We can use "const" with above field since we will set this field only once.Please don't ignore prior review comments: Either carry out what--- a/drivers/xen/xen-pciback/pci_stub.cOn 09.11.17 at 00:06, <Govinda.Tatti@xxxxxxxxxx> wrote:
+++ b/drivers/xen/xen-pciback/pci_stub.c
@@ -244,6 +244,91 @@ struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev,
return found_dev;
}
+struct pcistub_args {
+ struct pci_dev *dev;
was requested, or explain why the request can't be fulfilled. You
saying "This field will point to first device that is not owned by
pcistub" to Roger's request to make this a pointer to const is not a
valid reason to not do the adjustment; in fact your reply is entirely
unrelated to the request.
Sure, I will change it to "found".
+static int pcistub_search_dev(struct pci_dev *dev, void *data)Purely cosmetical, but anyway: Why not just "found"? What else
+{
+ struct pcistub_device *psdev;
+ struct pcistub_args *arg = data;
+ bool found_dev = false;
could be (not) found here other than the device in question?
Fine with me.
+ unsigned long flags;Despite the function needing to return int, this can be simplified to
+
+ spin_lock_irqsave(&pcistub_devices_lock, flags);
+
+ list_for_each_entry(psdev, &pcistub_devices, dev_list) {
+ if (psdev->dev == dev) {
+ found_dev = true;
+ arg->dcount++;
+ break;
+ }
+ }
+
+ spin_unlock_irqrestore(&pcistub_devices_lock, flags);
+
+ /* Device not owned by pcistub, someone owns it. Abort the walk */
+ if (!found_dev)
+ arg->dev = dev;
+
+ return found_dev ? 0 : 1;
"return !found_dev". I'd also like to note that the part of the
earlier comment related to this is sort of disconnected. How about
/* Device not owned by pcistub, someone owns it. Abort the walk */
if (!found_dev) {
arg->dev = dev;
return 1;
}
return 0;
OK. I will modify this comment as " Device not owned by pcistub. Abort the walk".
And finally - I don't think the comment is entirely correct - the
device not being owned by pciback doesn't necessarily mean it's
owned by another driver. It could as well be unowned.
+static int pcistub_reset_dev(struct pci_dev *dev)Is that really the case when you mean to do a slot reset? It was for
+{
+ struct xen_pcibk_dev_data *dev_data;
+ bool slot = false, bus = false;
+ struct pcistub_args arg = {};
+
+ if (!dev)
+ return -EINVAL;
+
+ dev_dbg(&dev->dev, "[%s]\n", __func__);
+
+ if (!pci_probe_reset_slot(dev->slot))
+ slot = true;
+ else if ((!pci_probe_reset_bus(dev->bus)) &&
+ (!pci_is_root_bus(dev->bus)))
+ bus = true;
+
+ if (!bus && !slot)
+ return -EOPNOTSUPP;
+
+ /*
+ * Make sure all devices on this bus are owned by the
+ * PCI backend so that we can safely reset the whole bus.
+ */
a reason that I had asked about a missing "else" in v1 review,
rather than questioning the conditional around the logic.
Sure, I will make this change.
+ pci_walk_bus(dev->bus, pcistub_search_dev, &arg);%#x
+
+ /* All devices under the bus should be part of pcistub! */
+ if (arg.dev) {
+ dev_err(&dev->dev, "%s device on bus 0x%x is not owned by pcistub\n",
Yet then, thinking about what would be useful information should the
situation really arise, I'm not convinced printing a bare bus number
here is useful either. Especially for the case of multiple parallel
requests you want to make it possible to match each message to the
original request (guest start or whatever). Hence I think you want
something like
"%s on the same bus as %s is not owned by " DRV_NAME "\n"
Sure, I can change it to
+ pci_name(arg.dev), dev->bus->number);While here the original device is perhaps not necessary to print,
+
+ return -EBUSY;
+ }
+
+ dev_dbg(&dev->dev, "pcistub owns %d devices on bus 0x%x\n",
+ arg.dcount, dev->bus->number);
the bare bus number doesn't carry enough information: You'll
want to prefix it by the segment number. Plus you'll want to use
canonical formatting (ssss:bb), so one can get matches when
suitably grep-ing the log. Perhaps bus->name is what you're
after.