[v2] ethdev: fix dev close in secondary process

Message ID 20220601013057.31782-1-humin29@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series [v2] ethdev: fix dev close in secondary process |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-x86_64-unit-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

humin (Q) June 1, 2022, 1:30 a.m. UTC
  From: Min Hu <humin29@huawei.com>

Secondary process need to close dev to release process private resources.
But secondary process should not be obliged to wait for device stop before
closing ethdev.

This patch fixed it.

Fixes: febc855b358e ("ethdev: forbid closing started device")
Cc: stable@dpdk.org

Signed-off-by: Min Hu <humin29@huawei.com>
---
v2:
* fixed comment.
---
 lib/ethdev/rte_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Ajit Khaparde June 1, 2022, 2:01 a.m. UTC | #1
On Tue, May 31, 2022 at 6:32 PM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> From: Min Hu <humin29@huawei.com>
>
> Secondary process need to close dev to release process private resources.
> But secondary process should not be obliged to wait for device stop before
> closing ethdev.
>
> This patch fixed it.
>
> Fixes: febc855b358e ("ethdev: forbid closing started device")
> Cc: stable@dpdk.org
>
> Signed-off-by: Min Hu <humin29@huawei.com>
> ---
> v2:
> * fixed comment.
> ---
>  lib/ethdev/rte_ethdev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index 09abee6345..f34c6580a4 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -1574,7 +1574,8 @@ rte_eth_dev_close(uint16_t port_id)
>         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>         dev = &rte_eth_devices[port_id];
>
> -       if (dev->data->dev_started) {
It will be good to add the comment as a part of the code as well.
That way someone in future won't have to look at the commit log to
understand the behavior.

> +       if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
> +                       dev->data->dev_started) {
>                 RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n",
>                                port_id);
>                 return -EINVAL;
> --
> 2.33.0
>
  
humin (Q) June 1, 2022, 3:18 a.m. UTC | #2
Hi, Ajit
v3 has been sent, thanks

在 2022/6/1 10:01, Ajit Khaparde 写道:
> On Tue, May 31, 2022 at 6:32 PM Min Hu (Connor) <humin29@huawei.com> wrote:
>>
>> From: Min Hu <humin29@huawei.com>
>>
>> Secondary process need to close dev to release process private resources.
>> But secondary process should not be obliged to wait for device stop before
>> closing ethdev.
>>
>> This patch fixed it.
>>
>> Fixes: febc855b358e ("ethdev: forbid closing started device")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Min Hu <humin29@huawei.com>
>> ---
>> v2:
>> * fixed comment.
>> ---
>>   lib/ethdev/rte_ethdev.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>> index 09abee6345..f34c6580a4 100644
>> --- a/lib/ethdev/rte_ethdev.c
>> +++ b/lib/ethdev/rte_ethdev.c
>> @@ -1574,7 +1574,8 @@ rte_eth_dev_close(uint16_t port_id)
>>          RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>>          dev = &rte_eth_devices[port_id];
>>
>> -       if (dev->data->dev_started) {
> It will be good to add the comment as a part of the code as well.
> That way someone in future won't have to look at the commit log to
> understand the behavior.
> 
>> +       if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
>> +                       dev->data->dev_started) {
>>                  RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n",
>>                                 port_id);
>>                  return -EINVAL;
>> --
>> 2.33.0
>>
  
Ajit Khaparde June 1, 2022, 1:45 p.m. UTC | #3
On Tue, May 31, 2022 at 8:18 PM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> Hi, Ajit
> v3 has been sent, thanks
Thanks
  

Patch

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 09abee6345..f34c6580a4 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1574,7 +1574,8 @@  rte_eth_dev_close(uint16_t port_id)
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	if (dev->data->dev_started) {
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
+			dev->data->dev_started) {
 		RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n",
 			       port_id);
 		return -EINVAL;