From: Tom Zanussi <tom.zanussi@linux.intel.com>
To: Fenghua Yu <fenghua.yu@intel.com>,
herbert@gondor.apana.org.au, davem@davemloft.net,
vkoul@kernel.org
Cc: dave.jiang@intel.com, tony.luck@intel.com,
wajdi.k.feghali@intel.com, james.guilford@intel.com,
kanchana.p.sridhar@intel.com, vinodh.gopal@intel.com,
giovanni.cabiddu@intel.com, linux-kernel@vger.kernel.org,
linux-crypto@vger.kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH v7 01/14] dmaengine: idxd: add wq driver name support for accel-config user tool
Date: Tue, 11 Jul 2023 13:57:28 -0500 [thread overview]
Message-ID: <fd472a246013a6b30884f6d279c232b47c9de8db.camel@linux.intel.com> (raw)
In-Reply-To: <8e51fc0d-1c5c-e1d2-b8fb-e7c6c247c74c@intel.com>
Hi Fenghua,
On Tue, 2023-07-11 at 10:49 -0700, Fenghua Yu wrote:
> Hi, Tom,
>
> On 7/10/23 12:06, Tom Zanussi wrote:
> > From: Dave Jiang <dave.jiang@intel.com>
> >
> > With the possibility of multiple wq drivers that can be bound to the wq,
> > the user config tool accel-config needs a way to know which wq driver to
> > bind to the wq. Introduce per wq driver_name sysfs attribute where the user
> > can indicate the driver to be bound to the wq. This allows accel-config to
> > just bind to the driver using wq->driver_name.
> >
> > Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> > Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> > ---
> > .../ABI/stable/sysfs-driver-dma-idxd | 6 ++++
> > drivers/dma/idxd/cdev.c | 7 +++++
> > drivers/dma/idxd/dma.c | 6 ++++
> > drivers/dma/idxd/idxd.h | 9 ++++++
> > drivers/dma/idxd/sysfs.c | 28 +++++++++++++++++++
> > include/uapi/linux/idxd.h | 1 +
> > 6 files changed, 57 insertions(+)
> >
> > diff --git a/Documentation/ABI/stable/sysfs-driver-dma-idxd b/Documentation/ABI/stable/sysfs-driver-dma-idxd
> > index 534b7a3d59fc..0e577209bee2 100644
> > --- a/Documentation/ABI/stable/sysfs-driver-dma-idxd
> > +++ b/Documentation/ABI/stable/sysfs-driver-dma-idxd
> > @@ -270,6 +270,12 @@ Description: Shows the operation capability bits displayed in bitmap format
> > correlates to the operations allowed. It's visible only
> > on platforms that support the capability.
> >
> > +What: /sys/bus/dsa/devices/wq<m>.<n>/driver_name
> > +Date: Mar 27, 2023
> > +KernelVersion: 6.6.0
> > +Contact: dmaengine@vger.kernel.org
> > +Description: Name of driver to be bounded to the wq.
> > +
> > What: /sys/bus/dsa/devices/engine<m>.<n>/group_id
> > Date: Oct 25, 2019
> > KernelVersion: 5.6.0
> > diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
> > index ecbf67c2ad2b..b1ecfb71d95e 100644
> > --- a/drivers/dma/idxd/cdev.c
> > +++ b/drivers/dma/idxd/cdev.c
> > @@ -510,6 +510,7 @@ void idxd_wq_del_cdev(struct idxd_wq *wq)
> >
> > static int idxd_user_drv_probe(struct idxd_dev *idxd_dev)
> > {
> > + struct device *dev = &idxd_dev->conf_dev;
> > struct idxd_wq *wq = idxd_dev_to_wq(idxd_dev);
> > struct idxd_device *idxd = wq->idxd;
> > int rc;
> > @@ -537,6 +538,12 @@ static int idxd_user_drv_probe(struct idxd_dev *idxd_dev)
> >
> > mutex_lock(&wq->wq_lock);
> >
> > + if (!idxd_wq_driver_name_match(wq, dev)) {
> > + idxd->cmd_status = IDXD_SCMD_WQ_NO_DRV_NAME;
> > + rc = -ENODEV;
> > + goto wq_err;
> > + }
> > +
> > wq->wq = create_workqueue(dev_name(wq_confdev(wq)));
> > if (!wq->wq) {
> > rc = -ENOMEM;
> > diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c
> > index eb35ca313684..8bb7e7ff8d6a 100644
> > --- a/drivers/dma/idxd/dma.c
> > +++ b/drivers/dma/idxd/dma.c
> > @@ -305,6 +305,12 @@ static int idxd_dmaengine_drv_probe(struct idxd_dev *idxd_dev)
> > return -ENXIO;
> >
> > mutex_lock(&wq->wq_lock);
> > + if (!idxd_wq_driver_name_match(wq, dev)) {
> > + idxd->cmd_status = IDXD_SCMD_WQ_NO_DRV_NAME;
> > + rc = -ENODEV;
> > + goto err;
> > + }
> > +
> > wq->type = IDXD_WQT_KERNEL;
> >
> > rc = drv_enable_wq(wq);
> > diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
> > index 5428a2e1b1ec..c62c78e1c9fa 100644
> > --- a/drivers/dma/idxd/idxd.h
> > +++ b/drivers/dma/idxd/idxd.h
> > @@ -159,6 +159,8 @@ struct idxd_cdev {
> > int minor;
> > };
> >
> > +#define DRIVER_NAME_SIZE 128
> > +
> > #define IDXD_ALLOCATED_BATCH_SIZE 128U
> > #define WQ_NAME_SIZE 1024
> > #define WQ_TYPE_SIZE 10
> > @@ -227,6 +229,8 @@ struct idxd_wq {
> > /* Lock to protect upasid_xa access. */
> > struct mutex uc_lock;
> > struct xarray upasid_xa;
> > +
> > + char driver_name[DRIVER_NAME_SIZE + 1];
> > };
> >
> > struct idxd_engine {
> > @@ -637,6 +641,11 @@ static inline void idxd_wqcfg_set_max_batch_shift(int idxd_type, union wqcfg *wq
> > wqcfg->max_batch_shift = max_batch_shift;
> > }
> >
> > +static inline int idxd_wq_driver_name_match(struct idxd_wq *wq, struct device *dev)
> > +{
> > + return (strncmp(wq->driver_name, dev->driver->name, strlen(dev->driver->name)) == 0);
> > +}
> > +
> > int __must_check __idxd_driver_register(struct idxd_device_driver *idxd_drv,
> > struct module *module, const char *mod_name);
> > #define idxd_driver_register(driver) \
> > diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
> > index 293739ac5596..6caad044f506 100644
> > --- a/drivers/dma/idxd/sysfs.c
> > +++ b/drivers/dma/idxd/sysfs.c
> > @@ -1266,6 +1266,33 @@ static ssize_t wq_op_config_store(struct device *dev, struct device_attribute *a
> > static struct device_attribute dev_attr_wq_op_config =
> > __ATTR(op_config, 0644, wq_op_config_show, wq_op_config_store);
> >
> > +static ssize_t wq_driver_name_show(struct device *dev, struct device_attribute *attr, char *buf)
> > +{
> > + struct idxd_wq *wq = confdev_to_wq(dev);
> > +
> > + return sysfs_emit(buf, "%s\n", wq->driver_name);
> > +}
> > +
> > +static ssize_t wq_driver_name_store(struct device *dev, struct device_attribute *attr,
> > + const char *buf, size_t count)
> > +{
> > + struct idxd_wq *wq = confdev_to_wq(dev);
> > +
> > + if (wq->state != IDXD_WQ_DISABLED)
> > + return -EPERM;
> > +
> > + if (strlen(buf) > DRIVER_NAME_SIZE || strlen(buf) == 0)
> > + return -EINVAL;
> > +
> > + memset(wq->driver_name, 0, DRIVER_NAME_SIZE + 1);
> > + strncpy(wq->driver_name, buf, DRIVER_NAME_SIZE);
> > + strreplace(wq->name, '\n', '\0');
>
> If user inputs "dmaengine " (with the trailing white spaces), the
> trailing white spaces will be copied to wq->driver_name. Later driver
> name match will always fail.
>
> A better way is using strim() to remove the trailing white spaces before
> copying the buffer to wq->driver_name. So wq->driver_name is "dmaengine"
> (without the trailing white spaces).
>
Yes, good point, I'll add that. Thanks for pointing that out!
Tom
> Thanks.
>
> -Fenghua
next prev parent reply other threads:[~2023-07-11 18:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 19:06 [PATCH v7 00/14] crypto: Add Intel Analytics Accelerator (IAA) crypto compression driver Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 01/14] dmaengine: idxd: add wq driver name support for accel-config user tool Tom Zanussi
2023-07-11 17:49 ` Fenghua Yu
2023-07-11 18:57 ` Tom Zanussi [this message]
2023-07-10 19:06 ` [PATCH v7 02/14] dmaengine: idxd: add external module driver support for dsa_bus_type Tom Zanussi
2023-07-12 23:13 ` Yu, Fenghua
2023-07-10 19:06 ` [PATCH v7 03/14] dmaengine: idxd: Export drv_enable/disable and related functions Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 04/14] dmaengine: idxd: Export descriptor management functions Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 05/14] dmaengine: idxd: Export wq resource " Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 06/14] dmaengine: idxd: Add wq private data accessors Tom Zanussi
2023-07-12 23:12 ` Yu, Fenghua
2023-07-10 19:06 ` [PATCH v7 07/14] dmaengine: idxd: add callback support for iaa crypto Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 08/14] crypto: iaa - Add IAA Compression Accelerator Documentation Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 09/14] crypto: iaa - Add Intel IAA Compression Accelerator crypto driver core Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 10/14] crypto: iaa - Add per-cpu workqueue table with rebalancing Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 11/14] crypto: iaa - Add compression mode management along with fixed mode Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 12/14] crypto: iaa - Add support for deflate-iaa compression algorithm Tom Zanussi
2023-07-17 2:12 ` Rex Zhang
2023-07-17 21:35 ` Tom Zanussi
2023-07-22 1:23 ` Herbert Xu
2023-07-22 17:14 ` Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 13/14] crypto: iaa - Add irq support for the crypto async interface Tom Zanussi
2023-07-10 19:06 ` [PATCH v7 14/14] crypto: iaa - Add IAA Compression Accelerator stats Tom Zanussi
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=fd472a246013a6b30884f6d279c232b47c9de8db.camel@linux.intel.com \
--to=tom.zanussi@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=davem@davemloft.net \
--cc=dmaengine@vger.kernel.org \
--cc=fenghua.yu@intel.com \
--cc=giovanni.cabiddu@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=james.guilford@intel.com \
--cc=kanchana.p.sridhar@intel.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=vinodh.gopal@intel.com \
--cc=vkoul@kernel.org \
--cc=wajdi.k.feghali@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox