patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
@ 2020-05-19  3:42 wangyunjian
  2020-09-17 12:43 ` wangyunjian
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: wangyunjian @ 2020-05-19  3:42 UTC (permalink / raw)
  To: dev
  Cc: anatoly.burakov, hemant.agrawal, sachin.saxena, jerry.lilijun,
	xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

The issue is that a file descriptor at 0 is a valid one. Currently
the file not found, the return value will be set to 0. As a result,
it is impossible to distinguish between a correct descriptor and a
failed return value. Fix it to return -ENOENT instead of 0.

Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 970969d2b..04ccf4af6 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -448,11 +448,14 @@ fslmc_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 
 	/* get the actual group fd */
 	vfio_group_fd = rte_vfio_get_group_fd(iommu_group_no);
-	if (vfio_group_fd < 0)
+	if (vfio_group_fd < 0 && vfio_group_fd != -ENOENT)
 		return -1;
 
-	/* if group_fd == 0, that means the device isn't managed by VFIO */
-	if (vfio_group_fd == 0) {
+	/*
+	 * if vfio_group_fd == -ENOENT, that means the device
+	 * isn't managed by VFIO
+	 */
+	if (vfio_group_fd == -ENOENT) {
 		RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver, skipping\n",
 				dev_addr);
 		return 1;
-- 
2.23.0



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

* Re: [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
  2020-05-19  3:42 [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd wangyunjian
@ 2020-09-17 12:43 ` wangyunjian
  2020-09-17 12:56 ` Burakov, Anatoly
  2020-09-17 15:38 ` Hemant Agrawal
  2 siblings, 0 replies; 6+ messages in thread
From: wangyunjian @ 2020-09-17 12:43 UTC (permalink / raw)
  To: dev
  Cc: hemant.agrawal, sachin.saxena, anatoly.burakov, Lilijun (Jerry),
	xudingke, stable

Friendly ping

