raw/skeleton: allow closing already closed device
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Mon, 21 Sep 2020 21:44:20 +0000 (23:44 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 6 Oct 2020 21:30:36 +0000 (23:30 +0200)
This patch return OK code (0) from skeleton_rawdev_close function
if firmware is in SKELETON_FW_READY state. Formerly it returned
-EINVAL error code.

Returning an error here is troublesome as it disallows proper release
of the rawdev. The rte_rawdev_pmd_release function from librte_rawdev
library calls drivers' rawdev_close handler and continues execution
only in case of errorless call.
(see lib/librte_rawdev/rte_rawdev.c:540)

The SKELETON_FW_READY state is reached after creation, reset, unload
or close of the device. The device should be ok to be released in
such situations.

To reproduce issue fixed by this patch, call rawdev_autotest
from dpdk-test app for few times. As the device is not properly
released, the next calls will fail.

Fixes: 61c592a8d035 ("raw/skeleton: introduce skeleton rawdev driver")
Cc: stable@dpdk.org
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
drivers/raw/skeleton/skeleton_rawdev.c

index f8b47a3..aa3beaa 100644 (file)
@@ -190,9 +190,11 @@ static int skeleton_rawdev_close(struct rte_rawdev *dev)
                }
                break;
        case SKELETON_FW_READY:
+               SKELETON_PMD_DEBUG("Device already in stopped state");
+               break;
        case SKELETON_FW_ERROR:
        default:
-               SKELETON_PMD_DEBUG("Device already in stopped state");
+               SKELETON_PMD_DEBUG("Device in impossible state");
                ret = -EINVAL;
                break;
        }