From patchwork Sat Nov 6 12:10:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 1551659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=fhqgBcww; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hmbnk4RC8z9ssD for ; Sat, 6 Nov 2021 23:11:21 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mjKXQ-0005co-9x; Sat, 06 Nov 2021 12:11:12 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mjKXL-0005bR-Aj for kernel-team@lists.ubuntu.com; Sat, 06 Nov 2021 12:11:07 +0000 Received: from HP-EliteBook-840-G7.. (1-171-213-210.dynamic-ip.hinet.net [1.171.213.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 3C8BD3F1B4 for ; Sat, 6 Nov 2021 12:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1636200667; bh=bMtGZeo4LBT81hXKNue9XLMkzaKrPDo9sjsUHOXCCWI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fhqgBcwwrNBY/IvKRvS8uJKsvvL2JZ5xIdo/Zhf5lZccF8XlM9se5MxTC6ARSgU4x 99Y144Y+eNMta3rzPgAqnbD5ghb4+tTe4kCdQ1vhfp3oni7mDmsFE9FSbvba0L2Rnn 5CihKyLyzgO7y5mu0b3QhgY5LwQC+jBz2nTn4WpNoGh2qbgIa3/2xyXweC9RRB+IbX JQV/AtU724xJ3N1vdB3rd9t+QeNqoyn/a4XQgzc9ND9ETzo61KTD27Qc1PjVqdb3ju EdKCEEJD1DKsc/UzUQr9ikggSQpTgPJOBG5ZCy30ZKBgj9eFTjCKaCx9n8XlLTGRoD y4D6bHNOI6GCQ== From: Kai-Heng Feng To: kernel-team@lists.ubuntu.com Subject: [H/I/OEM-5.10/OEM-5.13/OEM-5.14] [PATCH 2/4] nvme-pci: cmb sysfs: one file, one value Date: Sat, 6 Nov 2021 20:10:56 +0800 Message-Id: <20211106121058.1843173-3-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211106121058.1843173-1-kai.heng.feng@canonical.com> References: <20211106121058.1843173-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Keith Busch BugLink: https://bugs.launchpad.net/bugs/1950042 An attribute should only be exporting one value as recommended in Documentation/filesystems/sysfs.rst. Implement CMB attributes this way. The old attribute will remain for backward compatibility. Signed-off-by: Keith Busch Signed-off-by: Christoph Hellwig (cherry picked from commit 1751e97aa940656b5de0e620f02cf193a275e014) Signed-off-by: Kai-Heng Feng --- drivers/nvme/host/pci.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 724be85141b75..3d734e60f2146 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2067,6 +2067,24 @@ static ssize_t cmb_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(cmb); +static ssize_t cmbloc_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev)); + + return sysfs_emit(buf, "%u\n", ndev->cmbloc); +} +static DEVICE_ATTR_RO(cmbloc); + +static ssize_t cmbsz_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev)); + + return sysfs_emit(buf, "%u\n", ndev->cmbsz); +} +static DEVICE_ATTR_RO(cmbsz); + static umode_t nvme_pci_attrs_are_visible(struct kobject *kobj, struct attribute *a, int n) { @@ -2074,13 +2092,19 @@ static umode_t nvme_pci_attrs_are_visible(struct kobject *kobj, dev_get_drvdata(container_of(kobj, struct device, kobj)); struct nvme_dev *dev = to_nvme_dev(ctrl); - if (a == &dev_attr_cmb.attr && !dev->cmbsz) - return 0; + if (a == &dev_attr_cmb.attr || + a == &dev_attr_cmbloc.attr || + a == &dev_attr_cmbsz.attr) { + if (!dev->cmbsz) + return 0; + } return a->mode; } static struct attribute *nvme_pci_attrs[] = { &dev_attr_cmb.attr, + &dev_attr_cmbloc.attr, + &dev_attr_cmbsz.attr, NULL, };