Skip to contentSkip to conversation

Xen/pciback: Implement PCI slot or bus reset with 'do_flr' SysFS attribute

PATCH Superseded Govinda Tatti 6 participants 38 messages Nov 6, 2017 – Nov 30, 2017 Xen hypervisor interface

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Xen/pciback: Implement PCI slot or bus reset with 'do_flr' SysFS attribute

The life-cycle of a PCI device in Xen pciback is complex and is constrained by the generic PCI locking mechanism.

- It starts with the device being bound to us, for which we do a function reset (done via SysFS so the PCI lock is held).
- If the device is unbound from us, we also do a function reset (done via SysFS so the PCI lock is held).
- If the device is un-assigned from a guest - we do a function reset (no PCI lock is held).

All reset operations are done on the individual PCI function level (so bus:device:function).

The reset for an individual PCI function means device must support FLR (PCIe or AF), PM reset on D3hot->D0 device specific reset, or a secondary bus reset for a singleton device on a bus but FLR does not have widespread support or it is not reliable in some cases. So, we need to provide an alternate mechanism to users to perform a slot or bus level reset.

Currently, a slot or bus reset is not exposed in SysFS as there is no good way of exposing a bus topology there. This is due to the complexity - we MUST know that the different functions of a PCIe device are not in use by other drivers, or if they are in use (say one of them is assigned to a guest and the other is idle) - it is still OK to reset the slot (assuming both of them are owned by Xen pciback).

This patch does that by doing a slot or bus reset (if slot not supported) if all of the functions of a PCIe device belong to Xen PCIback.

Due to the complexity with the PCI lock we cannot do the reset when a device is bound ('echo $BDF > bind') or when unbound ('echo $BDF > unbind') as the pci_[slot|bus]_reset also takes the same lock resulting in a dead-lock.

Putting the reset function in a work-queue or thread won't work either - as we have to do the reset function outside the 'unbind' context (it holds the PCI lock). But once you 'unbind' a device the device is no longer under the ownership of Xen pciback and the pci_set_drvdata has been reset, so we cannot use a thread for this.

Instead of doing all this complex dance, we depend on the tool-stack doing the right thing. As such, we implement the 'do_flr' SysFS attribute which 'xl' uses when a device is detached or attached from/to a guest. It bypasses the need to worry about the PCI lock.

To not inadvertently do a bus reset that would affect devices that are in use by other drivers (other than Xen pciback) prior to the reset, we check that all of the devices under the bridge are owned by Xen pciback. If they are not, we refrain from executing the bus (or slot) reset.

---
 Documentation/ABI/testing/sysfs-driver-pciback |  12 +++
 drivers/xen/xen-pciback/pci_stub.c             | 125 +++++++++++++++++++++++++
 2 files changed, 137 insertions(+)
Documentation/ABI/testing/sysfs-driver-pciback +12 -0
index 6a733bf..ccf7dc0 100644
@@ -11,3 +11,15 @@ Description:
                 #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                 will allow the guest to read and write to the configuration
                 register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.
drivers/xen/xen-pciback/pci_stub.c +125 -0

149 lines not on this page · raw message

Signature · 1 line
2.9.5
#1 lore raw
Quoted 83 lines · Govinda Tatti

The life-cycle of a PCI device in Xen pciback is complex and is constrained by the generic PCI locking mechanism.

- It starts with the device being bound to us, for which we do a function reset (done via SysFS so the PCI lock is held).
- If the device is unbound from us, we also do a function reset (done via SysFS so the PCI lock is held).
- If the device is un-assigned from a guest - we do a function reset (no PCI lock is held).

All reset operations are done on the individual PCI function level (so bus:device:function).

The reset for an individual PCI function means device must support FLR (PCIe or AF), PM reset on D3hot->D0 device specific reset, or a secondary bus reset for a singleton device on a bus but FLR does not have widespread support or it is not reliable in some cases. So, we need to provide an alternate mechanism to users to perform a slot or bus level reset.

Currently, a slot or bus reset is not exposed in SysFS as there is no good way of exposing a bus topology there. This is due to the complexity - we MUST know that the different functions of a PCIe device are not in use by other drivers, or if they are in use (say one of them is assigned to a guest and the other is idle) - it is still OK to reset the slot (assuming both of them are owned by Xen pciback).

This patch does that by doing a slot or bus reset (if slot not supported) if all of the functions of a PCIe device belong to Xen PCIback.

Due to the complexity with the PCI lock we cannot do the reset when a device is bound ('echo $BDF > bind') or when unbound ('echo $BDF > unbind') as the pci_[slot|bus]_reset also takes the same lock resulting in a dead-lock.

Putting the reset function in a work-queue or thread won't work either - as we have to do the reset function outside the 'unbind' context (it holds the PCI lock). But once you 'unbind' a device the device is no longer under the ownership of Xen pciback and the pci_set_drvdata has been reset, so we cannot use a thread for this.

Instead of doing all this complex dance, we depend on the tool-stack doing the right thing. As such, we implement the 'do_flr' SysFS attribute which 'xl' uses when a device is detached or attached from/to a guest. It bypasses the need to worry about the PCI lock.

To not inadvertently do a bus reset that would affect devices that are in use by other drivers (other than Xen pciback) prior to the reset, we check that all of the devices under the bridge are owned by Xen pciback. If they are not, we refrain from executing the bus (or slot) reset.

---
 Documentation/ABI/testing/sysfs-driver-pciback |  12 +++
 drivers/xen/xen-pciback/pci_stub.c             | 125 +++++++++++++++++++++++++
 2 files changed, 137 insertions(+)
Documentation/ABI/testing/sysfs-driver-pciback +12 -0
index 6a733bf..ccf7dc0 100644
@@ -11,3 +11,15 @@ Description:
                 #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                 will allow the guest to read and write to the configuration
                 register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.
drivers/xen/xen-pciback/pci_stub.c +0 -0
index 6331a95..2b2c269 100644

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 248

Quoted 5 lines
drivers/xen/xen-pciback/pci_stub.c +2 -0
@@ -244,6 +244,96 @@ struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev,
 	return found_dev;
 }
 
+struct pcistub_args {
+	struct pci_dev *dev;

const?

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 249

Quoted 1 line
drivers/xen/xen-pciback/pci_stub.c +1 -0
+	int dcount;

unsigned int.

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 252

Quoted 3 lines
drivers/xen/xen-pciback/pci_stub.c +3 -0
+};
+
+static int pcistub_search_dev(struct pci_dev *dev, void *data)

Seems like this function would better return a boolean rather than an int.

