On Thu, 25 Mar 2021 18:09:58 +0200
Leon Romanovsky [off-list ref] wrote:
On Thu, Mar 25, 2021 at 08:55:04AM -0600, Alex Williamson wrote:
quoted
On Thu, 25 Mar 2021 10:37:54 +0200
Leon Romanovsky [off-list ref] wrote:
quoted
On Wed, Mar 24, 2021 at 11:17:29AM -0600, Alex Williamson wrote:
quoted
On Wed, 24 Mar 2021 17:13:56 +0200
Leon Romanovsky [off-list ref] wrote:
<...>
quoted
quoted
Yes, and real testing/debugging almost always requires kernel rebuild.
Everything else is waste of time.
Sorry, this is nonsense. Allowing users to debug issues without a full
kernel rebuild is a good thing.
It is far from debug, this interface doesn't give you any answers why
the reset didn't work, it just helps you to find the one that works.
Unless you believe that this information will be enough to understand
the root cause, you will need to ask from the user to perform extra
tests, maybe try some quirk. All of that requires from the users to
rebuild their kernel.
So no, it is not debug.
It allows a user to experiment to determine (a) my device doesn't work
in a given scenario with the default configuration, but (b) if I change
the reset to this other thing it does work. That is a step in
debugging.
It's absurd to think that a sysfs attribute could provide root cause,
but it might be enough for someone to further help that user. It would
be a useful clue for a bug report. Yes, reaching root cause might
involve building a kernel, but that doesn't invalidate that having a
step towards debugging in the base kernel might be a useful tool.
Let's agree to do not agree.
quoted
53 more quoted lines
CI is only one aspect where I think this interface could be useful, as
below there's also a policy use case. Therefore my inclination is that
this would be included in default kernels and avoiding bloat is a good
thing. A CI environment can be used in different ways, it's not
necessarily building a new kernel for every test, nor do typical users
have access to those types of environments to report information in a
bug.
quoted
quoted
quoted
quoted
The root permissions doesn't protect from anything, SO lovers will use
root without even thinking twice.
Yes, with great power comes great responsibility. Many admins ignore
this. That's far beyond the scope of this series.
<...>
quoted
quoted
I'm trying to help you with your use case of providing reset policy
mechanism, which can be without CONFIG_EXPERT. However if you want
to continue path of having specific reset type only, please ensure
that this is not taken to the "bypass kernel" direction.
You've lost me, are you saying you'd be in favor of an interface that
allows an admin to specify an arbitrary list of reset methods because
that's somehow more in line with a policy choice than a userspace
workaround? This seems like unnecessary bloat because (a) it allows
the same bypass mechanism, and (b) a given device is only going to use
a single method anyway, so the functionality is unnecessary. Please
help me understand how this favors the policy use case. Thanks,
The policy decision is global logic that is easier to grasp. At some
point of our discussion, you presented the case where PM reset is not
defined well and you prefer to do bus reset (something like that).
I expect that QEMU sets same reset policy for all devices at the same
time instead of trying per-device to guess which one works.
And yes, you will be able to bypass kernel, but at least this interface
will be broader than initial one that serves only SO and workarounds.
I still think allocating objects for a list and managing that list is
too bloated and complicated, but I agree that being able to have more
fine grained control could be useful. Is it necessary to be able to
re-order reset methods or might it still be better aligned to a policy
use case if we allow plus and minus operators? For example, a device
might list:
[pm] [bus]
21 more quoted lines
The above doesn't support re-ordering though, we'll need to parse a
comma separated list for that.
quoted
If we need to allow re-ording, we'd want to use a byte-array where each
byte indicates a type of reset and perhaps a non-zero value in the
array indicates the method is enabled and the value indicates priority.
For example writing "dev_spec,flr,bus" would parse to write 1 to the
byte associated with the device specific reset, 2 to flr, 3 to bus
reset, then we'd process low to high (or maybe starting at a high value
to count down to zero might be more simple). We could do that with
only adding less than a fixed 8-bytes per device and no dynamic
allocation. Thoughts? Thanks,
Like I suggested, linked list will be easier and the reset will be
something like:
for_each_reset_type(device, type) {
switch (type) {
case PM:
ret = do_some_reset(device);
break;
case BUS:
.....
}
if (!ret || ret == -ENOMEM) <-- go to next type in linked list
return ret;
}
Perhaps Bjorn has some thoughts, but I don't like the dynamic memory
allocation and list management required for a linked list. Once bus &
slot reset are combined, I think we're talking about potentially 5
reset methods, so if we had:
const struct pci_reset_fn_method pci_reset_fn_methods[] = {
{ .reset_fn = &pci_dev_specific_reset, .name = "device_specific" },
{ .reset_fn = &pcie_flr, .name = "flr" },
{ .reset_fn = &pci_af_flr, .name = "af_flr" },
{ .reset_fn = &pci_pm_reset, .name = "pm" },
{ .reset_fn = &pci_reset_bus_function, .name = "bus" },
};
The pci_dev could include
u8 reset_methods[ARRAY_SIZE(pci_reset_fn_methods)];
And we could loop as:
u8 prio;
for (prio = ARRAY_SIZE(pci_reset_fn_methods); prio; prio--) {
int i;
for (i = 0; i < ARRAY_SIZE(pci_reset_fn_methods); i++) {
if (dev->reset_methods[i] == prio) {
ret = pci_reset_fn_methods[i].reset_fn(dev, probe);
if (ret != -ENOTTY)
return ret;
break;
}
}
if (i == ARRAY_SIZE(pci_reset_fn_methods))
break;
}
return -ENOTTY;
The sysfs _store function would probably do something like:40 more lines