DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] bus/pci: don't open uio device in secondary process
@ 2024-08-28 10:40 Konrad Sztyber
  2024-08-29  5:53 ` Chaoyong He
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Konrad Sztyber @ 2024-08-28 10:40 UTC (permalink / raw)
  To: dev
  Cc: Konrad Sztyber, Chenbo Xia, Nipun Gupta, Peng Zhang, Long Wu,
	Zerun Fu, Chaoyong He

The uio_pci_generic driver clears the bus master bit when the device
file is closed.  So, when the secondary process terminates after probing
a device, that device becomes unusable in the primary process.

To avoid that, the device file is now opened only in the primary
process.  The commit that introduced this regression, 847d78fb95
("bus/pci: fix FD in secondary process"), only mentioned enabling access
to config space from secondary process, which still works, as it doesn't
rely on the device file.

Fixes: 847d78fb95 ("bus/pci: fix FD in secondary process")

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
---
 drivers/bus/pci/linux/pci_uio.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index 4c1d3327a9..432316afcc 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -232,18 +232,6 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
 			loc->domain, loc->bus, loc->devid, loc->function);
 		return 1;
 	}
-	snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
-
-	/* save fd */
-	fd = open(devname, O_RDWR);
-	if (fd < 0) {
-		PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
-		goto error;
-	}
-
-	if (rte_intr_fd_set(dev->intr_handle, fd))
-		goto error;
-
 	snprintf(cfgname, sizeof(cfgname),
 			"/sys/class/uio/uio%u/device/config", uio_num);
 
@@ -273,6 +261,19 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	/* the uio_pci_generic driver clears the bus master enable bit when the device file is
+	 * closed, so open it only in the primary process */
+	snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
+	/* save fd */
+	fd = open(devname, O_RDWR);
+	if (fd < 0) {
+		PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
+		goto error;
+	}
+
+	if (rte_intr_fd_set(dev->intr_handle, fd))
+		goto error;
+
 	/* allocate the mapping details for secondary processes*/
 	*uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0);
 	if (*uio_res == NULL) {
-- 
2.45.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] bus/pci: don't open uio device in secondary process
  2024-08-28 10:40 [PATCH] bus/pci: don't open uio device in secondary process Konrad Sztyber
@ 2024-08-29  5:53 ` Chaoyong He
  2024-08-29  8:06 ` Chenbo Xia
  2024-08-29  8:57 ` [PATCH v2] " Konrad Sztyber
  2 siblings, 0 replies; 5+ messages in thread
From: Chaoyong He @ 2024-08-29  5:53 UTC (permalink / raw)
  To: Konrad Sztyber, dev; +Cc: Chenbo Xia, Nipun Gupta, Long Wu, Zerun Fu

> 
> The uio_pci_generic driver clears the bus master bit when the device file is
> closed.  So, when the secondary process terminates after probing a device,
> that device becomes unusable in the primary process.
> 
> To avoid that, the device file is now opened only in the primary process.  The
> commit that introduced this regression, 847d78fb95
> ("bus/pci: fix FD in secondary process"), only mentioned enabling access to
> config space from secondary process, which still works, as it doesn't rely on
> the device file.

Yes, we can still access the config space from secondary process.

> 
> Fixes: 847d78fb95 ("bus/pci: fix FD in secondary process")

Maybe here also need a 'Cc: stable@dpdk.org' ?

With this, It looks good to me, thanks.
Acked-by: Chaoyong He <chaoyong.he@corigine.com>

