From patchwork Fri Dec 16 18:54:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Bates X-Patchwork-Id: 9478267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 705D5601C2 for ; Fri, 16 Dec 2016 19:20:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39C9F286E5 for ; Fri, 16 Dec 2016 19:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CAB128736; Fri, 16 Dec 2016 19:20:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F07812873E for ; Fri, 16 Dec 2016 19:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759001AbcLPTUN (ORCPT ); Fri, 16 Dec 2016 14:20:13 -0500 Received: from gateway21.websitewelcome.com ([192.185.45.31]:59703 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758993AbcLPTUM (ORCPT ); Fri, 16 Dec 2016 14:20:12 -0500 X-Greylist: delayed 1511 seconds by postgrey-1.27 at vger.kernel.org; Fri, 16 Dec 2016 14:20:12 EST Received: from cm5.websitewelcome.com (unknown [108.167.139.22]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 015AB400E8A59 for ; Fri, 16 Dec 2016 12:54:59 -0600 (CST) Received: from estate.websitewelcome.com ([192.185.83.90]) by cm5.websitewelcome.com with id Liux1u0151wvuag01iuyeg; Fri, 16 Dec 2016 12:54:58 -0600 Received: from lambic.deltatee.com ([207.54.116.65]:53010 helo=cgy1-donard.priv.deltatee.com) by estate.websitewelcome.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.87) (envelope-from ) id 1cHxej-000MJb-H1; Fri, 16 Dec 2016 12:54:57 -0600 From: Stephen Bates To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, axboe@fb.com Cc: sagi@grimberg.me, james_p_freyensee@linux.intel.com, jonathan.derrick@intel.com, Stephen Bates Subject: [PATCH 2/2] nvme: improve cmb sysfs reporting Date: Fri, 16 Dec 2016 11:54:51 -0700 Message-Id: <1481914491-21456-3-git-send-email-sbates@raithlin.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1481914491-21456-1-git-send-email-sbates@raithlin.com> References: <1481914491-21456-1-git-send-email-sbates@raithlin.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - estate.websitewelcome.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - raithlin.com X-BWhitelist: no X-Source-IP: 207.54.116.65 X-Exim-ID: 1cHxej-000MJb-H1 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: lambic.deltatee.com (cgy1-donard.priv.deltatee.com) [207.54.116.65]:53010 X-Source-Auth: sbates@raithlin.com X-Email-Count: 19 X-Source-Cap: cmFpdGhsaW47c2NvdHQ7ZXN0YXRlLndlYnNpdGV3ZWxjb21lLmNvbQ== Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add more information to the NVMe CMB sysfs entry. This includes information about the CMB size, location and capabilities. Signed-off-by: Stephen Bates --- drivers/nvme/host/pci.c | 31 +++++++++++++++++++++++++++++-- include/linux/nvme.h | 8 ++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index be10860..1f70630 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -98,6 +98,7 @@ struct nvme_dev { void __iomem *cmb; dma_addr_t cmb_dma_addr; u64 cmb_size; + u64 cmb_offset; u32 cmbsz; u32 cmbloc; struct nvme_ctrl ctrl; @@ -1326,14 +1327,39 @@ static int nvme_create_io_queues(struct nvme_dev *dev) return ret >= 0 ? 0 : ret; } +static const char * const cmb_caps[] = { + [NVME_CMB_CAP_SQS] = "SQS", + [NVME_CMB_CAP_CQS] = "CQS", + [NVME_CMB_CAP_LISTS] = "LISTS", + [NVME_CMB_CAP_RDS] = "RDS", + [NVME_CMB_CAP_WDS] = "WDS", +}; + static ssize_t nvme_cmb_show(struct device *dev, struct device_attribute *attr, char *buf) { struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev)); + unsigned int i, len = 0; + + len += scnprintf(buf+len, PAGE_SIZE-len, + "cmbloc : 0x%08x\ncmbsz : 0x%08x\n\n", + ndev->cmbloc, ndev->cmbsz); + + len += scnprintf(buf+len, PAGE_SIZE-len, + "OFFSET : 0x%016llx\nSIZE : %llu Bytes\n" \ + "DMA ADDR : %pad\n\n", + ndev->cmb_offset, ndev->cmb_size, + &ndev->cmb_dma_addr); + + for (i = NVME_CMB_CAP_SQS; i <= NVME_CMB_CAP_WDS; i++) + len += scnprintf(buf+len, PAGE_SIZE-len, "%-7s: %s\n", + cmb_caps[i], + ((ndev->cmbsz) & (1<cmbloc, ndev->cmbsz); } static DEVICE_ATTR(cmb, S_IRUGO, nvme_cmb_show, NULL); @@ -1376,6 +1402,7 @@ static void __iomem *nvme_map_cmb(struct nvme_dev *dev) dev->cmb_dma_addr = dma_addr; dev->cmb_size = size; + dev->cmb_offset = offset; return cmb; } diff --git a/include/linux/nvme.h b/include/linux/nvme.h index fc3c242..cd0d324 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -121,6 +121,14 @@ enum { #define NVME_CMB_CQS(cmbsz) ((cmbsz) & 0x2) #define NVME_CMB_SQS(cmbsz) ((cmbsz) & 0x1) +enum { + NVME_CMB_CAP_SQS = 0, + NVME_CMB_CAP_CQS, + NVME_CMB_CAP_LISTS, + NVME_CMB_CAP_RDS, + NVME_CMB_CAP_WDS, +}; + /* * Submission and Completion Queue Entry Sizes for the NVM command set. * (In bytes and specified as a power of two (2^n)).