Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35759977rwd; Mon, 10 Jul 2023 12:09:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlGGao5KBcOiVO/q3RAjfW56r8UJZ2HiDRZr7VtOtFVGvQBZgGAYRxl92OLhH3hea3AEc1MU X-Received: by 2002:a17:90b:38d:b0:263:9329:19df with SMTP id ga13-20020a17090b038d00b00263932919dfmr10318460pjb.36.1689016152289; Mon, 10 Jul 2023 12:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689016152; cv=none; d=google.com; s=arc-20160816; b=GflMjMxd+QyXpL+MGM2c3SQGymSgdWQdrHzkUZ8kPk86eXOa+oZ1JdaBgYL6mLBTNJ B9QHClwkhYw+uJgT2CWF6xHTi158rfV0+wWVf0XC72Bfuie5zq10DTsOci2oE0cKPP7c F0qQ3beAKU8+QFAUk/HurSThMaowgm3kPyTctNhKxAqc2294CjGkn/1/bwyXshJHGkWT bUsJFasdOCjH3V7K01E1YLztLzVJ2M5qV5k1RaYvxGnfrZ0EFvi/pEuvqOc08H89nT9E OkTT/Ajyeu1WagrA1nwWx8emEZ21biIfEiUEJ2a+gjhJLgEBrCR/en9n2Z+IPYET7ytO dwLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZvqwdYEyQ6/9WgnPk/6eI2JNI9/iahxOVHPrKAUv/LM=; fh=KKYX96Dyn269sAN9Nbt8IfOk86mWVdLVST7Tbph7224=; b=xPfqVZqk70PmiBatHDIC0TxIerJhbS+ruZWbpjM3cJw12xQpj19RrQRlHcl9pix11w ScajHOEGqW2YJsuXbX4yibJzrQ6vbL6PW13oAfYz6FDxpXBjZ5duT+tGYVkVK/4f/MVK 3Pm7NPDu+2CYdpDzW36cOrVGUBVwJejCXnsSdvfWS0xZFKm0Ql49McTIT7j6n9q6bnaL +ZPBq9sBaC5UM4eHll4q+vVMocVZbAS+MFCnQywcncUbia7YJKCDkF84fhSlT2Jozr/F BjevXJ/tRxoPRneVsOMafEqtsbtPCwVbQUDgTTmkGL6VMwyNwyJO4+mAY5qTYUMhRt2O ojdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fmh8XupG; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lp3-20020a17090b4a8300b0025defcc6e75si273474pjb.172.2023.07.10.12.08.51; Mon, 10 Jul 2023 12:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fmh8XupG; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjGJTHD (ORCPT + 99 others); Mon, 10 Jul 2023 15:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjGJTHD (ORCPT ); Mon, 10 Jul 2023 15:07:03 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ED209D; Mon, 10 Jul 2023 12:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689016022; x=1720552022; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7wHyUQOkzK8BGn6NRiVl1TNuSnOG57CjWfmL7W1+UkQ=; b=fmh8XupGPV0dSkTTduJZdTEwBG71Nsel6RzRrhRm+0mHR9grJSpErYPC o6ZgET+CoQb6BvB4qqcBBAH9RmJdRXmgjzfToSiV3dhozBJcXqKJhKHqI HdodTKDrVF5J6zwrQe0wUwc6Cly02HenLanu2uLBKUbJ7QZ6brIpkpR+b tmwLRpTJX78u/mPws9O5n4j0WCL43G4f+HW69lPM9GU3WBZmeQz2ayxzN tyQAKE5W2XjysbxEGwjAcvzgo+Jkh0796AhAdRxhH5+8uDAJs0jsBjDdb 2535GernuKUXdMLiClzuhTsb2U4NO5n4j3/CC5ZxTx8ApHwV/HGD2G8el Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="354290736" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="354290736" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2023 12:07:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="844990983" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="844990983" Received: from jdmillsx-mobl1.amr.corp.intel.com (HELO tzanussi-mobl1.intel.com) ([10.212.107.12]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2023 12:06:59 -0700 From: Tom Zanussi To: herbert@gondor.apana.org.au, davem@davemloft.net, fenghua.yu@intel.com, 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: [PATCH v7 01/14] dmaengine: idxd: add wq driver name support for accel-config user tool Date: Mon, 10 Jul 2023 14:06:41 -0500 Message-Id: <20230710190654.299639-2-tom.zanussi@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710190654.299639-1-tom.zanussi@linux.intel.com> References: <20230710190654.299639-1-tom.zanussi@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Dave Jiang 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 Signed-off-by: Tom Zanussi --- .../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./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./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'); + return count; +} + +static struct device_attribute dev_attr_wq_driver_name = + __ATTR(driver_name, 0644, wq_driver_name_show, wq_driver_name_store); + static struct attribute *idxd_wq_attributes[] = { &dev_attr_wq_clients.attr, &dev_attr_wq_state.attr, @@ -1285,6 +1312,7 @@ static struct attribute *idxd_wq_attributes[] = { &dev_attr_wq_occupancy.attr, &dev_attr_wq_enqcmds_retries.attr, &dev_attr_wq_op_config.attr, + &dev_attr_wq_driver_name.attr, NULL, }; diff --git a/include/uapi/linux/idxd.h b/include/uapi/linux/idxd.h index 606b52e88ce3..3d1987e1bb2d 100644 --- a/include/uapi/linux/idxd.h +++ b/include/uapi/linux/idxd.h @@ -31,6 +31,7 @@ enum idxd_scmd_stat { IDXD_SCMD_WQ_IRQ_ERR = 0x80100000, IDXD_SCMD_WQ_USER_NO_IOMMU = 0x80110000, IDXD_SCMD_DEV_EVL_ERR = 0x80120000, + IDXD_SCMD_WQ_NO_DRV_NAME = 0x80200000, }; #define IDXD_SCMD_SOFTERR_MASK 0x80000000 -- 2.34.1