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, pavel@ucw.cz,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
dmaengine@vger.kernel.org
Subject: Re: [PATCH v10 14/14] dmaengine: idxd: Add support for device/wq defaults
Date: Tue, 28 Nov 2023 15:09:06 -0600 [thread overview]
Message-ID: <e0d1e4441dc7976450efd07322be0fe5a7526efe.camel@linux.intel.com> (raw)
In-Reply-To: <00aa3b9f-d81e-3dc2-3fb0-bb79e16564d3@intel.com>
Hi Fenghua,
On Tue, 2023-11-28 at 12:31 -0800, Fenghua Yu wrote:
> Hi, Tom,
>
> On 11/27/23 12:27, Tom Zanussi wrote:
> > Add a load_device_defaults() function pointer to struct
> > idxd_driver_data, which if defined, will be called when an idxd
> > device
> > is probed and will allow the idxd device to be configured with
> > default
> > values.
> >
> > The load_device_defaults() function is passed an idxd device to
> > work
> > with to set specific device attributes.
> >
> > Also add a load_device_defaults() implementation IAA devices;
> > future
> > patches would add default functions for other device types such as
> > DSA.
> >
> > The way idxd device probing works, if the device configuration is
> > valid at that point e.g. at least one workqueue and engine is
> > properly
> > configured then the device will be enabled and ready to go.
> >
> > The IAA implementation, idxd_load_iaa_device_defaults(), configures
> > a
> > single workqueue (wq0) for each device with the following default
> > values:
> >
> > mode "dedicated"
> > threshold 0
> > size 16
>
> Why is it 16?
>
> If wqcap supports less than 16, configuring wq size 16 will fail.
> If wqcap supports more than 16, wq size 16 uses less wq size than
> capable and less performance.
>
> Is it better to set wq size as total wq size reported in wqcap?
Yes, good point. I'll calculate this based on wqcap.
> > priority 10
> > type IDXD_WQT_KERNEL
> > group 0
> > name "iaa_crypto"
> > driver_name "crypto"
> >
> > Note that this now adds another configuration step for any users
> > that
> > want to configure their own devices/workqueus with something
> > different
> > in that they'll first need to disable (in the case of IAA) wq0 and
> > the
> > device itself before they can set their own attributes and re-
> > enable,
> > since they've been already been auto-enabled. Note also that in
> > order
> > for the new configuration to be applied to the deflate-iaa crypto
> > algorithm the iaa_crypto module needs to unregister the old
> > version,
> > which is accomplished by removing the iaa_crypto module, and
> > re-registering it with the new configuration by reinserting the
> > iaa_crypto module.
> >
> > Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> > ---
> > drivers/dma/idxd/Makefile | 2 +-
> > drivers/dma/idxd/defaults.c | 53
> > +++++++++++++++++++++++++++++++++++++
> > drivers/dma/idxd/idxd.h | 4 +++
> > drivers/dma/idxd/init.c | 7 +++++
> > 4 files changed, 65 insertions(+), 1 deletion(-)
> > create mode 100644 drivers/dma/idxd/defaults.c
> >
> > diff --git a/drivers/dma/idxd/Makefile b/drivers/dma/idxd/Makefile
> > index c5e679070e46..2b4a0d406e1e 100644
> > --- a/drivers/dma/idxd/Makefile
> > +++ b/drivers/dma/idxd/Makefile
> > @@ -4,7 +4,7 @@ obj-$(CONFIG_INTEL_IDXD_BUS) += idxd_bus.o
> > idxd_bus-y := bus.o
> >
> > obj-$(CONFIG_INTEL_IDXD) += idxd.o
> > -idxd-y := init.o irq.o device.o sysfs.o submit.o dma.o cdev.o
> > debugfs.o
> > +idxd-y := init.o irq.o device.o sysfs.o submit.o dma.o cdev.o
> > debugfs.o defaults.o
> >
> > idxd-$(CONFIG_INTEL_IDXD_PERFMON) += perfmon.o
> >
> > diff --git a/drivers/dma/idxd/defaults.c
> > b/drivers/dma/idxd/defaults.c
> > new file mode 100644
> > index 000000000000..a0c9faad8efe
> > --- /dev/null
> > +++ b/drivers/dma/idxd/defaults.c
> > @@ -0,0 +1,53 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/* Copyright(c) 2023 Intel Corporation. All rights rsvd. */
> > +#include <linux/kernel.h>
> > +#include "idxd.h"
> > +
> > +int idxd_load_iaa_device_defaults(struct idxd_device *idxd)
> > +{
> > + struct idxd_engine *engine;
> > + struct idxd_group *group;
> > + struct idxd_wq *wq;
> > +
> > + if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
> > + return 0;
> > +
> > + wq = idxd->wqs[0];
> > +
> > + if (wq->state != IDXD_WQ_DISABLED)
> > + return -EPERM;
> > +
> > + /* set mode to "dedicated" */
> > + set_bit(WQ_FLAG_DEDICATED, &wq->flags);
> > + wq->threshold = 0;
> > +
> > + /* set size to 16 */
> > + wq->size = 16;
> > +
> > + /* set priority to 10 */
> > + wq->priority = 10;
> > +
> > + /* set type to "kernel" */
> > + wq->type = IDXD_WQT_KERNEL;
> > +
> > + /* set wq group to 0 */
> > + group = idxd->groups[0];
> > + wq->group = group;
> > + group->num_wqs++;
> > +
> > + /* set name to "iaa_crypto" */
> > + memset(wq->name, 0, WQ_NAME_SIZE + 1);
> > + strscpy(wq->name, "iaa_crypto", WQ_NAME_SIZE + 1);
>
> Is strcpy(wq->name, "iaa_crypto") simpler than memset() and
> strscpy()?
That's what I originally had, but checkpatch complained about it,
suggesting strscpy, so I changed it to make checkpatch happy.
>
> > +
> > + /* set driver_name to "crypto" */
> > + memset(wq->driver_name, 0, DRIVER_NAME_SIZE + 1);
> > + strscpy(wq->driver_name, "crypto", DRIVER_NAME_SIZE + 1);
>
> Is strcpy(wq->driver_name, "crypto") simpler?
Same here.
Thanks,
Tom
>
> > +
> > + engine = idxd->engines[0];
> > +
> > + /* set engine group to 0 */
> > + engine->group = idxd->groups[0];
> > + engine->group->num_engines++;
> > +
> > + return 0;
> > +}
> > diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
> > index 62ea21b25906..47de3f93ff1e 100644
> > --- a/drivers/dma/idxd/idxd.h
> > +++ b/drivers/dma/idxd/idxd.h
> > @@ -277,6 +277,8 @@ struct idxd_dma_dev {
> > struct dma_device dma;
> > };
> >
> > +typedef int (*load_device_defaults_fn_t) (struct idxd_device
> > *idxd);
> > +
> > struct idxd_driver_data {
> > const char *name_prefix;
> > enum idxd_type type;
> > @@ -286,6 +288,7 @@ struct idxd_driver_data {
> > int evl_cr_off;
> > int cr_status_off;
> > int cr_result_off;
> > + load_device_defaults_fn_t load_device_defaults;
> > };
> >
> > struct idxd_evl {
> > @@ -730,6 +733,7 @@ void idxd_unregister_devices(struct idxd_device
> > *idxd);
> > void idxd_wqs_quiesce(struct idxd_device *idxd);
> > bool idxd_queue_int_handle_resubmit(struct idxd_desc *desc);
> > void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count);
> > +int idxd_load_iaa_device_defaults(struct idxd_device *idxd);
> >
> > /* device interrupt control */
> > irqreturn_t idxd_misc_thread(int vec, void *data);
> > diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
> > index 0eb1c827a215..14df1f1347a8 100644
> > --- a/drivers/dma/idxd/init.c
> > +++ b/drivers/dma/idxd/init.c
> > @@ -59,6 +59,7 @@ static struct idxd_driver_data idxd_driver_data[]
> > = {
> > .evl_cr_off = offsetof(struct iax_evl_entry, cr),
> > .cr_status_off = offsetof(struct
> > iax_completion_record, status),
> > .cr_result_off = offsetof(struct
> > iax_completion_record, error_code),
> > + .load_device_defaults =
> > idxd_load_iaa_device_defaults,
> > },
> > };
> >
> > @@ -745,6 +746,12 @@ static int idxd_pci_probe(struct pci_dev
> > *pdev, const struct pci_device_id *id)
> > goto err;
> > }
> >
> > + if (data->load_device_defaults) {
> > + rc = data->load_device_defaults(idxd);
> > + if (rc)
> > + dev_warn(dev, "IDXD loading device defaults
> > failed\n");
> > + }
> > +
> > rc = idxd_register_devices(idxd);
> > if (rc) {
> > dev_err(dev, "IDXD sysfs setup failed\n");
>
> Thanks.
>
> -Fenghua
next prev parent reply other threads:[~2023-11-28 21:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 20:26 [PATCH v10 00/14] crypto: Add Intel Analytics Accelerator (IAA) crypto compression driver Tom Zanussi
2023-11-27 20:26 ` [PATCH v10 01/14] dmaengine: idxd: add external module driver support for dsa_bus_type Tom Zanussi
2023-11-27 20:26 ` [PATCH v10 02/14] dmaengine: idxd: Rename drv_enable/disable_wq to idxd_drv_enable/disable_wq, and export Tom Zanussi
2023-11-29 13:23 ` Vinod Koul
2023-11-27 20:26 ` [PATCH v10 03/14] dmaengine: idxd: Export descriptor management functions Tom Zanussi
2023-11-27 20:26 ` [PATCH v10 04/14] dmaengine: idxd: Export wq resource " Tom Zanussi
2023-11-27 20:26 ` [PATCH v10 05/14] dmaengine: idxd: Add wq private data accessors Tom Zanussi
2023-11-27 20:26 ` [PATCH v10 06/14] dmaengine: idxd: add callback support for iaa crypto Tom Zanussi
2023-11-27 20:26 ` [PATCH v10 07/14] crypto: iaa - Add IAA Compression Accelerator Documentation Tom Zanussi
2023-11-27 20:26 ` [PATCH v10 08/14] crypto: iaa - Add Intel IAA Compression Accelerator crypto driver core Tom Zanussi
2023-11-27 20:26 ` [PATCH v10 09/14] crypto: iaa - Add per-cpu workqueue table with rebalancing Tom Zanussi
2023-11-27 20:27 ` [PATCH v10 10/14] crypto: iaa - Add compression mode management along with fixed mode Tom Zanussi
2023-11-27 20:27 ` [PATCH v10 11/14] crypto: iaa - Add support for deflate-iaa compression algorithm Tom Zanussi
2023-11-27 20:27 ` [PATCH v10 12/14] crypto: iaa - Add irq support for the crypto async interface Tom Zanussi
2023-11-27 20:27 ` [PATCH v10 13/14] crypto: iaa - Add IAA Compression Accelerator stats Tom Zanussi
2023-11-27 20:27 ` [PATCH v10 14/14] dmaengine: idxd: Add support for device/wq defaults Tom Zanussi
2023-11-27 22:14 ` Dave Jiang
2023-11-27 22:42 ` Tom Zanussi
2023-11-28 20:31 ` Fenghua Yu
2023-11-28 21:09 ` Tom Zanussi [this message]
2023-11-30 0:31 ` Yu, Fenghua
2023-11-30 15:18 ` 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=e0d1e4441dc7976450efd07322be0fe5a7526efe.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=pavel@ucw.cz \
--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