Quoted 31 lines
drivers/xen/xen-pciback/pci_stub.c +31 -0
+{
+	struct pcistub_device *psdev;
+	struct pcistub_args *arg = data;
+	bool found_dev = false;
+	unsigned long flags;
+
+	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;
+}
+
+static int pcistub_reset_dev(struct pci_dev *dev)
+{
+	struct xen_pcibk_dev_data *dev_data;
+	bool slot = false, bus = false;
+
+	if (!dev)

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 293

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +10 -0
+		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)) {
+		/* We won't attempt to reset a root bridge. */
+		if (!pci_is_root_bus(dev->bus))
+			bus = true;

Con't you join the two if, ie:

} else if (!pci_probe_reset_bus(dev->bus) && !pci_is_root_bus(dev->bus)) {

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +10 -0
+	}
+
+	if (!bus && !slot)
+		return -EOPNOTSUPP;
+
+	if (!slot) {
+		struct pcistub_args arg = { .dev = NULL, .dcount = 0 };
+
+		/*
+		 * Make sure all devices on this bus are owned by the

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 313

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +10 -0
+		 * PCI backend so that we can safely reset the whole bus.
+		 */
+		pci_walk_bus(dev->bus, pcistub_search_dev, &arg);
+
+		/* All devices under the bus should be part of pcistub! */
+		if (arg.dev) {
+			dev_err(&dev->dev, "%s device on the bus is not owned by pcistub\n",
+				pci_name(arg.dev));
+
+			return -EBUSY;

Not sure EBUSY is the best return code here, EINVAL?

Quoted 30 lines
drivers/xen/xen-pciback/pci_stub.c +23 -0
+		}
+
+		dev_dbg(&dev->dev, "pcistub owns %d devices on the bus\n",
+			arg.dcount);
+	}
+
+	dev_data = pci_get_drvdata(dev);
+	if (!pci_load_saved_state(dev, dev_data->pci_saved_state))
+		pci_restore_state(dev);
+
+	/* This disables the device. */
+	xen_pcibk_reset_device(dev);
+
+	/* Cleanup up any emulated fields */
+	xen_pcibk_config_reset_dev(dev);
+
+	dev_dbg(&dev->dev, "resetting %s device using %s reset\n",
+		pci_name(dev), slot ? "slot" : "bus");
+
+	return slot ? pci_try_reset_slot(dev->slot) :
+			pci_try_reset_bus(dev->bus);
+}
+
 /*
  * Called when:
  *  - XenBus state has been reconfigure (pci unplug). See xen_pcibk_remove_device
@@ -1434,6 +1524,34 @@ static ssize_t permissive_show(struct device_driver *drv, char *buf)
 static DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, permissive_show,
 		   permissive_add);
 

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1536

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +10 -0
+static ssize_t pcistub_do_flr(struct device_driver *drv, const char *buf,
+			      size_t count)
+{
+	struct pcistub_device *psdev;
+	int domain, bus, slot, func;
+	int err;
+
+	err = str_to_slot(buf, &domain, &bus, &slot, &func);
+	if (err)
+		goto out;
		return err;

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1538

Quoted 2 lines
drivers/xen/xen-pciback/pci_stub.c +2 -0
+
+	psdev = pcistub_device_find(domain, bus, slot, func);
	if (!psdev)
		return -ENODEV;

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1550

Quoted 12 lines
drivers/xen/xen-pciback/pci_stub.c +12 -0
+	if (psdev) {
+		err = pcistub_reset_dev(psdev->dev);
+		pcistub_device_put(psdev);
+	} else {
+		err = -ENODEV;
+	}
+
+out:
+	if (!err)
+		err = count;
+
+	return err;

What's the purpose of returning count here?

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw

Thanks Roger for your review comments. Please see below for my comments.

Quoted 87 lines · Roger Pau Monné
Quoted 86 lines · Govinda Tatti

The life-cycle of a PCI device in Xen pciback is complex and is constrained by the generic PCI locking mechanism.

- It starts with the device being bound to us, for which we do a function reset (done via SysFS so the PCI lock is held).
- If the device is unbound from us, we also do a function reset (done via SysFS so the PCI lock is held).
- If the device is un-assigned from a guest - we do a function reset (no PCI lock is held).

All reset operations are done on the individual PCI function level (so bus:device:function).

The reset for an individual PCI function means device must support FLR (PCIe or AF), PM reset on D3hot->D0 device specific reset, or a secondary bus reset for a singleton device on a bus but FLR does not have widespread support or it is not reliable in some cases. So, we need to provide an alternate mechanism to users to perform a slot or bus level reset.

Currently, a slot or bus reset is not exposed in SysFS as there is no good way of exposing a bus topology there. This is due to the complexity - we MUST know that the different functions of a PCIe device are not in use by other drivers, or if they are in use (say one of them is assigned to a guest and the other is idle) - it is still OK to reset the slot (assuming both of them are owned by Xen pciback).

This patch does that by doing a slot or bus reset (if slot not supported) if all of the functions of a PCIe device belong to Xen PCIback.

Due to the complexity with the PCI lock we cannot do the reset when a device is bound ('echo $BDF > bind') or when unbound ('echo $BDF > unbind') as the pci_[slot|bus]_reset also takes the same lock resulting in a dead-lock.

Putting the reset function in a work-queue or thread won't work either - as we have to do the reset function outside the 'unbind' context (it holds the PCI lock). But once you 'unbind' a device the device is no longer under the ownership of Xen pciback and the pci_set_drvdata has been reset, so we cannot use a thread for this.

Instead of doing all this complex dance, we depend on the tool-stack doing the right thing. As such, we implement the 'do_flr' SysFS attribute which 'xl' uses when a device is detached or attached from/to a guest. It bypasses the need to worry about the PCI lock.

To not inadvertently do a bus reset that would affect devices that are in use by other drivers (other than Xen pciback) prior to the reset, we check that all of the devices under the bridge are owned by Xen pciback. If they are not, we refrain from executing the bus (or slot) reset.

---
  Documentation/ABI/testing/sysfs-driver-pciback |  12 +++
  drivers/xen/xen-pciback/pci_stub.c             | 125 +++++++++++++++++++++++++
  2 files changed, 137 insertions(+)
Documentation/ABI/testing/sysfs-driver-pciback +12 -0
index 6a733bf..ccf7dc0 100644
@@ -11,3 +11,15 @@ Description:
                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                  will allow the guest to read and write to the configuration
                  register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.
drivers/xen/xen-pciback/pci_stub.c +0 -0
index 6331a95..2b2c269 100644
@@ -244,6 +244,96 @@ struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev,
  	return found_dev;
  }
 
Quoted 3 lines

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 248

Quoted 2 lines
drivers/xen/xen-pciback/pci_stub.c +2 -0
+struct pcistub_args {
+	struct pci_dev *dev;

const?

This field will point to first device that is not owned by pcistub.

Quoted 3 lines

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 249

Quoted 2 lines
drivers/xen/xen-pciback/pci_stub.c +1 -0
+	int dcount;

unsigned int.

OK.

Quoted 6 lines

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 252

Quoted 4 lines
drivers/xen/xen-pciback/pci_stub.c +3 -0
+};
+
+static int pcistub_search_dev(struct pci_dev *dev, void *data)

Seems like this function would better return a boolean rather than an int.

pcistub_search_dev() is invoked through pci_walk_bus() and it expects int return code.

Quoted 44 lines
Quoted 32 lines
drivers/xen/xen-pciback/pci_stub.c +31 -0
+{
+	struct pcistub_device *psdev;
+	struct pcistub_args *arg = data;
+	bool found_dev = false;
+	unsigned long flags;
+
+	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;
+}
+
+static int pcistub_reset_dev(struct pci_dev *dev)
+{
+	struct xen_pcibk_dev_data *dev_data;
+	bool slot = false, bus = false;
+
+	if (!dev)

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 293

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +10 -0
+		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)) {
+		/* We won't attempt to reset a root bridge. */
+		if (!pci_is_root_bus(dev->bus))
+			bus = true;

