From patchwork Wed Jul 12 17:44:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fenghua Yu X-Patchwork-Id: 119314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1317704vqm; Wed, 12 Jul 2023 10:54:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlG/Ns8Sh3QNmliqdh+m4iVGB4Qh86vJKYPA7EFslxT7QEyI0WEtq3FQ8nPMtneT6RHei7CK X-Received: by 2002:a17:906:20d8:b0:993:eef2:5d56 with SMTP id c24-20020a17090620d800b00993eef25d56mr15560906ejc.0.1689184483564; Wed, 12 Jul 2023 10:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689184483; cv=none; d=google.com; s=arc-20160816; b=waTAJrkAia2rxtWPqeAZroY5BhwTjOKxK4h0u6AxgTu8UHA5nolg1guJ1Ik/b5iLNo sI0btsdvOHc1a8QnggDVXIFRgtoMHlFxZGEqqJlDOxnX4v8lr6shKtR3R0XZnOg1TBGW fYgG8gKJv3uBJWcu/g5XgTR/trQiBZNYxda/WyCGGXtw6UJirUwXxkXXzg9RXICYHYj8 nVEL7JGcAFXjknlUFfCM3EaGKczNuBoung0LpsS68u2CSe0cLB0U7qYs7nqAdk+mLrF9 TK6fiGqdneOcGCSviRHrtq8/nDfDd1zFmgnCXo+ZNtxQrGWG0ZaniO14CBOAYRd1Z+KR Bsaw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=QLPK380mEANZMQyS6l/ilXAmevNGYEsE1SyZm4e4CTA=; fh=/5iuT7zm+1LdtyDsRT8aaoOPy5FKYhDbwG/k3GVtR/A=; b=MKeNnJ8sEPp+Jelt20cOtzkkwGUfqC7mozxQgI4LnArCIAiIAxEfqg9y06zZvc2Ut1 Tj8ijvrHYtssXO+x8EClPOa36FCcqhOiTbvJocVPG5nGkP4g92YBbi1PQNNIUhnYJhub zSsqZU6KXZj7YQTCdFJwLfS5veO8iFlTlFvFueD9+SwQ5Jc9gYjV6h8CS1QxTxVSJBwI lBXqmQiCxnNTIM1q00y+KVygUfNvv65fz1bmD1L3G2UN45929LmnjnUWKEqNp9xEbHfk eJnCkfhLRyDgYsOf5zyk3cVsRPVv6vS2pTZPm3uSq1Wdr9+aIWdOd9ZCXZxorYs0kYoC ImGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SGAmd4Bf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gh16-20020a170906e09000b0099302221714si4987240ejb.790.2023.07.12.10.54.19; Wed, 12 Jul 2023 10:54:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=SGAmd4Bf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S232159AbjGLRor (ORCPT + 99 others); Wed, 12 Jul 2023 13:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbjGLRol (ORCPT ); Wed, 12 Jul 2023 13:44:41 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 326CE1BC6; Wed, 12 Jul 2023 10:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689183881; x=1720719881; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=U2R7b+iUtPFdxm/EIWwuSf9S3+IwEB4iHE7tb1dTlJE=; b=SGAmd4BfhJO5bxD2koM2x3WcjxJT2uHL5Vn5jQb6VTxg6SeUOLWSOo8C Ax+x/V+3un7PCe3mfGOHQ06AwRIVvJrO0Gdq00h1VKewOl8VUqqXTTKbV 2Wx80EkbeoTyJspErtYcem62gn6Ko4SdchZMuO75LSTm9ZPL1g2AjNQoc imRvXswW/OdXAxat5nMFIbI0CANNDcDoUE/MkEQmZe+h6QQiUAa5CAdso wCaBaodXyZ1LXEYFXrKI6wNjAkApIOmXpODkb0GtNGZEzJo52DHzkbxSo oTXF+9XV20HdBsWizHPk3t35cZ4RnnjFHxe/EQt3EaYWc6js4nEwt5sL+ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10769"; a="363828273" X-IronPort-AV: E=Sophos;i="6.01,200,1684825200"; d="scan'208";a="363828273" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 10:44:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10769"; a="811671700" X-IronPort-AV: E=Sophos;i="6.01,200,1684825200"; d="scan'208";a="811671700" Received: from fyu1.sc.intel.com ([172.25.103.126]) by FMSMGA003.fm.intel.com with ESMTP; 12 Jul 2023 10:44:40 -0700 From: Fenghua Yu To: "Vinod Koul" , "Dave Jiang" Cc: dmaengine@vger.kernel.org, "linux-kernel" , Fenghua Yu Subject: [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks Date: Wed, 12 Jul 2023 10:44:35 -0700 Message-Id: <20230712174436.3435088-1-fenghua.yu@intel.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771238309063579305 X-GMAIL-MSGID: 1771238309063579305 The functions that check if WQ attributes are invisible are almost duplicate. Define a helper to simplify these functions and future WQ attribute visibility checks as well. Signed-off-by: Fenghua Yu Reviewed-by: Dave Jiang --- drivers/dma/idxd/sysfs.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c index 293739ac5596..388fba7c85f8 100644 --- a/drivers/dma/idxd/sysfs.c +++ b/drivers/dma/idxd/sysfs.c @@ -1288,12 +1288,9 @@ static struct attribute *idxd_wq_attributes[] = { NULL, }; -static bool idxd_wq_attr_op_config_invisible(struct attribute *attr, - struct idxd_device *idxd) -{ - return attr == &dev_attr_wq_op_config.attr && - !idxd->hw.wq_cap.op_config; -} +/* A WQ attr is invisible if the feature is not supported in WQCAP. */ +#define idxd_wq_attr_invisible(name, cap_field, a, idxd) \ + ((a) == &dev_attr_wq_##name.attr && !(idxd)->hw.wq_cap.cap_field) static bool idxd_wq_attr_max_batch_size_invisible(struct attribute *attr, struct idxd_device *idxd) @@ -1303,13 +1300,6 @@ static bool idxd_wq_attr_max_batch_size_invisible(struct attribute *attr, idxd->data->type == IDXD_TYPE_IAX; } -static bool idxd_wq_attr_wq_prs_disable_invisible(struct attribute *attr, - struct idxd_device *idxd) -{ - return attr == &dev_attr_wq_prs_disable.attr && - !idxd->hw.wq_cap.wq_prs_support; -} - static umode_t idxd_wq_attr_visible(struct kobject *kobj, struct attribute *attr, int n) { @@ -1317,13 +1307,13 @@ static umode_t idxd_wq_attr_visible(struct kobject *kobj, struct idxd_wq *wq = confdev_to_wq(dev); struct idxd_device *idxd = wq->idxd; - if (idxd_wq_attr_op_config_invisible(attr, idxd)) + if (idxd_wq_attr_invisible(op_config, op_config, attr, idxd)) return 0; if (idxd_wq_attr_max_batch_size_invisible(attr, idxd)) return 0; - if (idxd_wq_attr_wq_prs_disable_invisible(attr, idxd)) + if (idxd_wq_attr_invisible(prs_disable, wq_prs_support, attr, idxd)) return 0; return attr->mode; From patchwork Wed Jul 12 17:44:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fenghua Yu X-Patchwork-Id: 119315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1317703vqm; Wed, 12 Jul 2023 10:54:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlFO56SgwJ3pFVPbXCEzr2BsN8Jcqmd3nnkA/XW4Lhb/fg1UhRRQaggHzM8CZuRxhGTMAy5e X-Received: by 2002:a2e:9104:0:b0:2b6:d7d1:95c0 with SMTP id m4-20020a2e9104000000b002b6d7d195c0mr16144232ljg.11.1689184483604; Wed, 12 Jul 2023 10:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689184483; cv=none; d=google.com; s=arc-20160816; b=vOj7t4YYmKe0bqwsJ4YmupbtosWntqLFlccztLi5qwh0iLih3ewSg60hIZxMTOhN3n T3d90LfJIl122DebWd1S71z3aJRkDO6//YDUb6t04utau5ZvXfK3LWIvVR7b/xVg79Ex gbt5aBu1BYALELIIhEkKqFmvV9eXKxIdhPXWfvV/hVGEPM2StgQePko/fURYBxbg2ySx QrsZeTquCo+CW6D5v8oBrKhfERG2DoX3cNrpY7HFCszQJDXEdAkstSBlEhKaRGJjg7PP 2uyN15miTC/40K2taTPPpAM5KY2x+K1ftw06GTXj3vMisS2bQq7mQPnZtxRjQv6W51Ds mIQw== 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=WR8lScki+4QXdZ6SI4RgXKumL2Zc8AWBdI9WkoIoXYA=; fh=/5iuT7zm+1LdtyDsRT8aaoOPy5FKYhDbwG/k3GVtR/A=; b=EG/kvAA8Opk8vIcRmjmgP0uSLeg80AabqJFAQq/hr26Qk3PLc4ieCMOOY6cZu/xCPW 7SyVGGPYGrRFw4d0lQR1IzVK8Y9y+mqJFI9ASBoiALPt35LJ8P+ugPZSyLAva6U23SE4 JIXSby8vi4uCkFMnIztMQY5fBv+IhJlOx1FKADEpai0ngDA9z8j3VN1FqLSYKDrJ4b0J wayBhrkmrW7Yx+sWIHMqWBlh2YKSfrXBgEtat1W9vZ+1xWHxorlNREkZlrTi86Va4whJ KHCNVLzB6L2oxOjDHcFR4Uy/4FAM5dlg0F6cwH+S9kT5fuuRmgPBpUw6N5rSFILcdW3q XVIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RhpNfr2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc5-20020a170906f90500b009931472bdb8si4946835ejb.965.2023.07.12.10.54.19; Wed, 12 Jul 2023 10:54:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=RhpNfr2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S232049AbjGLRot (ORCPT + 99 others); Wed, 12 Jul 2023 13:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbjGLRoo (ORCPT ); Wed, 12 Jul 2023 13:44:44 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21F7C1FE1; Wed, 12 Jul 2023 10:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689183882; x=1720719882; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3Hsd5zirctSI+8W68udbD0g6eNW2VbZCTcPq+MQAM9k=; b=RhpNfr2gnpiyjifZYDLAnKUzueAlKfMh8Q+wthS4hnBmmiEJaU2WkULr MrFlhQ88FSQV9wNCJ5D15bukUc5RGLkv4GKXz0cuK951FKvsyI5br0zjW OpZaBTyUzNQbFUl4IpbmQX5KX+wrKfuIixstjr5XAYojuGBv8xYyITeEG aCixd5qK98tf/mwJO1KfyFxXsPv7/ziQiNfywbcKDxr6XLIsUOpii9ygz zeE1IR7a9W4iGfQrG7KSlzc2rHSqYP5QZmQCqBm/vn/FmvvjZRsf4pQZU H4W+XtvCSUuVwurKycQ2jOiYc7i89C+xj7kT0b6sme3E4TCiuOhmJQcR7 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10769"; a="363828275" X-IronPort-AV: E=Sophos;i="6.01,200,1684825200"; d="scan'208";a="363828275" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 10:44:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10769"; a="811671702" X-IronPort-AV: E=Sophos;i="6.01,200,1684825200"; d="scan'208";a="811671702" Received: from fyu1.sc.intel.com ([172.25.103.126]) by FMSMGA003.fm.intel.com with ESMTP; 12 Jul 2023 10:44:40 -0700 From: Fenghua Yu To: "Vinod Koul" , "Dave Jiang" Cc: dmaengine@vger.kernel.org, "linux-kernel" , Fenghua Yu Subject: [PATCH 2/2] dmaengine: idxd: Expose ATS disable knob only when WQ ATS is supported Date: Wed, 12 Jul 2023 10:44:36 -0700 Message-Id: <20230712174436.3435088-2-fenghua.yu@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230712174436.3435088-1-fenghua.yu@intel.com> References: <20230712174436.3435088-1-fenghua.yu@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771238309079098985 X-GMAIL-MSGID: 1771238309079098985 WQ Advanced Translation Service (ATS) can be controlled only when WQ ATS is supported. The sysfs ATS disable knob should be visible only when the features is supported. Signed-off-by: Fenghua Yu Reviewed-by: Dave Jiang --- drivers/dma/idxd/sysfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c index 388fba7c85f8..7c317367226d 100644 --- a/drivers/dma/idxd/sysfs.c +++ b/drivers/dma/idxd/sysfs.c @@ -1088,16 +1088,12 @@ static ssize_t wq_ats_disable_store(struct device *dev, struct device_attribute const char *buf, size_t count) { struct idxd_wq *wq = confdev_to_wq(dev); - struct idxd_device *idxd = wq->idxd; bool ats_dis; int rc; if (wq->state != IDXD_WQ_DISABLED) return -EPERM; - if (!idxd->hw.wq_cap.wq_ats_support) - return -EOPNOTSUPP; - rc = kstrtobool(buf, &ats_dis); if (rc < 0) return rc; @@ -1316,6 +1312,9 @@ static umode_t idxd_wq_attr_visible(struct kobject *kobj, if (idxd_wq_attr_invisible(prs_disable, wq_prs_support, attr, idxd)) return 0; + if (idxd_wq_attr_invisible(ats_disable, wq_ats_support, attr, idxd)) + return 0; + return attr->mode; }