> 
> Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
> ---
>  drivers/bus/pci/linux/pci_uio.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
> index 4c1d3327a9..432316afcc 100644
> --- a/drivers/bus/pci/linux/pci_uio.c
> +++ b/drivers/bus/pci/linux/pci_uio.c
> @@ -232,18 +232,6 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
>                         loc->domain, loc->bus, loc->devid, loc->function);
>                 return 1;
>         }
> -       snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
> -
> -       /* save fd */
> -       fd = open(devname, O_RDWR);
> -       if (fd < 0) {
> -               PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
> -               goto error;
> -       }
> -
> -       if (rte_intr_fd_set(dev->intr_handle, fd))
> -               goto error;
> -
>         snprintf(cfgname, sizeof(cfgname),
>                         "/sys/class/uio/uio%u/device/config", uio_num);
> 
> @@ -273,6 +261,19 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
>         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
>                 return 0;
> 
> +       /* the uio_pci_generic driver clears the bus master enable bit when the
> device file is
> +        * closed, so open it only in the primary process */
> +       snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
> +       /* save fd */
> +       fd = open(devname, O_RDWR);
> +       if (fd < 0) {
> +               PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
> +               goto error;
> +       }
> +
> +       if (rte_intr_fd_set(dev->intr_handle, fd))
> +               goto error;
> +
>         /* allocate the mapping details for secondary processes*/
>         *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0);
>         if (*uio_res == NULL) {
> --
> 2.45.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] bus/pci: don't open uio device in secondary process
  2024-08-28 10:40 [PATCH] bus/pci: don't open uio device in secondary process Konrad Sztyber
  2024-08-29  5:53 ` Chaoyong He
@ 2024-08-29  8:06 ` Chenbo Xia
  2024-08-29  8:57 ` [PATCH v2] " Konrad Sztyber
  2 siblings, 0 replies; 5+ messages in thread
From: Chenbo Xia @ 2024-08-29  8:06 UTC (permalink / raw)
  To: Konrad Sztyber
  Cc: dev, Nipun Gupta, Peng Zhang, Long Wu, Zerun Fu, Chaoyong He



> On Aug 28, 2024, at 18:40, Konrad Sztyber <konrad.sztyber@intel.com> wrote:
> 
> External email: Use caution opening links or attachments
> 
> 
> The uio_pci_generic driver clears the bus master bit when the device
> file is closed.  So, when the secondary process terminates after probing

Should be one space before ‘So'

> a device, that device becomes unusable in the primary process.
> 
> To avoid that, the device file is now opened only in the primary
> process.  The commit that introduced this regression, 847d78fb95
> ("bus/pci: fix FD in secondary process"), only mentioned enabling access
> to config space from secondary process, which still works, as it doesn't
> rely on the device file.
> 
> Fixes: 847d78fb95 ("bus/pci: fix FD in secondary process")

Besides the cc stable tag mentioned by Chaoyong, commit ID should be 12-digit.

Please also fix the coding style:

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#176: FILE: drivers/bus/pci/linux/pci_uio.c:265:
+ * closed, so open it only in the primary process */

With above fixed:

Reviewed-by: Chenbo Xia <chenbox@nvidia.com>

> 
> Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
> ---
> drivers/bus/pci/linux/pci_uio.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
> index 4c1d3327a9..432316afcc 100644
> --- a/drivers/bus/pci/linux/pci_uio.c
> +++ b/drivers/bus/pci/linux/pci_uio.c
> @@ -232,18 +232,6 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
>                        loc->domain, loc->bus, loc->devid, loc->function);
>                return 1;
>        }
> -       snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
> -
> -       /* save fd */
> -       fd = open(devname, O_RDWR);
> -       if (fd < 0) {
> -               PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
> -               goto error;
> -       }
> -
> -       if (rte_intr_fd_set(dev->intr_handle, fd))
> -               goto error;
> -
>        snprintf(cfgname, sizeof(cfgname),
>                        "/sys/class/uio/uio%u/device/config", uio_num);
> 
> @@ -273,6 +261,19 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
>        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
>                return 0;
> 
> +       /* the uio_pci_generic driver clears the bus master enable bit when the device file is
> +        * closed, so open it only in the primary process */
> +       snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
> +       /* save fd */
> +       fd = open(devname, O_RDWR);
> +       if (fd < 0) {
> +               PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
> +               goto error;
> +       }
> +
> +       if (rte_intr_fd_set(dev->intr_handle, fd))
> +               goto error;
> +
>        /* allocate the mapping details for secondary processes*/
>        *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0);
>        if (*uio_res == NULL) {
> --
> 2.45.0
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] bus/pci: don't open uio device in secondary process
  2024-08-28 10:40 [PATCH] bus/pci: don't open uio device in secondary process Konrad Sztyber
  2024-08-29  5:53 ` Chaoyong He
  2024-08-29  8:06 ` Chenbo Xia
@ 2024-08-29  8:57 ` Konrad Sztyber
  2024-08-30  3:48   ` Chenbo Xia
  2 siblings, 1 reply; 5+ messages in thread
From: Konrad Sztyber @ 2024-08-29  8:57 UTC (permalink / raw)
  To: dev
  Cc: chaoyong.he, Konrad Sztyber, stable, Chenbo Xia, Nipun Gupta,
	Zerun Fu, Anatoly Burakov, Peng Zhang, Long Wu

The uio_pci_generic driver clears the bus master bit when the device
file is closed. So, when the secondary process terminates after probing
a device, that device becomes unusable in the primary process.

To avoid that, the device file is now opened only in the primary
process. The commit that introduced this regression, 847d78fb9530
("bus/pci: fix FD in secondary process"), only mentioned enabling access
to config space from secondary process, which still works, as it doesn't
rely on the device file.

Fixes: 847d78fb9530 ("bus/pci: fix FD in secondary process")
Cc: stable@dpdk.org

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
---
 drivers/bus/pci/linux/pci_uio.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index 4c1d3327a9..5c4ba8098c 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -232,18 +232,6 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
 			loc->domain, loc->bus, loc->devid, loc->function);
 		return 1;
 	}
-	snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
-
-	/* save fd */
-	fd = open(devname, O_RDWR);
-	if (fd < 0) {
-		PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
-		goto error;
-	}
-
-	if (rte_intr_fd_set(dev->intr_handle, fd))
-		goto error;
-
 	snprintf(cfgname, sizeof(cfgname),
 			"/sys/class/uio/uio%u/device/config", uio_num);
 
@@ -273,6 +261,21 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	/*
+	 * the uio_pci_generic driver clears the bus master enable bit when the device file is
+	 * closed, so open it only in the primary process
+	 */
+	snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
+	/* save fd */
+	fd = open(devname, O_RDWR);
+	if (fd < 0) {
+		PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
+		goto error;
+	}
+
+	if (rte_intr_fd_set(dev->intr_handle, fd))
+		goto error;
+
 	/* allocate the mapping details for secondary processes*/
 	*uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0);
 	if (*uio_res == NULL) {
-- 
2.45.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] bus/pci: don't open uio device in secondary process
  2024-08-29  8:57 ` [PATCH v2] " Konrad Sztyber
@ 2024-08-30  3:48   ` Chenbo Xia
  0 siblings, 0 replies; 5+ messages in thread
From: Chenbo Xia @ 2024-08-30  3:48 UTC (permalink / raw)
  To: Konrad Sztyber
  Cc: dev, Chaoyong He, stable, Nipun Gupta, Zerun Fu, Anatoly Burakov,
	Peng Zhang, Long Wu


> On Aug 29, 2024, at 16:57, Konrad Sztyber <konrad.sztyber@intel.com> wrote:
> 
> External email: Use caution opening links or attachments
> 
> 
> The uio_pci_generic driver clears the bus master bit when the device
> file is closed. So, when the secondary process terminates after probing
> a device, that device becomes unusable in the primary process.
> 
> To avoid that, the device file is now opened only in the primary
> process. The commit that introduced this regression, 847d78fb9530
> ("bus/pci: fix FD in secondary process"), only mentioned enabling access
> to config space from secondary process, which still works, as it doesn't
> rely on the device file.
> 
> Fixes: 847d78fb9530 ("bus/pci: fix FD in secondary process")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
> ---
> drivers/bus/pci/linux/pci_uio.c | 27 +++++++++++++++------------
> 1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
> index 4c1d3327a9..5c4ba8098c 100644
> --- a/drivers/bus/pci/linux/pci_uio.c
> +++ b/drivers/bus/pci/linux/pci_uio.c
> @@ -232,18 +232,6 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
>                       loc->domain, loc->bus, loc->devid, loc->function);
>               return 1;
>       }
> -       snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
> -
> -       /* save fd */
> -       fd = open(devname, O_RDWR);
> -       if (fd < 0) {
> -               PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
> -               goto error;
> -       }
> -
> -       if (rte_intr_fd_set(dev->intr_handle, fd))
> -               goto error;
> -
>       snprintf(cfgname, sizeof(cfgname),
>                       "/sys/class/uio/uio%u/device/config", uio_num);
> 
> @@ -273,6 +261,21 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
>       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
>               return 0;
> 
> +       /*
> +        * the uio_pci_generic driver clears the bus master enable bit when the device file is
> +        * closed, so open it only in the primary process
> +        */
> +       snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
> +       /* save fd */
> +       fd = open(devname, O_RDWR);
> +       if (fd < 0) {
> +               PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno));
> +               goto error;
> +       }
> +
> +       if (rte_intr_fd_set(dev->intr_handle, fd))
> +               goto error;
> +
>       /* allocate the mapping details for secondary processes*/
>       *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0);
>       if (*uio_res == NULL) {
> --
> 2.45.0
> 

Reviewed-by: Chenbo Xia <chenbox@nvidia.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-30  3:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-28 10:40 [PATCH] bus/pci: don't open uio device in secondary process Konrad Sztyber
2024-08-29  5:53 ` Chaoyong He
2024-08-29  8:06 ` Chenbo Xia
2024-08-29  8:57 ` [PATCH v2] " Konrad Sztyber
2024-08-30  3:48   ` Chenbo Xia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).