Con't you join the two if, ie:

Quoted 1 line

} else if (!pci_probe_reset_bus(dev->bus) && !pci_is_root_bus(dev->bus)) {

Ok

Quoted 14 lines
Quoted 14 lines
drivers/xen/xen-pciback/pci_stub.c +13 -0
+	}
+
+	if (!bus && !slot)
+		return -EOPNOTSUPP;
+
+	if (!slot) {
+		struct pcistub_args arg = { .dev = NULL, .dcount = 0 };
+
+		/*
+		 * Make sure all devices on this bus are owned by the
+		 * PCI backend so that we can safely reset the whole bus.
+		 */
+		pci_walk_bus(dev->bus, pcistub_search_dev, &arg);
Quoted 8 lines

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 313

Quoted 7 lines
drivers/xen/xen-pciback/pci_stub.c +7 -0
+
+		/* All devices under the bus should be part of pcistub! */
+		if (arg.dev) {
+			dev_err(&dev->dev, "%s device on the bus is not owned by pcistub\n",
+				pci_name(arg.dev));
+
+			return -EBUSY;

Not sure EBUSY is the best return code here, EINVAL?

I don't think EINVAL is right return code for this case.

Quoted 48 lines
Quoted 31 lines
drivers/xen/xen-pciback/pci_stub.c +23 -0
+		}
+
+		dev_dbg(&dev->dev, "pcistub owns %d devices on the bus\n",
+			arg.dcount);
+	}
+
+	dev_data = pci_get_drvdata(dev);
+	if (!pci_load_saved_state(dev, dev_data->pci_saved_state))
+		pci_restore_state(dev);
+
+	/* This disables the device. */
+	xen_pcibk_reset_device(dev);
+
+	/* Cleanup up any emulated fields */
+	xen_pcibk_config_reset_dev(dev);
+
+	dev_dbg(&dev->dev, "resetting %s device using %s reset\n",
+		pci_name(dev), slot ? "slot" : "bus");
+
+	return slot ? pci_try_reset_slot(dev->slot) :
+			pci_try_reset_bus(dev->bus);
+}
+
  /*
   * Called when:
   *  - XenBus state has been reconfigure (pci unplug). See xen_pcibk_remove_device
@@ -1434,6 +1524,34 @@ static ssize_t permissive_show(struct device_driver *drv, char *buf)
  static DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, permissive_show,
  		   permissive_add);
 

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1536

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +10 -0
+static ssize_t pcistub_do_flr(struct device_driver *drv, const char *buf,
+			      size_t count)
+{
+	struct pcistub_device *psdev;
+	int domain, bus, slot, func;
+	int err;
+
+	err = str_to_slot(buf, &domain, &bus, &slot, &func);
+	if (err)
+		goto out;
		return err;

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1538

Quoted 2 lines
drivers/xen/xen-pciback/pci_stub.c +2 -0
+
+	psdev = pcistub_device_find(domain, bus, slot, func);
	if (!psdev)
		return -ENODEV;
Quoted 13 lines

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1550

Quoted 12 lines
drivers/xen/xen-pciback/pci_stub.c +12 -0
+	if (psdev) {
+		err = pcistub_reset_dev(psdev->dev);
+		pcistub_device_put(psdev);
+	} else {
+		err = -ENODEV;
+	}
+
+out:
+	if (!err)
+		err = count;
+
+	return err;

What's the purpose of returning count here?

Not sure. Will check with Konrad and address this comment.

I will post revised patch later this week. Thanks.

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
In reply to Roger Pau Monné

Thanks Roger for your review comments. Please see below for my comments.

Quoted 87 lines · Roger Pau Monné
Quoted 86 lines · Govinda Tatti

The life-cycle of a PCI device in Xen pciback is complex and is constrained by the generic PCI locking mechanism.

- It starts with the device being bound to us, for which we do a function reset (done via SysFS so the PCI lock is held).
- If the device is unbound from us, we also do a function reset (done via SysFS so the PCI lock is held).
- If the device is un-assigned from a guest - we do a function reset (no PCI lock is held).

All reset operations are done on the individual PCI function level (so bus:device:function).

The reset for an individual PCI function means device must support FLR (PCIe or AF), PM reset on D3hot->D0 device specific reset, or a secondary bus reset for a singleton device on a bus but FLR does not have widespread support or it is not reliable in some cases. So, we need to provide an alternate mechanism to users to perform a slot or bus level reset.

Currently, a slot or bus reset is not exposed in SysFS as there is no good way of exposing a bus topology there. This is due to the complexity - we MUST know that the different functions of a PCIe device are not in use by other drivers, or if they are in use (say one of them is assigned to a guest and the other is idle) - it is still OK to reset the slot (assuming both of them are owned by Xen pciback).

This patch does that by doing a slot or bus reset (if slot not supported) if all of the functions of a PCIe device belong to Xen PCIback.

Due to the complexity with the PCI lock we cannot do the reset when a device is bound ('echo $BDF > bind') or when unbound ('echo $BDF > unbind') as the pci_[slot|bus]_reset also takes the same lock resulting in a dead-lock.

Putting the reset function in a work-queue or thread won't work either - as we have to do the reset function outside the 'unbind' context (it holds the PCI lock). But once you 'unbind' a device the device is no longer under the ownership of Xen pciback and the pci_set_drvdata has been reset, so we cannot use a thread for this.

Instead of doing all this complex dance, we depend on the tool-stack doing the right thing. As such, we implement the 'do_flr' SysFS attribute which 'xl' uses when a device is detached or attached from/to a guest. It bypasses the need to worry about the PCI lock.

To not inadvertently do a bus reset that would affect devices that are in use by other drivers (other than Xen pciback) prior to the reset, we check that all of the devices under the bridge are owned by Xen pciback. If they are not, we refrain from executing the bus (or slot) reset.

---
  Documentation/ABI/testing/sysfs-driver-pciback |  12 +++
  drivers/xen/xen-pciback/pci_stub.c             | 125 +++++++++++++++++++++++++
  2 files changed, 137 insertions(+)
Documentation/ABI/testing/sysfs-driver-pciback +12 -0
index 6a733bf..ccf7dc0 100644
@@ -11,3 +11,15 @@ Description:
                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                  will allow the guest to read and write to the configuration
                  register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.
drivers/xen/xen-pciback/pci_stub.c +0 -0
index 6331a95..2b2c269 100644
@@ -244,6 +244,96 @@ struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev,
  	return found_dev;
  }
 
Quoted 3 lines

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 248

Quoted 2 lines
drivers/xen/xen-pciback/pci_stub.c +2 -0
+struct pcistub_args {
+	struct pci_dev *dev;

const?

This field will point to first device that is not owned by pcistub.

Quoted 3 lines

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 249

Quoted 2 lines
drivers/xen/xen-pciback/pci_stub.c +1 -0
+	int dcount;

unsigned int.

OK.

Quoted 6 lines

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 252

Quoted 4 lines
drivers/xen/xen-pciback/pci_stub.c +3 -0
+};
+
+static int pcistub_search_dev(struct pci_dev *dev, void *data)

Seems like this function would better return a boolean rather than an int.

pcistub_search_dev() is invoked through pci_walk_bus() and it expects int return code.

Quoted 44 lines
Quoted 32 lines
drivers/xen/xen-pciback/pci_stub.c +31 -0
+{
+	struct pcistub_device *psdev;
+	struct pcistub_args *arg = data;
+	bool found_dev = false;
+	unsigned long flags;
+
+	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;
+}
+
+static int pcistub_reset_dev(struct pci_dev *dev)
+{
+	struct xen_pcibk_dev_data *dev_data;
+	bool slot = false, bus = false;
+
+	if (!dev)

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 293

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +10 -0
+		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)) {
+		/* We won't attempt to reset a root bridge. */
+		if (!pci_is_root_bus(dev->bus))
+			bus = true;

