From patchwork Wed Oct 31 03:13:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10662035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CA271751 for ; Wed, 31 Oct 2018 03:24:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A8F22A440 for ; Wed, 31 Oct 2018 03:24:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F1B12A594; Wed, 31 Oct 2018 03:24:57 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D594A2A440 for ; Wed, 31 Oct 2018 03:24:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B734B6B033D; Tue, 30 Oct 2018 23:24:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B231F6B033F; Tue, 30 Oct 2018 23:24:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A391B6B0341; Tue, 30 Oct 2018 23:24:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 60B516B033D for ; Tue, 30 Oct 2018 23:24:55 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id h9-v6so10564779pgs.11 for ; Tue, 30 Oct 2018 20:24:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=mEg82Bat5HZC027BqUz2OLlmEDU24MVtgOchnD2tpz0=; b=W18GWHcLD2odbmTmbQfbhjsXWoWT1vY7ImbC9Wld6f6IXiVT0yy95c3MiTg3UEHG2r wOtEoXCgDYfUxmI0R02iot1y31vQpt9XRZ/JH6TJb6FbhIilFAz0lRrTfzOFTVQGT+E6 U/0egGOy6wfkaztZDUAkL6yGJZC3TilHQmTFhYUbZw35ryybW2XIMLPd0u+xfmRBwZ+a Qbv+q3jIr7anCkiSwUzOqUneUTyxPza2qg/pYM/VZEe5nlC5uI1VwBSH7s8eBkTC+uJz ocQd5Id9mWyVnGC9dNBfV3iDGFiKEF9K4dRmrlD2fp04jdw5p4Wb2LNYVstfPf9aWiZ9 1YlA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AGRZ1gL+iaU8mw4KHQmmEntI8bh038Ik5EKa5LA8S8KiJfbScj9jOQSm 6x+jrowSSxEhETfFjN9iOk+zq6GiC+p39G8gkd+bmg9vMBzI4enB81x/KatU36JnlSbS7fi9n+y RMhS8AaoPClGnJDqRt1fY7B4drSKvMkdZvdpcpU1jwC31OT3lwLKTyS/st7t983fbUg== X-Received: by 2002:a17:902:20ca:: with SMTP id v10-v6mr1529000plg.182.1540956295045; Tue, 30 Oct 2018 20:24:55 -0700 (PDT) X-Google-Smtp-Source: AJdET5ejWXj19Ym1GFwcOCgdwhOAYD3jp9734hYAzCqWO4iPdUOm5vnfGVAWz2X0y7E70wNHoRe3 X-Received: by 2002:a17:902:20ca:: with SMTP id v10-v6mr1528935plg.182.1540956293910; Tue, 30 Oct 2018 20:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540956293; cv=none; d=google.com; s=arc-20160816; b=eMEinOETQET9eNg0DtSiCc7WPJhl+9la//EzsuwkSQylkimQtjPS+7tzcRpzQEqdGj DVsaLzjJqDIuJJ/DtEJ4issh1NEYMTTAND7YT8nBjELsvTZi1VYPZNnIaWFGtzr9/QsV pMEPGLouPUukHXmx57jxHXhimtFnb3xNU+wNFO1csDK2/g6V1noZb+621JM3UjiIXuxU AJvgoyC+8S+48kXhG4nYT7wDPGkXCETyrG1XhOWSkelgY4ryYRDgp6Lc410ivsyBnpv7 JJoE7pekyXYQZBDien7ADzOYBme4cBxvC2XFr1fQwenBp5Bz7B+aDAUrhkrVvOKIbG7h sziA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=mEg82Bat5HZC027BqUz2OLlmEDU24MVtgOchnD2tpz0=; b=rCenzPZ6EPzwUsFisCuw1XzDH4Xv6+nsl8BILvRbmctNj0Pxz874UD8cLaR9JG1i2t C2OSLuKr6r1hh91JVUig9eQ2nqdg4ujRsJ7FJvQxhTe1ZYxpikEg6V34tplaa6cRAt8E jxz67IPgn5Z5D7pu4lnR37N7SeA6fgm7g/zXpsxVBcEdHvHTAgxp+3DYGmKDXkTNsntQ J5JF3i3opRROQbpnPOfBNtmyf4vxv0Y+Zu8BK4kw+AeKNaTkqC5k0jEKayyqIJELFeKs DA72GgHdszU5oXXadi/ufhz8az35JE+bYf+zk7Fo5bgcatV+obLYCuAJc7KOLw6l3w4i BawA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id 102-v6si9347637plf.65.2018.10.30.20.24.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 20:24:53 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 20:24:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,447,1534834800"; d="scan'208";a="87434960" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga006.jf.intel.com with ESMTP; 30 Oct 2018 20:24:53 -0700 Subject: [PATCH 3/8] device-dax: Remove multi-resource infrastructure From: Dan Williams To: linux-nvdimm@lists.01.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com Date: Tue, 30 Oct 2018 20:13:05 -0700 Message-ID: <154095558513.3271337.6460925877189898414.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <154095556915.3271337.12581429676272726902.stgit@dwillia2-desk3.amr.corp.intel.com> References: <154095556915.3271337.12581429676272726902.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The multi-resource implementation anticipated discontiguous sub-division support. That has not yet materialized, delete the infrastructure and related code. Signed-off-by: Dan Williams --- drivers/dax/dax-private.h | 4 --- drivers/dax/device-dax.h | 3 +- drivers/dax/device.c | 49 +++++++--------------------------------- drivers/dax/pmem.c | 3 +- tools/testing/nvdimm/dax-dev.c | 16 ++----------- 5 files changed, 13 insertions(+), 62 deletions(-) diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h index 9b393c218fe4..dbd077653b5c 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -39,14 +39,10 @@ struct dax_region { * @region - parent region * @dax_dev - core dax functionality * @dev - device core - * @num_resources - number of physical address extents in this device - * @res - array of physical address ranges */ struct dev_dax { struct dax_region *region; struct dax_device *dax_dev; struct device dev; - int num_resources; - struct resource res[0]; }; #endif diff --git a/drivers/dax/device-dax.h b/drivers/dax/device-dax.h index 4f1c69e1b3a2..e9be99584b92 100644 --- a/drivers/dax/device-dax.h +++ b/drivers/dax/device-dax.h @@ -19,6 +19,5 @@ struct dax_region; void dax_region_put(struct dax_region *dax_region); struct dax_region *alloc_dax_region(struct device *parent, int region_id, struct resource *res, unsigned int align, unsigned long flags); -struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, - int id, struct resource *res, int count); +struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, int id); #endif /* __DEVICE_DAX_H__ */ diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 811c1015194c..db12e24b8005 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -151,11 +151,7 @@ static ssize_t size_show(struct device *dev, struct device_attribute *attr, char *buf) { struct dev_dax *dev_dax = to_dev_dax(dev); - unsigned long long size = 0; - int i; - - for (i = 0; i < dev_dax->num_resources; i++) - size += resource_size(&dev_dax->res[i]); + unsigned long long size = resource_size(&dev_dax->region->res); return sprintf(buf, "%llu\n", size); } @@ -224,21 +220,11 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, unsigned long size) { - struct resource *res; - /* gcc-4.6.3-nolibc for i386 complains that this is uninitialized */ - phys_addr_t uninitialized_var(phys); - int i; - - for (i = 0; i < dev_dax->num_resources; i++) { - res = &dev_dax->res[i]; - phys = pgoff * PAGE_SIZE + res->start; - if (phys >= res->start && phys <= res->end) - break; - pgoff -= PHYS_PFN(resource_size(res)); - } + struct resource *res = &dev_dax->region->res; + phys_addr_t phys; - if (i < dev_dax->num_resources) { - res = &dev_dax->res[i]; + phys = pgoff * PAGE_SIZE + res->start; + if (phys >= res->start && phys <= res->end) { if (phys + size - 1 <= res->end) return phys; } @@ -608,8 +594,7 @@ static void unregister_dev_dax(void *dev) put_device(dev); } -struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, - int id, struct resource *res, int count) +struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, int id) { struct device *parent = dax_region->dev; struct dax_device *dax_dev; @@ -617,29 +602,12 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, struct inode *inode; struct device *dev; struct cdev *cdev; - int rc, i; + int rc; - if (!count) - return ERR_PTR(-EINVAL); - - dev_dax = kzalloc(struct_size(dev_dax, res, count), GFP_KERNEL); + dev_dax = kzalloc(sizeof(*dev_dax), GFP_KERNEL); if (!dev_dax) return ERR_PTR(-ENOMEM); - for (i = 0; i < count; i++) { - if (!IS_ALIGNED(res[i].start, dax_region->align) - || !IS_ALIGNED(resource_size(&res[i]), - dax_region->align)) { - rc = -EINVAL; - break; - } - dev_dax->res[i].start = res[i].start; - dev_dax->res[i].end = res[i].end; - } - - if (i < count) - goto err; - /* * No 'host' or dax_operations since there is no access to this * device outside of mmap of the resulting character device. @@ -659,7 +627,6 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, cdev_init(cdev, &dax_fops); cdev->owner = parent->driver->owner; - dev_dax->num_resources = count; dev_dax->dax_dev = dax_dev; dev_dax->region = dax_region; kref_get(&dax_region->kref); diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c index 3afae503fc42..23bc8ed40e84 100644 --- a/drivers/dax/pmem.c +++ b/drivers/dax/pmem.c @@ -137,8 +137,7 @@ static int dax_pmem_probe(struct device *dev) if (!dax_region) return -ENOMEM; - /* TODO: support for subdividing a dax region... */ - dev_dax = devm_create_dev_dax(dax_region, id, &res, 1); + dev_dax = devm_create_dev_dax(dax_region, id); /* child dev_dax instances now own the lifetime of the dax_region */ dax_region_put(dax_region); diff --git a/tools/testing/nvdimm/dax-dev.c b/tools/testing/nvdimm/dax-dev.c index 36ee3d8797c3..f36e708265b8 100644 --- a/tools/testing/nvdimm/dax-dev.c +++ b/tools/testing/nvdimm/dax-dev.c @@ -17,20 +17,11 @@ phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, unsigned long size) { - struct resource *res; + struct resource *res = &dev_dax->region->res; phys_addr_t addr; - int i; - for (i = 0; i < dev_dax->num_resources; i++) { - res = &dev_dax->res[i]; - addr = pgoff * PAGE_SIZE + res->start; - if (addr >= res->start && addr <= res->end) - break; - pgoff -= PHYS_PFN(resource_size(res)); - } - - if (i < dev_dax->num_resources) { - res = &dev_dax->res[i]; + addr = pgoff * PAGE_SIZE + res->start; + if (addr >= res->start && addr <= res->end) { if (addr + size - 1 <= res->end) { if (get_nfit_res(addr)) { struct page *page; @@ -44,6 +35,5 @@ phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, return addr; } } - return -1; }