On Sat, 20 Oct 2018 10:03:53 -0500 Bjorn Helgaas <helgaas@xxxxxxxxxx> wrote: > On Fri, Oct 19, 2018 at 10:58:00PM -0400, Sinan Kaya wrote: > > On 10/19/2018 10:09 PM, Bjorn Helgaas wrote: > > > On Fri, Oct 19, 2018 at 02:11:21AM +0000, Sinan Kaya wrote: > > > > We need a contract between the reset API users and the PCI core about the > > > > types of reset that a user needs vs. what PCI core can do internally. > > > > If a platform supports hotplug, we need to do hotplug reset as an example. > > > > > > Somewhere this needs a description of a bug that's being fixed or some > > > other justification, e.g., code simplification. The above is a little > > > too abstract for me to grasp it. > > > > This series was in response to a request from Alex to have external users > > some level of control on what PCI core can do internally. > > > > On the other hand, I have been posting patches to remove direct access from > > external users to PCI core internals and hide all reset semantics like > > save/restore from the users. I like giving less power to the users :) > > That's a good goal. Along the way we might need to tweak the users to > align their usage to some common cases. > > > > > Expose the reset types to the drivers and try different reset types based > > > > on the new reset_type parameter. > > > > > > > > Most users are expected to use PCI_RESET_ANY, PCI_RESET_FUNC or > > > > PCI_RESET_LINK parameters. > > > > > > There are fewer than a dozen callers of all these functions and the > > > complication of these interfaces doesn't seem commensurate with the > > > problem. With six different interfaces and five independent bit > > > flags, the possibilities are way more than necessary. > > > > True, I posted an RFC to reduce 5 function reset API flavors to 1 and > > rely on the flags. > > I don't like the flags. Even one API with five bit flags has 32 > possible combinations, most of which are meaningless. > > > Even these generic reset examples are not really generic today. Some of them > > call reset from probe path and use the locked reset API > > (pci_reset_function_locked()). > > > > Others call the reset but prefer to not save/restore context. > > (__pci_reset_function_locked()). Some drivers even implemented their own > > context save/restore code themselves. > > > > There are others that do obtain the lock as well as save/restore context. > > (pci_reset_function()) > > > > I really don't like having these many reset API flavors and I thought > > we could do something about that. > > I agree we have too many flavors. I'm not convinced all the variation > in save/restore is necessary; I suspect most of that is accidental and > drivers could probably all live with a single solution. > > > We can also drop the series if we think that current API are good enough > > and nuances are well understood. > > I don't think the current API is good enough :) It's just a small > matter of sorting out a better one. The thing that I was really hoping to fix was what happened in 811c5cb37df4 where we used to have separate bus vs slot reset interfaces that vfio-pci made use of, but these were abstracted away such that even though vfio-pci is specifically trying to achieve one or the other, not just whichever the pci-core chooses to use, we no longer have an interface to do that. It doesn't make sense that we have pci_probe_reset_slot() and pci_probe_reset_bus() exported for drivers yet only pci_reset_bus() to execute the reset, which actually does a slot reset, not a bus reset, if it's available (and hopefully it picks the one that aligns with what the caller was intending). I agree that we should have the "I don't really know what I'm doing, please make the correct choice obvious" interface, but at the same time I don't see the value in penalizing drivers that do know what they're doing and want to make a specific choice. In that sense a desire to give less power to the user (ie. GPL kernel drivers) seems misplaced, I think we need to aim for a balance where the interface is hard to misuse, but at the same time retains useful functionality. It can't just be one or the other. I was also in a discussion today that seems like it could leverage aspects of this series where there's a desire to allow system admin level influence over the type of reset used for a device. We can do this in the kernel via device specific resets, but it's not always the case that we can develop a universal recipe for blacklisting a reset mechanism for a given device. Consider for instance a device where FLR works well only with some firmware revisions, but different system vendors might report similar firmware revisions, some afflicted, others not. The bar is relatively high to not introduce device regressions and incorrectly requiring a device to use SBR rather than FLR can have functionality repercussions. I know Bjorn has a desire to have things work well by default and command line options and sysfs tweaking of devices are obstacles to that, but there are cases where I don't see that we have a clear path to impose a device specific quirk without fear of regressions, and some mechanism of letting userspace policy influence the operation seems a viable path. IMO it would also be a useful debugging tool if I could select a specific method of reset for a device from userspace and perhaps the infrastructure for this might make it easier to test and implement device specific quirks that simply need to pick a reset mechanism different from the one the kernel chooses by default. The interface in this proposal maybe needs some work, but at some level it seems we need to consider which resets the device/bus/slot is capable of, resets blacklisted/selected/prioritized by the user/driver, and allow the caller to identify the type of reset they want to achieve. Can we agree that's a desirable goal? Thanks, Alex