Con't you join the two if, ie:

Quoted 1 line

} else if (!pci_probe_reset_bus(dev->bus) && !pci_is_root_bus(dev->bus)) {

Ok

Quoted 14 lines
Quoted 14 lines
drivers/xen/xen-pciback/pci_stub.c +13 -0
+	}
+
+	if (!bus && !slot)
+		return -EOPNOTSUPP;
+
+	if (!slot) {
+		struct pcistub_args arg = { .dev = NULL, .dcount = 0 };
+
+		/*
+		 * Make sure all devices on this bus are owned by the
+		 * PCI backend so that we can safely reset the whole bus.
+		 */
+		pci_walk_bus(dev->bus, pcistub_search_dev, &arg);
Quoted 8 lines

drivers/xen/xen-pciback/pci_stub.c struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev, · line 313

Quoted 7 lines
drivers/xen/xen-pciback/pci_stub.c +7 -0
+
+		/* All devices under the bus should be part of pcistub! */
+		if (arg.dev) {
+			dev_err(&dev->dev, "%s device on the bus is not owned by pcistub\n",
+				pci_name(arg.dev));
+
+			return -EBUSY;

Not sure EBUSY is the best return code here, EINVAL?

I don't think EINVAL is right return code for this case.

Quoted 48 lines
Quoted 31 lines
drivers/xen/xen-pciback/pci_stub.c +23 -0
+		}
+
+		dev_dbg(&dev->dev, "pcistub owns %d devices on the bus\n",
+			arg.dcount);
+	}
+
+	dev_data = pci_get_drvdata(dev);
+	if (!pci_load_saved_state(dev, dev_data->pci_saved_state))
+		pci_restore_state(dev);
+
+	/* This disables the device. */
+	xen_pcibk_reset_device(dev);
+
+	/* Cleanup up any emulated fields */
+	xen_pcibk_config_reset_dev(dev);
+
+	dev_dbg(&dev->dev, "resetting %s device using %s reset\n",
+		pci_name(dev), slot ? "slot" : "bus");
+
+	return slot ? pci_try_reset_slot(dev->slot) :
+			pci_try_reset_bus(dev->bus);
+}
+
  /*
   * Called when:
   *  - XenBus state has been reconfigure (pci unplug). See xen_pcibk_remove_device
@@ -1434,6 +1524,34 @@ static ssize_t permissive_show(struct device_driver *drv, char *buf)
  static DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, permissive_show,
  		   permissive_add);
 

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1536

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +10 -0
+static ssize_t pcistub_do_flr(struct device_driver *drv, const char *buf,
+			      size_t count)
+{
+	struct pcistub_device *psdev;
+	int domain, bus, slot, func;
+	int err;
+
+	err = str_to_slot(buf, &domain, &bus, &slot, &func);
+	if (err)
+		goto out;
		return err;

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1538

Quoted 2 lines
drivers/xen/xen-pciback/pci_stub.c +2 -0
+
+	psdev = pcistub_device_find(domain, bus, slot, func);
	if (!psdev)
		return -ENODEV;
Quoted 13 lines

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1550

Quoted 12 lines
drivers/xen/xen-pciback/pci_stub.c +12 -0
+	if (psdev) {
+		err = pcistub_reset_dev(psdev->dev);
+		pcistub_device_put(psdev);
+	} else {
+		err = -ENODEV;
+	}
+
+out:
+	if (!err)
+		err = count;
+
+	return err;

What's the purpose of returning count here?

Not sure. Will check with Konrad and address this comment.

I will post revised patch later this week. Thanks.

Cheers
GOVINDA

maintainer
#4 lore raw
Quoted 11 lines · Govinda Tatti

Thanks Roger for your review comments. Please see below for my comments.

Quoted 7 lines · Roger Pau Monné

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1550

Quoted 5 lines · Govinda Tatti
drivers/xen/xen-pciback/pci_stub.c +5 -0
+out:
+    if (!err)
+        err = count;
+
+    return err;

What's the purpose of returning count here?

Not sure. Will check with Konrad and address this comment.

You are telling sysfs that you have consumed all input characters.

Juergen

#5 lore raw
Quoted 5 lines · Juergen Gross
Quoted 4 lines · Govinda Tatti

Thanks Roger for your review comments. Please see below for my comments.

Quoted 1 line · Roger Pau Monné

On Mon, Nov 06, 2017 at 12:48:42PM -0500, Govinda Tatti wrote:

Quoted 9 lines
Quoted 7 lines
Quoted 6 lines

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1550

Quoted 5 lines
drivers/xen/xen-pciback/pci_stub.c +5 -0
+out:
+    if (!err)
+        err = count;
+
+    return err;

What's the purpose of returning count here?

Not sure. Will check with Konrad and address this comment.

You are telling sysfs that you have consumed all input characters.

Thanks Juergen

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
In reply to Juergen Gross
Quoted 5 lines · Juergen Gross
Quoted 4 lines · Govinda Tatti

Thanks Roger for your review comments. Please see below for my comments.

Quoted 1 line · Roger Pau Monné

On Mon, Nov 06, 2017 at 12:48:42PM -0500, Govinda Tatti wrote:

Quoted 9 lines
Quoted 7 lines
Quoted 6 lines

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1550

Quoted 5 lines
drivers/xen/xen-pciback/pci_stub.c +5 -0
+out:
+    if (!err)
+        err = count;
+
+    return err;

What's the purpose of returning count here?

Not sure. Will check with Konrad and address this comment.

You are telling sysfs that you have consumed all input characters.

Thanks Juergen

Cheers
GOVINDA

maintainer
#7 lore raw
In reply to Govinda Tatti
Quoted 11 lines · Govinda Tatti

Thanks Roger for your review comments. Please see below for my comments.

Quoted 7 lines · Roger Pau Monné

drivers/xen/xen-pciback/pci_stub.c static ssize_t permissive_show(struct device_driver *drv, char *buf) · line 1550

Quoted 5 lines · Govinda Tatti
drivers/xen/xen-pciback/pci_stub.c +5 -0
+out:
+    if (!err)
+        err = count;
+
+    return err;

What's the purpose of returning count here?

Not sure. Will check with Konrad and address this comment.

You are telling sysfs that you have consumed all input characters.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw
In reply to Govinda Tatti
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +2 -0
@@ -11,3 +11,15 @@ Description:
                 #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                 will allow the guest to read and write to the configuration
                 register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 13 lines
Documentation/ABI/testing/sysfs-driver-pciback +13 -0
+static int pcistub_reset_dev(struct pci_dev *dev)
+{
+	struct xen_pcibk_dev_data *dev_data;
+	bool slot = false, bus = false;
+
+	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)) {

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+		/* We won't attempt to reset a root bridge. */
+		if (!pci_is_root_bus(dev->bus))
+			bus = true;
+	}
+
+	if (!bus && !slot)
+		return -EOPNOTSUPP;
+
+	if (!slot) {
+		struct pcistub_args arg = { .dev = NULL, .dcount = 0 };

Neither of the two initializers is really needed - just {} will do.

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+		/*
+		 * Make sure all devices on this bus are owned by the
+		 * PCI backend so that we can safely reset the whole bus.
+		 */
+		pci_walk_bus(dev->bus, pcistub_search_dev, &arg);
+
+		/* All devices under the bus should be part of pcistub! */
+		if (arg.dev) {
+			dev_err(&dev->dev, "%s device on the bus is not owned by pcistub\n",
+				pci_name(arg.dev));

I think "device" is superfluous here, while "the bus" could do with replacing by something actually identifying the bus.

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 5 lines
Documentation/ABI/testing/sysfs-driver-pciback +5 -0
+			return -EBUSY;
+		}
+
+		dev_dbg(&dev->dev, "pcistub owns %d devices on the bus\n",
+			arg.dcount);

Same here for "the bus", provided this log message is useful in the first place.

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 1 line
Documentation/ABI/testing/sysfs-driver-pciback +1 -0
+	}