> -----Original Message-----
> From: wangyunjian
> Sent: Tuesday, May 19, 2020 11:42 AM
> To: dev@dpdk.org
> Cc: anatoly.burakov@intel.com; hemant.agrawal@nxp.com;
> sachin.saxena@nxp.com; Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
> <xudingke@huawei.com>; wangyunjian <wangyunjian@huawei.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
> 
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> The issue is that a file descriptor at 0 is a valid one. Currently the file not found,
> the return value will be set to 0. As a result, it is impossible to distinguish
> between a correct descriptor and a failed return value. Fix it to return -ENOENT
> instead of 0.
> 
> Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  drivers/bus/fslmc/fslmc_vfio.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index
> 970969d2b..04ccf4af6 100644
> --- a/drivers/bus/fslmc/fslmc_vfio.c
> +++ b/drivers/bus/fslmc/fslmc_vfio.c
> @@ -448,11 +448,14 @@ fslmc_vfio_setup_device(const char *sysfs_base,
> const char *dev_addr,
> 
>  	/* get the actual group fd */
>  	vfio_group_fd = rte_vfio_get_group_fd(iommu_group_no);
> -	if (vfio_group_fd < 0)
> +	if (vfio_group_fd < 0 && vfio_group_fd != -ENOENT)
>  		return -1;
> 
> -	/* if group_fd == 0, that means the device isn't managed by VFIO */
> -	if (vfio_group_fd == 0) {
> +	/*
> +	 * if vfio_group_fd == -ENOENT, that means the device
> +	 * isn't managed by VFIO
> +	 */
> +	if (vfio_group_fd == -ENOENT) {
>  		RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver,
> skipping\n",
>  				dev_addr);
>  		return 1;
> --
> 2.23.0
> 


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
  2020-05-19  3:42 [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd wangyunjian
  2020-09-17 12:43 ` wangyunjian
@ 2020-09-17 12:56 ` Burakov, Anatoly
  2020-09-17 13:34   ` wangyunjian
  2020-09-17 15:38 ` Hemant Agrawal
  2 siblings, 1 reply; 6+ messages in thread
From: Burakov, Anatoly @ 2020-09-17 12:56 UTC (permalink / raw)
  To: wangyunjian, dev
  Cc: hemant.agrawal, sachin.saxena, jerry.lilijun, xudingke, stable

On 19-May-20 4:42 AM, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> The issue is that a file descriptor at 0 is a valid one. Currently
> the file not found, the return value will be set to 0. As a result,
> it is impossible to distinguish between a correct descriptor and a
> failed return value. Fix it to return -ENOENT instead of 0.
> 
> Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---

I am unfamiliar with bus/fslmc code but i've taken a quick look, and 
i've noticed that there's another instance of get_group_fd() usage that 
you're not modifying - is that intentional?

-- 
Thanks,
Anatoly

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
  2020-09-17 12:56 ` Burakov, Anatoly
@ 2020-09-17 13:34   ` wangyunjian
  2020-09-17 14:41     ` Burakov, Anatoly
  0 siblings, 1 reply; 6+ messages in thread
From: wangyunjian @ 2020-09-17 13:34 UTC (permalink / raw)
  To: Burakov, Anatoly, dev
  Cc: hemant.agrawal, sachin.saxena, Lilijun (Jerry), xudingke, stable

> -----Original Message-----
> From: Burakov, Anatoly [mailto:anatoly.burakov@intel.com]
> Sent: Thursday, September 17, 2020 8:56 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: hemant.agrawal@nxp.com; sachin.saxena@nxp.com; Lilijun (Jerry)
> <jerry.lilijun@huawei.com>; xudingke <xudingke@huawei.com>;
> stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
> 
> On 19-May-20 4:42 AM, wangyunjian wrote:
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > The issue is that a file descriptor at 0 is a valid one. Currently the
> > file not found, the return value will be set to 0. As a result, it is
> > impossible to distinguish between a correct descriptor and a failed
> > return value. Fix it to return -ENOENT instead of 0.
> >
> > Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> 
> I am unfamiliar with bus/fslmc code but i've taken a quick look, and i've noticed
> that there's another instance of get_group_fd() usage that you're not
> modifying - is that intentional?

Thank you for your review. The another instance of get_group_fd(), is this it?
int
fslmc_vfio_setup_group(void) {
    ...
	/* Get the actual group fd */
	ret = rte_vfio_get_group_fd(groupid);
	if (ret < 0)
		return ret;
	vfio_group.fd = ret;
    ...
}
I don't think this's necessary. Because it must be a valid descriptor before it can be used.

Yunjian

> 
> --
> Thanks,
> Anatoly

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
  2020-09-17 13:34   ` wangyunjian
@ 2020-09-17 14:41     ` Burakov, Anatoly
  0 siblings, 0 replies; 6+ messages in thread
From: Burakov, Anatoly @ 2020-09-17 14:41 UTC (permalink / raw)
  To: wangyunjian, dev
  Cc: hemant.agrawal, sachin.saxena, Lilijun (Jerry), xudingke, stable

On 17-Sep-20 2:34 PM, wangyunjian wrote:
>> -----Original Message-----
>> From: Burakov, Anatoly [mailto:anatoly.burakov@intel.com]
>> Sent: Thursday, September 17, 2020 8:56 PM
>> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
>> Cc: hemant.agrawal@nxp.com; sachin.saxena@nxp.com; Lilijun (Jerry)
>> <jerry.lilijun@huawei.com>; xudingke <xudingke@huawei.com>;
>> stable@dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
>>
>> On 19-May-20 4:42 AM, wangyunjian wrote:
>>> From: Yunjian Wang <wangyunjian@huawei.com>
>>>
>>> The issue is that a file descriptor at 0 is a valid one. Currently the
>>> file not found, the return value will be set to 0. As a result, it is
>>> impossible to distinguish between a correct descriptor and a failed
>>> return value. Fix it to return -ENOENT instead of 0.
>>>
>>> Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>>> ---
>>
>> I am unfamiliar with bus/fslmc code but i've taken a quick look, and i've noticed
>> that there's another instance of get_group_fd() usage that you're not
>> modifying - is that intentional?
> 
> Thank you for your review. The another instance of get_group_fd(), is this it?
> int
> fslmc_vfio_setup_group(void) {
>      ...
> 	/* Get the actual group fd */
> 	ret = rte_vfio_get_group_fd(groupid);
> 	if (ret < 0)
> 		return ret;
> 	vfio_group.fd = ret;
>      ...
> }
> I don't think this's necessary. Because it must be a valid descriptor before it can be used.
> 
> Yunjian
> 
>>
>> --
>> Thanks,
>> Anatoly

OK. I'll leave this for fslmc bus maintainers to review, but the patch 
looks fine to me.

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd
  2020-05-19  3:42 [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd wangyunjian
  2020-09-17 12:43 ` wangyunjian
  2020-09-17 12:56 ` Burakov, Anatoly
@ 2020-09-17 15:38 ` Hemant Agrawal
  2 siblings, 0 replies; 6+ messages in thread
From: Hemant Agrawal @ 2020-09-17 15:38 UTC (permalink / raw)
  To: wangyunjian, dev
  Cc: anatoly.burakov, hemant.agrawal, sachin.saxena, jerry.lilijun,
	xudingke, stable

Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>



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

end of thread, other threads:[~2020-09-17 15:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19  3:42 [dpdk-stable] [dpdk-dev] [PATCH 2/2] bus/fslmc: fix check for vfio_group_fd wangyunjian
2020-09-17 12:43 ` wangyunjian
2020-09-17 12:56 ` Burakov, Anatoly
2020-09-17 13:34   ` wangyunjian
2020-09-17 14:41     ` Burakov, Anatoly
2020-09-17 15:38 ` Hemant Agrawal

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).