From: ramesh.thomas at intel.com
To: accel-config@lists.01.org
Subject: [Accel-config] [PATCH 1/5] accel-config: Update for driver deferred mdev registration
Date: Mon, 05 Apr 2021 23:34:07 -0400 [thread overview]
Message-ID: <20210406033411.464362-2-ramesh.thomas@intel.com> (raw)
In-Reply-To: 20210406033411.464362-1-ramesh.thomas@intel.com
[-- Attachment #1: Type: text/plain, Size: 2563 bytes --]
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
Mdev is now registered when the first mdev wq is created. It will be
deregistered when the last mdev wq is removed. Change will check for
presence of /sys/class/mdev_bus at the point of mdev use instead of
initializing context at start.
Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
accfg/lib/libaccfg.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index a8d18ff..24ae65c 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -108,6 +108,11 @@ const char *accfg_device_cmd_status[] = {
[ACCFG_CMD_STATUS_MAX] = "",
};
+static inline bool is_mdev_registered(struct accfg_device *device)
+{
+ return device->mdev_path && !access(device->mdev_path, R_OK);
+}
+
static long accfg_get_param_long(struct accfg_ctx *ctx, int dfd, char *name)
{
int fd = openat(dfd, name, O_RDONLY);
@@ -593,11 +598,7 @@ static void *add_device(void *parent, int id, const char *ctl_base,
goto err_dev_path;
}
free(device->mdev_path);
- if (access(p, R_OK)) {
- free(p);
- device->mdev_path = NULL;
- } else
- device->mdev_path = p;
+ device->mdev_path = p;
device->device_buf = calloc(1, strlen(device->device_path) +
MAX_PARAM_LEN);
@@ -614,7 +615,7 @@ static void *add_device(void *parent, int id, const char *ctl_base,
device->bus_type_str = bus_type;
- if (device->mdev_path && add_device_mdevs(ctx, device))
+ if (is_mdev_registered(device) && add_device_mdevs(ctx, device))
goto err_dev_path;
list_add_tail(&ctx->devices, &device->list);
@@ -1050,7 +1051,7 @@ ACCFG_EXPORT int accfg_create_mdev(struct accfg_device *device,
unsigned int version;
int rc;
- if (!device->mdev_path)
+ if (!is_mdev_registered(device))
return -ENOENT;
if (type >= ACCFG_MDEV_TYPE_UNKNOWN || type < 0)
@@ -1110,7 +1111,7 @@ ACCFG_EXPORT int accfg_remove_mdev(struct accfg_device *device, uuid_t uuid)
struct accfg_device_mdev *entry, *next;
int rc, all;
- if (!device->mdev_path)
+ if (!is_mdev_registered(device))
return -ENOENT;
/* remove all mdevs if null uuid is passed */
@@ -1266,7 +1267,7 @@ ACCFG_EXPORT bool accfg_device_get_pasid_enabled(
ACCFG_EXPORT bool accfg_device_get_mdev_enabled(
struct accfg_device *device)
{
- return device->mdev_path != NULL;
+ return is_mdev_registered(device);
}
ACCFG_EXPORT int accfg_device_get_errors(struct accfg_device *device,
--
2.26.3
reply other threads:[~2021-04-06 3:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210406033411.464362-2-ramesh.thomas@intel.com \
--to=accel-config@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.