Aren't you missing an "else" here? Aiui in the "slot" case it may still be multiple devices/functions which are affected.

Jan

#9 lore raw

Thanks Jan for your review comments. Please see below for my comments.

Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                  will allow the guest to read and write to the configuration
                  register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

Quoted 17 lines
Quoted 17 lines
Documentation/ABI/testing/sysfs-driver-pciback +16 -0
+static int pcistub_reset_dev(struct pci_dev *dev)
+{
+	struct xen_pcibk_dev_data *dev_data;
+	bool slot = false, bus = false;
+
+	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)) {
+		/* We won't attempt to reset a root bridge. */
+		if (!pci_is_root_bus(dev->bus))
+			bus = true;
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 7 lines
Documentation/ABI/testing/sysfs-driver-pciback +7 -0
+	}
+
+	if (!bus && !slot)
+		return -EOPNOTSUPP;
+
+	if (!slot) {
+		struct pcistub_args arg = { .dev = NULL, .dcount = 0 };

Neither of the two initializers is really needed - just {} will do.

OK.

Quoted 13 lines

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 11 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+		/*
+		 * Make sure all devices on this bus are owned by the
+		 * PCI backend so that we can safely reset the whole bus.
+		 */
+		pci_walk_bus(dev->bus, pcistub_search_dev, &arg);
+
+		/* All devices under the bus should be part of pcistub! */
+		if (arg.dev) {
+			dev_err(&dev->dev, "%s device on the bus is not owned by pcistub\n",
+				pci_name(arg.dev));

I think "device" is superfluous here, while "the bus" could do with replacing by something actually identifying the bus.

I assume you want "bus" number to be printed in above msg. If yes, will do.

Quoted 9 lines

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +5 -0
+			return -EBUSY;
+		}
+
+		dev_dbg(&dev->dev, "pcistub owns %d devices on the bus\n",
+			arg.dcount);

Same here for "the bus", provided this log message is useful in the first place.

Quoted 3 lines

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 1 line
Documentation/ABI/testing/sysfs-driver-pciback +1 -0
+	}

Aren't you missing an "else" here? Aiui in the "slot" case it may still be multiple devices/functions which are affected.

Good catch.  Our original code was performing same check, both for bus and slot case but somehow I removed it during internal review based on some comment.

I will post revised patch later this week. Thanks.

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw
In reply to Jan Beulich

Thanks Jan for your review comments. Please see below for my comments.

Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                  will allow the guest to read and write to the configuration
                  register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

Quoted 17 lines
Quoted 17 lines
Documentation/ABI/testing/sysfs-driver-pciback +16 -0
+static int pcistub_reset_dev(struct pci_dev *dev)
+{
+	struct xen_pcibk_dev_data *dev_data;
+	bool slot = false, bus = false;
+
+	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)) {
+		/* We won't attempt to reset a root bridge. */
+		if (!pci_is_root_bus(dev->bus))
+			bus = true;
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 7 lines
Documentation/ABI/testing/sysfs-driver-pciback +7 -0
+	}
+
+	if (!bus && !slot)
+		return -EOPNOTSUPP;
+
+	if (!slot) {
+		struct pcistub_args arg = { .dev = NULL, .dcount = 0 };

Neither of the two initializers is really needed - just {} will do.

OK.

Quoted 13 lines

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 11 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+		/*
+		 * Make sure all devices on this bus are owned by the
+		 * PCI backend so that we can safely reset the whole bus.
+		 */
+		pci_walk_bus(dev->bus, pcistub_search_dev, &arg);
+
+		/* All devices under the bus should be part of pcistub! */
+		if (arg.dev) {
+			dev_err(&dev->dev, "%s device on the bus is not owned by pcistub\n",
+				pci_name(arg.dev));

I think "device" is superfluous here, while "the bus" could do with replacing by something actually identifying the bus.

I assume you want "bus" number to be printed in above msg. If yes, will do.

Quoted 9 lines

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +5 -0
+			return -EBUSY;
+		}
+
+		dev_dbg(&dev->dev, "pcistub owns %d devices on the bus\n",
+			arg.dcount);

Same here for "the bus", provided this log message is useful in the first place.

Quoted 3 lines

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 1 line
Documentation/ABI/testing/sysfs-driver-pciback +1 -0
+	}

