From patchwork Tue Mar 7 21:06:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 9609841 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 B61BC602B4 for ; Tue, 7 Mar 2017 21:06:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8444728535 for ; Tue, 7 Mar 2017 21:06:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 794B82853E; Tue, 7 Mar 2017 21:06:45 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D89E28535 for ; Tue, 7 Mar 2017 21:06:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5876580363; Tue, 7 Mar 2017 13:06:45 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D794880352 for ; Tue, 7 Mar 2017 13:06:43 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2017 13:06:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,260,1486454400"; d="scan'208";a="832056217" Received: from djiang5-desk3.ch.intel.com ([143.182.137.38]) by FMSMGA003.fm.intel.com with ESMTP; 07 Mar 2017 13:06:43 -0800 Subject: [PATCH v2 2/5] libnvdimm: Add resource sysfs attrib to nd region From: Dave Jiang To: dan.j.williams@intel.com Date: Tue, 07 Mar 2017 14:06:43 -0700 Message-ID: <148892080294.46486.10193714287914679165.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <148892068983.46486.5008198419806159468.stgit@djiang5-desk3.ch.intel.com> References: <148892068983.46486.5008198419806159468.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Adding sysfs attribute in order to export the physical address of the ND region. This is for supporting of user app poison clear via device dax. Signed-off-by: Dave Jiang Reviewed-by: Johannes Thumshirn --- drivers/nvdimm/region_devs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index 3500fc8..8de5a04 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -463,6 +463,15 @@ static struct device_attribute dev_attr_nd_badblocks = { .show = nd_badblocks_show, }; +static ssize_t resource_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct nd_region *nd_region = to_nd_region(dev); + + return sprintf(buf, "%#llx\n", nd_region->ndr_start); +} +static DEVICE_ATTR_RO(resource); + static struct attribute *nd_region_attributes[] = { &dev_attr_size.attr, &dev_attr_nstype.attr, @@ -476,6 +485,7 @@ static struct attribute *nd_region_attributes[] = { &dev_attr_namespace_seed.attr, &dev_attr_init_namespaces.attr, &dev_attr_nd_badblocks.attr, + &dev_attr_resource.attr, NULL, }; @@ -495,6 +505,9 @@ static umode_t region_visible(struct kobject *kobj, struct attribute *a, int n) if (!is_nd_pmem(dev) && a == &dev_attr_nd_badblocks.attr) return 0; + if (!is_nd_pmem(dev) && a == &dev_attr_resource.attr) + return 0; + if (a != &dev_attr_set_cookie.attr && a != &dev_attr_available_size.attr) return a->mode;