[dpdk-dev] [PATCH v2] igb_uio: allow multi-process access
Tiwei Bie
tiwei.bie at intel.com
Tue Dec 19 10:04:34 CET 2017
Hi,
On Tue, Dec 19, 2017 at 07:42:20AM -0800, Xiao Wang wrote:
> @@ -336,6 +337,10 @@ struct rte_uio_pci_dev {
> struct pci_dev *dev = udev->pdev;
> int err;
>
> + atomic_inc(&udev->refcnt);
> + if (atomic_read(&udev->refcnt) > 1)
The "inc and read" should be atomic. Otherwise below
sequence may happen:
P1: atomic_inc(&udev->refcnt);
P2: atomic_inc(&udev->refcnt);
P1: if (atomic_read(&udev->refcnt) > 1)
P2: if (atomic_read(&udev->refcnt) > 1)
> + return 0;
> +
> /* set bus master, which was cleared by the reset function */
> pci_set_master(dev);
>
> @@ -354,6 +359,10 @@ struct rte_uio_pci_dev {
> struct rte_uio_pci_dev *udev = info->priv;
> struct pci_dev *dev = udev->pdev;
>
> + atomic_dec(&udev->refcnt);
> + if (atomic_read(&udev->refcnt) > 0)
> + return 0;
Ditto.
Best regards,
Tiwei Bie
> +
> /* disable interrupts */
> igbuio_pci_disable_interrupts(udev);
>
> --
> 1.8.3.1
>
More information about the dev
mailing list