Aren't you missing an "else" here? Aiui in the "slot" case it may still be multiple devices/functions which are affected.

Good catch.  Our original code was performing same check, both for bus and slot case but somehow I removed it during internal review based on some comment.

I will post revised patch later this week. Thanks.

Cheers
GOVINDA

#11 lore raw

Hi,

Quoted 24 lines · Govinda Tatti

Thanks Jan for your review comments. Please see below for my comments.

Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                 #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                 will allow the guest to read and write to the configuration
                 register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 4 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the
function that matches with sysfs attribute.

Hmm.. I remember some discussion from ages ago related to this.

Back then it was suggested to "emulate" the flr capability (by doing slot or bus reset) for devices which don't have *native* flr available? So is this patch perhaps related to that?

If the PCI device in question has native flr capability, then native flr is used, right ? I guess I should read the full patch..

-- Pasi

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw

Thanks Pasi for your response. Please see below for my comments.

Quoted 27 lines · Pasi Kärkkäinen

Hi,

Quoted 24 lines · Govinda Tatti

Thanks Jan for your review comments. Please see below for my comments.

Quoted 21 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +2 -0
@@ -11,3 +11,15 @@ Description:
                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                  will allow the guest to read and write to the configuration
                  register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 7 lines
Quoted 4 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the
function that matches with sysfs attribute.

Hmm.. I remember some discussion from ages ago related to this.

Back then it was suggested to "emulate" the flr capability (by doing slot or bus reset) for devices which don't have *native* flr available? So is this patch perhaps related to that?

I don't think so but either Konrad or someone can comment on it.

Quoted 2 lines

If the PCI device in question has native flr capability, then native flr is used, right ?

Yes.

Quoted 1 line

I guess I should read the full patch..

Please check it and let us know your comments.

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw
In reply to Pasi Kärkkäinen

Thanks Pasi for your response. Please see below for my comments.

Quoted 27 lines · Pasi Kärkkäinen

Hi,

Quoted 24 lines · Govinda Tatti

Thanks Jan for your review comments. Please see below for my comments.

Quoted 21 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +2 -0
@@ -11,3 +11,15 @@ Description:
                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                  will allow the guest to read and write to the configuration
                  register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 7 lines
Quoted 4 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the
function that matches with sysfs attribute.

Hmm.. I remember some discussion from ages ago related to this.

Back then it was suggested to "emulate" the flr capability (by doing slot or bus reset) for devices which don't have *native* flr available? So is this patch perhaps related to that?

I don't think so but either Konrad or someone can comment on it.

Quoted 2 lines

If the PCI device in question has native flr capability, then native flr is used, right ?

Yes.

Quoted 1 line

I guess I should read the full patch..

Please check it and let us know your comments.

Cheers
GOVINDA

#14 lore raw
In reply to Govinda Tatti
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                  will allow the guest to read and write to the configuration
                  register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead). Furthermore, contrary to what you claim in your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

And btw - I don't consider it too good an idea to post the next version of a patch when discussion of the prior one hasn't really settled yet.

Jan

#15 lore raw

Jan,

Sorry for the late response. Please see below for my comments.

Quoted 23 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 21 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +2 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                   will allow the guest to read and write to the configuration
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 7 lines
Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset". Please let me knowyour preference.

Quoted 5 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

Quoted 3 lines

And btw - I don't consider it too good an idea to post the next version of a patch when discussion of the prior one hasn't really settled yet.

Sure, In future I will not post next version of the patch until we complete agree on all the review comment/fixes.Thanks.

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#16 lore raw
In reply to Jan Beulich

Jan,

Sorry for the late response. Please see below for my comments.

Quoted 23 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 21 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +2 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                   will allow the guest to read and write to the configuration
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected]
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 7 lines
Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset". Please let me knowyour preference.

Quoted 5 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

Quoted 3 lines

And btw - I don't consider it too good an idea to post the next version of a patch when discussion of the prior one hasn't really settled yet.

Sure, In future I will not post next version of the patch until we complete agree on all the review comment/fixes.Thanks.

Cheers
GOVINDA

#17 lore raw
Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 16:08, <[email protected]> wrote:
Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                   will allow the guest to read and write to the configuration
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

Quoted 7 lines
Quoted 4 lines

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset".
Please let me knowyour preference.

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus" doesn't cover the slot variant.

Quoted 11 lines
Quoted 5 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

Jan

#18 lore raw
Quoted 32 lines · Jan Beulich
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 16:08, <[email protected]> wrote:
Quoted 30 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                   will allow the guest to read and write to the configuration
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Quoted 6 lines
Quoted 3 lines

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset".
Please let me knowyour preference.

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus"

Can't do 'reset'.

Quoted 1 line

doesn't cover the slot variant.

'bus_reset' sounds lovely?

Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

Quoted 10 lines
Quoted 3 lines

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#19 lore raw
In reply to Jan Beulich
Quoted 32 lines · Jan Beulich
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 16:08, <[email protected]> wrote:
Quoted 30 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                   will allow the guest to read and write to the configuration
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Quoted 6 lines
Quoted 3 lines

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset".
Please let me knowyour preference.

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus"

Can't do 'reset'.

Quoted 1 line

doesn't cover the slot variant.

'bus_reset' sounds lovely?

Quoted 19 lines
Quoted 6 lines
Quoted 6 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Quoted 6 lines

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

Jan

#20 lore raw
Quoted 36 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 17:29, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 16:08, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 11

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +0 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > 

/sys/bus/pci/drivers/pciback/quirks

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 12

Quoted 1 line
Documentation/ABI/testing/sysfs-driver-pciback +0 -0
                   will allow the guest to read and write to the 

configuration

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset".
Please let me knowyour preference.

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus"

Can't do 'reset'.

Why?

Quoted 3 lines
Quoted 1 line

doesn't cover the slot variant.

'bus_reset' sounds lovely?

Lovely sounding or not, it may end up misleading, and even more so if - like asked for - FLR would be tried first.

Jan

#21 lore raw
Quoted 40 lines · Jan Beulich
Quoted 40 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 17:29, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 16:08, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 11

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +0 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > 

/sys/bus/pci/drivers/pciback/quirks

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 12

Quoted 1 line
Documentation/ABI/testing/sysfs-driver-pciback +0 -0
                   will allow the guest to read and write to the 

configuration

Quoted 26 lines
Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 13 lines
Documentation/ABI/testing/sysfs-driver-pciback +12 -0
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 7 lines
Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset".
Please let me knowyour preference.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus"

Can't do 'reset'.

Why?

B/c I forgot that this attribute is not per device, but on the module sub-directory:

