Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1806027pxa; Sun, 2 Aug 2020 22:23:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQk8DJ5j4/8pSf36Hbz+onWbAj+LERREZciuurLTnPXYQUgPJbiFMVWPjwI0jXYjsicISq X-Received: by 2002:a17:906:af51:: with SMTP id ly17mr14550975ejb.81.1596432214602; Sun, 02 Aug 2020 22:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596432214; cv=none; d=google.com; s=arc-20160816; b=y/72ld+bDTOwlnGCD/CoWFRFwklxk8JrHv3riI2fcZ/dalrV32eMQHZVcbgjMUcYIB 5nLY5XVYaJ/5CPG0AO91T3foGPgjjwRH0RstIRPw9idpbUQs+RTFQwHm8r39++EcViC3 ++Sabiv1YaT3DvrZjj06baIPGd1UUa8oLLMUE1L/ZA4Vayr9KVuQenQ2aGoezCZtw9N6 A0BGKVjKTBB/KIT6hcTC54Sv77ITwh3UJt+LrWIfwo+dWbH9SPSe3xuvyKw22Kb6xDEG S+U6AuVXFG393uP+h13XzDAycQQcilzgGEDnpHkXGD8HxypwU9JSNkKdUyizkl877Umk he7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=yrlKsPsvHohGKzXyxDfBj89kPrRx4DIfuRD1yRJu1/E=; b=DaEyxkapzUxlgqvywuPZN5W9M2xieWs4dnHJPMJha/Fl8QIQ6fy072ndCSgfdzDNoa JJ+DiC6SJA/I0acuUVOEqbn7BCFoFgRYAcaIPB8JgqNYPRCnSiKbLFfTarQw8pJvJEml 1aOgIZB6OAHakrDbUzGukSB7ikvR4e3j0yX+gbjTZLkYPm4iuwH3pnTxoB9uWGASQV/m uLOm7F9FB5DrTXA/L5b22mM6fHaJmqHrIt/aDxEyYvALfe0jAE0v6Hsv52WdYL4BBVPF uGiAUs6ItOC1UpcaT1XaVjiwxdlVPB0xOKjtZYHWkuA8UhwIUiTCBoDKmiK9hYiD7wZb PFwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si7474133ejw.748.2020.08.02.22.23.12; Sun, 02 Aug 2020 22:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728207AbgHCFUe (ORCPT + 99 others); Mon, 3 Aug 2020 01:20:34 -0400 Received: from mga07.intel.com ([134.134.136.100]:16928 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727920AbgHCFUd (ORCPT ); Mon, 3 Aug 2020 01:20:33 -0400 IronPort-SDR: DepvX4jTl6lBiPKW0fRxhn2ySICn7HRt7ccBCJk+5+AeIRUITP9qTNNQl/m6d4ovS+L2Wq0em6 s88VMdUlnTBQ== X-IronPort-AV: E=McAfee;i="6000,8403,9701"; a="216472214" X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="216472214" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2020 22:20:32 -0700 IronPort-SDR: Q4wqFp6NHlXuXQJz/1u4ACuBKdO7iqNqFIYE446SgNcM7iR/d/jzaKrY5zPk3IbBbdo7/GpsCn qDO+PvICOLHg== X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="329890662" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2020 22:20:32 -0700 Subject: [PATCH v4 20/23] device-dax: Make align a per-device property From: Dan Williams To: akpm@linux-foundation.org Cc: Joao Martins , peterz@infradead.org, vishal.l.verma@intel.com, dave.hansen@linux.intel.com, ard.biesheuvel@linaro.org, vishal.l.verma@intel.com, linux-mm@kvack.org, linux-nvdimm@lists.01.org, joao.m.martins@oracle.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Sun, 02 Aug 2020 22:04:13 -0700 Message-ID: <159643105377.4062302.4159447829955683131.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <159643094279.4062302.17779410714418721328.stgit@dwillia2-desk3.amr.corp.intel.com> References: <159643094279.4062302.17779410714418721328.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joao Martins Introduce @align to struct dev_dax. When creating a new device, we still initialize to the default dax_region @align. Child devices belonging to a region may wish to keep a different alignment property instead of a global region-defined one. Signed-off-by: Joao Martins Link: https://lore.kernel.org/r/20200716172913.19658-2-joao.m.martins@oracle.com Signed-off-by: Dan Williams --- drivers/dax/bus.c | 1 + drivers/dax/dax-private.h | 3 +++ drivers/dax/device.c | 37 +++++++++++++++---------------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 2779c65dc7c0..9edfdf83408e 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1215,6 +1215,7 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) dev_dax->dax_dev = dax_dev; dev_dax->target_node = dax_region->target_node; + dev_dax->align = dax_region->align; ida_init(&dev_dax->ida); kref_get(&dax_region->kref); diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h index 13780f62b95e..5fd3a26cfcea 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -62,6 +62,7 @@ struct dax_mapping { struct dev_dax { struct dax_region *region; struct dax_device *dax_dev; + unsigned int align; int target_node; int id; struct ida ida; @@ -84,4 +85,6 @@ static inline struct dax_mapping *to_dax_mapping(struct device *dev) { return container_of(dev, struct dax_mapping, dev); } + +phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, unsigned long size); #endif diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 2bfc5c83e3b0..d2b1892cb1b2 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -17,7 +17,6 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, const char *func) { - struct dax_region *dax_region = dev_dax->region; struct device *dev = &dev_dax->dev; unsigned long mask; @@ -32,7 +31,7 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, return -EINVAL; } - mask = dax_region->align - 1; + mask = dev_dax->align - 1; if (vma->vm_start & mask || vma->vm_end & mask) { dev_info_ratelimited(dev, "%s: %s: fail, unaligned vma (%#lx - %#lx, %#lx)\n", @@ -78,21 +77,19 @@ static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf, pfn_t *pfn) { struct device *dev = &dev_dax->dev; - struct dax_region *dax_region; phys_addr_t phys; unsigned int fault_size = PAGE_SIZE; if (check_vma(dev_dax, vmf->vma, __func__)) return VM_FAULT_SIGBUS; - dax_region = dev_dax->region; - if (dax_region->align > PAGE_SIZE) { + if (dev_dax->align > PAGE_SIZE) { dev_dbg(dev, "alignment (%#x) > fault size (%#x)\n", - dax_region->align, fault_size); + dev_dax->align, fault_size); return VM_FAULT_SIGBUS; } - if (fault_size != dax_region->align) + if (fault_size != dev_dax->align) return VM_FAULT_SIGBUS; phys = dax_pgoff_to_phys(dev_dax, vmf->pgoff, PAGE_SIZE); @@ -120,15 +117,15 @@ static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, return VM_FAULT_SIGBUS; dax_region = dev_dax->region; - if (dax_region->align > PMD_SIZE) { + if (dev_dax->align > PMD_SIZE) { dev_dbg(dev, "alignment (%#x) > fault size (%#x)\n", - dax_region->align, fault_size); + dev_dax->align, fault_size); return VM_FAULT_SIGBUS; } - if (fault_size < dax_region->align) + if (fault_size < dev_dax->align) return VM_FAULT_SIGBUS; - else if (fault_size > dax_region->align) + else if (fault_size > dev_dax->align) return VM_FAULT_FALLBACK; /* if we are outside of the VMA */ @@ -164,15 +161,15 @@ static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, return VM_FAULT_SIGBUS; dax_region = dev_dax->region; - if (dax_region->align > PUD_SIZE) { + if (dev_dax->align > PUD_SIZE) { dev_dbg(dev, "alignment (%#x) > fault size (%#x)\n", - dax_region->align, fault_size); + dev_dax->align, fault_size); return VM_FAULT_SIGBUS; } - if (fault_size < dax_region->align) + if (fault_size < dev_dax->align) return VM_FAULT_SIGBUS; - else if (fault_size > dax_region->align) + else if (fault_size > dev_dax->align) return VM_FAULT_FALLBACK; /* if we are outside of the VMA */ @@ -267,9 +264,8 @@ static int dev_dax_split(struct vm_area_struct *vma, unsigned long addr) { struct file *filp = vma->vm_file; struct dev_dax *dev_dax = filp->private_data; - struct dax_region *dax_region = dev_dax->region; - if (!IS_ALIGNED(addr, dax_region->align)) + if (!IS_ALIGNED(addr, dev_dax->align)) return -EINVAL; return 0; } @@ -278,9 +274,8 @@ static unsigned long dev_dax_pagesize(struct vm_area_struct *vma) { struct file *filp = vma->vm_file; struct dev_dax *dev_dax = filp->private_data; - struct dax_region *dax_region = dev_dax->region; - return dax_region->align; + return dev_dax->align; } static const struct vm_operations_struct dax_vm_ops = { @@ -319,13 +314,11 @@ static unsigned long dax_get_unmapped_area(struct file *filp, { unsigned long off, off_end, off_align, len_align, addr_align, align; struct dev_dax *dev_dax = filp ? filp->private_data : NULL; - struct dax_region *dax_region; if (!dev_dax || addr) goto out; - dax_region = dev_dax->region; - align = dax_region->align; + align = dev_dax->align; off = pgoff << PAGE_SHIFT; off_end = off + len; off_align = round_up(off, align);