/sys/bus/pci/drivers/pciback/do_flr

It can be indeed called 'reset'.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

doesn't cover the slot variant.

'bus_reset' sounds lovely?

Lovely sounding or not, it may end up misleading, and even more so if - like asked for - FLR would be tried first.

Fair enough. Reset should work then.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#22 lore raw
In reply to Jan Beulich
Quoted 40 lines · Jan Beulich
Quoted 40 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 17:29, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 16:08, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 11

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +0 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > 

/sys/bus/pci/drivers/pciback/quirks

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 12

Quoted 1 line
Documentation/ABI/testing/sysfs-driver-pciback +0 -0
                   will allow the guest to read and write to the 

configuration

Quoted 26 lines
Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 13 lines
Documentation/ABI/testing/sysfs-driver-pciback +12 -0
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 7 lines
Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset".
Please let me knowyour preference.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus"

Can't do 'reset'.

Why?

B/c I forgot that this attribute is not per device, but on the module sub-directory:

/sys/bus/pci/drivers/pciback/do_flr

It can be indeed called 'reset'.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

doesn't cover the slot variant.

'bus_reset' sounds lovely?

Lovely sounding or not, it may end up misleading, and even more so if - like asked for - FLR would be tried first.

Fair enough. Reset should work then.

#23 lore raw

Thanks Konrad for your response. Please see below for my comments.

Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus"

Can't do 'reset'.

Why?

B/c I forgot that this attribute is not per device, but on the module sub-directory:

/sys/bus/pci/drivers/pciback/do_flr

It can be indeed called 'reset'.

Good.  We will rename sysfs attribute from "do_flr" to "reset"

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

doesn't cover the slot variant.

'bus_reset' sounds lovely?

Lovely sounding or not, it may end up misleading, and even more so if - like asked for - FLR would be tried first.

Fair enough. Reset should work then.

So, we will use the following sequence to reset the requested device/function.

- FLR (as first option)
- BUS/SLOT reset (as fall-back option) if FLR is not supported or any issue with FLR

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#24 lore raw
In reply to Konrad Rzeszutek Wilk

Thanks Konrad for your response. Please see below for my comments.

Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus"

Can't do 'reset'.

Why?

B/c I forgot that this attribute is not per device, but on the module sub-directory:

/sys/bus/pci/drivers/pciback/do_flr

It can be indeed called 'reset'.

Good.  We will rename sysfs attribute from "do_flr" to "reset"

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

doesn't cover the slot variant.

'bus_reset' sounds lovely?

Lovely sounding or not, it may end up misleading, and even more so if - like asked for - FLR would be tried first.

Fair enough. Reset should work then.

So, we will use the following sequence to reset the requested device/function.

- FLR (as first option)
- BUS/SLOT reset (as fall-back option) if FLR is not supported or any issue with FLR

Cheers
GOVINDA

#25 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 20:44, <[email protected]> wrote:

So, we will use the following sequence to reset the requested device/function.

- FLR (as first option)
- BUS/SLOT reset (as fall-back option) if FLR is not supported or any issue with FLR

It looks to me as if the slot reset could also fail despite the probe having succeeded. In such a case it might be better to try a bus reset, i.e. the sequence would become
- FLR
- slot reset if FLR failed
- bus reset if slot reset failed

Jan

#26 lore raw
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 20:44, <[email protected]> wrote:

So, we will use the following sequence to reset the requested device/function.

- FLR (as first option)
- BUS/SLOT reset (as fall-back option) if FLR is not supported or any issue with FLR

Quoted 6 lines

It looks to me as if the slot reset could also fail despite the probe having succeeded. In such a case it might be better to try a bus reset, i.e. the sequence would become
- FLR
- slot reset if FLR failed
- bus reset if slot reset failed

Fine with me.

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#27 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 20:44, <[email protected]> wrote:

So, we will use the following sequence to reset the requested device/function.

- FLR (as first option)
- BUS/SLOT reset (as fall-back option) if FLR is not supported or any issue with FLR

Quoted 6 lines

It looks to me as if the slot reset could also fail despite the probe having succeeded. In such a case it might be better to try a bus reset, i.e. the sequence would become
- FLR
- slot reset if FLR failed
- bus reset if slot reset failed

Fine with me.

Cheers
GOVINDA

#28 lore raw
In reply to Govinda Tatti
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 20:44, <[email protected]> wrote:

So, we will use the following sequence to reset the requested device/function.

- FLR (as first option)
- BUS/SLOT reset (as fall-back option) if FLR is not supported or any issue with FLR

It looks to me as if the slot reset could also fail despite the probe having succeeded. In such a case it might be better to try a bus reset, i.e. the sequence would become
- FLR
- slot reset if FLR failed
- bus reset if slot reset failed

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#29 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 36 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 17:29, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 16:08, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 11

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +0 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > 

/sys/bus/pci/drivers/pciback/quirks

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 12

Quoted 1 line
Documentation/ABI/testing/sysfs-driver-pciback +0 -0
                   will allow the guest to read and write to the 

configuration

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset".
Please let me knowyour preference.

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus"

Can't do 'reset'.

Why?

Quoted 3 lines
Quoted 1 line

doesn't cover the slot variant.

'bus_reset' sounds lovely?

Lovely sounding or not, it may end up misleading, and even more so if - like asked for - FLR would be tried first.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#30 lore raw
In reply to Jan Beulich
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Quoted 8 lines
Quoted 6 lines

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

pcistub_reset_dev() just tries slot or bus reset but not FLR since it is being checked and executed by pci_reset_function_locked() if supported. May be we can add FLR reset code to pcistub_reset_dev() and try FLR first before fall-back to slot/bus reset.

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#31 lore raw
In reply to Jan Beulich
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Quoted 8 lines
Quoted 6 lines

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

pcistub_reset_dev() just tries slot or bus reset but not FLR since it is being checked and executed by pci_reset_function_locked() if supported. May be we can add FLR reset code to pcistub_reset_dev() and try FLR first before fall-back to slot/bus reset.

Cheers
GOVINDA

#32 lore raw
Quoted 15 lines · Govinda Tatti
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Quoted 8 lines
Quoted 6 lines

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

Quoted 8 lines

pcistub_reset_dev() just tries slot or bus reset but not FLR since it is being
checked and executed by pci_reset_function_locked() if supported. May be we can
add FLR reset code to pcistub_reset_dev() and try FLR first before fall-back to
slot/bus reset.

Hmm.. is the suitable reset method something that can be figured out automatically?

I mean if FLR is tried first, but it isn't supported by the device, is it OK to go ahead and do a slot/bus reset automatically? What if there are other devices in the same bus, wouldn't automatic bus reset be a bad thing?

Or should the reset-method be configured by the user for the VM / PCI device ?

Just thinking out loud here..

Quoted 3 lines

Cheers
GOVINDA

Thanks,

-- Pasi

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#33 lore raw
Quoted 22 lines · Pasi Kärkkäinen
Quoted 13 lines · Govinda Tatti
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Quoted 8 lines
Quoted 6 lines

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

Quoted 8 lines

pcistub_reset_dev() just tries slot or bus reset but not FLR since it is being
checked and executed by pci_reset_function_locked() if supported. May be we can
add FLR reset code to pcistub_reset_dev() and try FLR first before fall-back to
slot/bus reset.

Quoted 3 lines

Hmm.. is the suitable reset method something that can be figured out automatically?

I mean if FLR is tried first, but it isn't supported by the device, is it OK to go ahead and do a slot/bus reset automatically?

Yes, we are moving in the same direction.

Quoted 1 line

What if there are other devices in the same bus, wouldn't automatic bus reset be a bad thing?

We will perform BUS or SLOT reset only if all device/functions behind the bus/slot are owned by pcistub. Otherwise, we will skipthis reset.

Quoted 4 lines

Or should the reset-method be configured by the user for the VM / PCI device ?

Just thinking out loud here..

Cheers
GOVINDA

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#34 lore raw
In reply to Pasi Kärkkäinen
Quoted 22 lines · Pasi Kärkkäinen
Quoted 13 lines · Govinda Tatti
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Quoted 8 lines
Quoted 6 lines

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

Quoted 8 lines

pcistub_reset_dev() just tries slot or bus reset but not FLR since it is being
checked and executed by pci_reset_function_locked() if supported. May be we can
add FLR reset code to pcistub_reset_dev() and try FLR first before fall-back to
slot/bus reset.

Quoted 3 lines

Hmm.. is the suitable reset method something that can be figured out automatically?

I mean if FLR is tried first, but it isn't supported by the device, is it OK to go ahead and do a slot/bus reset automatically?

Yes, we are moving in the same direction.

Quoted 1 line

What if there are other devices in the same bus, wouldn't automatic bus reset be a bad thing?

We will perform BUS or SLOT reset only if all device/functions behind the bus/slot are owned by pcistub. Otherwise, we will skipthis reset.

Quoted 4 lines

Or should the reset-method be configured by the user for the VM / PCI device ?

Just thinking out loud here..

Cheers
GOVINDA

#35 lore raw
In reply to Govinda Tatti
Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 29.11.17 at 16:08, <[email protected]> wrote:
Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                   #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                   will allow the guest to read and write to the configuration
                   register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

Quoted 7 lines
Quoted 4 lines

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead).

Sure, we can consider renaming "do_flr" attribute to "pci reset" or "bus reset".
Please let me knowyour preference.

Well, that's more a question to Konrad as the maintainer. Personally I'd prefer just "reset", as "pci" is redundant and "bus" doesn't cover the slot variant.

Quoted 11 lines
Quoted 5 lines

Furthermore, contrary to what you claim in
your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

Currently, multiple resets are being invoked (independently) in the context of "xl attach/detach/shutdown/reboot".

- pci_reset_function_locked (invoked by pcistub_put_pci_dev()) This function tries various PCI reset methods including FLR.
- pcistub_reset_dev (called by toolsstack based on "do_flr" attribute)

While related in a certain way, I can't really see how this addresses the comment.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#36 lore raw
In reply to Govinda Tatti
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 08.11.17 at 16:44, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
@@ -11,3 +11,15 @@ Description:
                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                  will allow the guest to read and write to the configuration
                  register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
Quoted 8 lines

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-pciback +6 -0
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 3 lines

Yes, I agree but xen toolstack has already been modified to consume"do_flr" attribute. Hence, we are using the function that matches with sysfs attribute.

That's not a valid reason imo: Right now the driver doesn't expose such an attribute, so if the tool stack was trying to use it, it would not do what is intended at present anyway (i.e. the code could at best be called dead). Furthermore, contrary to what you claim in your reply to Pasi, I can't see where you try an actual FLR first - you go straight to pci_probe_reset_{slot,bus}(). If you actually tried FLR first, only falling back to the other methods as "emulation", I could certainly agree with the file name chosen.

And btw - I don't consider it too good an idea to post the next version of a patch when discussion of the prior one hasn't really settled yet.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#37 lore raw
In reply to Govinda Tatti
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.11.17 at 18:48, <[email protected]> wrote:
Documentation/ABI/testing/sysfs-driver-pciback +2 -0
@@ -11,3 +11,15 @@ Description:
                 #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                 will allow the guest to read and write to the configuration
                 register 0x0E.
+
+What:           /sys/bus/pci/drivers/pciback/do_flr

Documentation/ABI/testing/sysfs-driver-pciback Description: · line 25

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+Date:           Nov 2017
+KernelVersion:  4.15
+Contact:        [email protected] 
+Description:
+                An option to perform a slot or bus reset when a PCI device
+		is owned by Xen PCI backend. Writing a string of DDDD:BB:DD.F
+		will cause the pciback driver to perform a slot or bus reset
+		if the device supports it. It also checks to make sure that
+		all of the devices under the bridge are owned by Xen PCI
+		backend.

Why do you name this "do_flr" when you don't even try FLR, but go to slot or then bus reset right away.

Quoted 13 lines
Documentation/ABI/testing/sysfs-driver-pciback +13 -0
+static int pcistub_reset_dev(struct pci_dev *dev)
+{
+	struct xen_pcibk_dev_data *dev_data;
+	bool slot = false, bus = false;
+
+	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)) {

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+		/* We won't attempt to reset a root bridge. */
+		if (!pci_is_root_bus(dev->bus))
+			bus = true;
+	}
+
+	if (!bus && !slot)
+		return -EOPNOTSUPP;
+
+	if (!slot) {
+		struct pcistub_args arg = { .dev = NULL, .dcount = 0 };

Neither of the two initializers is really needed - just {} will do.

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-pciback +10 -0
+		/*
+		 * Make sure all devices on this bus are owned by the
+		 * PCI backend so that we can safely reset the whole bus.
+		 */
+		pci_walk_bus(dev->bus, pcistub_search_dev, &arg);
+
+		/* All devices under the bus should be part of pcistub! */
+		if (arg.dev) {
+			dev_err(&dev->dev, "%s device on the bus is not owned by pcistub\n",
+				pci_name(arg.dev));

I think "device" is superfluous here, while "the bus" could do with replacing by something actually identifying the bus.

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 5 lines
Documentation/ABI/testing/sysfs-driver-pciback +5 -0
+			return -EBUSY;
+		}
+
+		dev_dbg(&dev->dev, "pcistub owns %d devices on the bus\n",
+			arg.dcount);

Same here for "the bus", provided this log message is useful in the first place.

Documentation/ABI/testing/sysfs-driver-pciback

Quoted 1 line
Documentation/ABI/testing/sysfs-driver-pciback +1 -0
+	}

Aren't you missing an "else" here? Aiui in the "slot" case it may still be multiple devices/functions which are affected.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel