diff mbox series

[v3,20/23] device-dax: Make align a per-device property

Message ID 159625241066.3040297.5565166696242815434.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show
Series device-dax: Support sub-dividing soft-reserved ranges | expand

Commit Message

Dan Williams Aug. 1, 2020, 3:26 a.m. UTC
From: Joao Martins <joao.m.martins@oracle.com>

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 <joao.m.martins@oracle.com>
Link: https://lore.kernel.org/r/20200716172913.19658-2-joao.m.martins@oracle.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/dax/bus.c         |    1 +
 drivers/dax/dax-private.h |    1 +
 drivers/dax/device.c      |   35 +++++++++++++++--------------------
 3 files changed, 17 insertions(+), 20 deletions(-)

Comments

kernel test robot Aug. 1, 2020, 7:23 a.m. UTC | #1
Hi Dan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on 01830e6c042e8eb6eb202e05d7df8057135b4c26]

url:    https://github.com/0day-ci/linux/commits/Dan-Williams/device-dax-Support-sub-dividing-soft-reserved-ranges/20200801-114823
base:    01830e6c042e8eb6eb202e05d7df8057135b4c26
config: s390-allyesconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=s390 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/dax/device.c:54:20: warning: no previous prototype for 'dax_pgoff_to_phys' [-Wmissing-prototypes]
      54 | __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
         |                    ^~~~~~~~~~~~~~~~~
   drivers/dax/device.c: In function '__dev_dax_pte_fault':
>> drivers/dax/device.c:80:21: warning: variable 'dax_region' set but not used [-Wunused-but-set-variable]
      80 |  struct dax_region *dax_region;
         |                     ^~~~~~~~~~
   drivers/dax/device.c: In function '__dev_dax_pmd_fault':
   drivers/dax/device.c:113:21: warning: variable 'dax_region' set but not used [-Wunused-but-set-variable]
     113 |  struct dax_region *dax_region;
         |                     ^~~~~~~~~~
   drivers/dax/device.c: At top level:
   drivers/dax/device.c:397:5: warning: no previous prototype for 'dev_dax_probe' [-Wmissing-prototypes]
     397 | int dev_dax_probe(struct dev_dax *dev_dax)
         |     ^~~~~~~~~~~~~

vim +/dax_region +80 drivers/dax/device.c

dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   52  
efebc711180f7fe drivers/dax/dax.c    Dave Jiang   2017-04-07   53  /* see "strong" declaration in tools/testing/nvdimm/dax-dev.c */
736163671bcb163 drivers/dax/device.c Dan Williams 2017-05-04  @54  __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   55  		unsigned long size)
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   56  {
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   57  	int i;
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   58  
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   59  	for (i = 0; i < dev_dax->nr_range; i++) {
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   60  		struct dev_dax_range *dax_range = &dev_dax->ranges[i];
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   61  		struct range *range = &dax_range->range;
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   62  		unsigned long long pgoff_end;
753a0850e707e9a drivers/dax/device.c Dan Williams 2017-07-14   63  		phys_addr_t phys;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   64  
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   65  		pgoff_end = dax_range->pgoff + PHYS_PFN(range_len(range)) - 1;
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   66  		if (pgoff < dax_range->pgoff || pgoff > pgoff_end)
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   67  			continue;
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   68  		phys = PFN_PHYS(pgoff - dax_range->pgoff) + range->start;
e8f1f803fc7e653 drivers/dax/device.c Dan Williams 2020-07-31   69  		if (phys + size - 1 <= range->end)
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   70  			return phys;
4d3c109cf2a8406 drivers/dax/device.c Dan Williams 2020-07-31   71  		break;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   72  	}
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   73  	return -1;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   74  }
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   75  
226ab561075f6f8 drivers/dax/device.c Dan Williams 2018-07-13   76  static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax,
2232c6382a453db drivers/dax/device.c Dan Williams 2018-07-13   77  				struct vm_fault *vmf, pfn_t *pfn)
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   78  {
5f0694b300b9fb8 drivers/dax/dax.c    Dan Williams 2017-01-30   79  	struct device *dev = &dev_dax->dev;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14  @80  	struct dax_region *dax_region;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   81  	phys_addr_t phys;
0134ed4fb9e7867 drivers/dax/dax.c    Dave Jiang   2017-03-10   82  	unsigned int fault_size = PAGE_SIZE;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   83  
5f0694b300b9fb8 drivers/dax/dax.c    Dan Williams 2017-01-30   84  	if (check_vma(dev_dax, vmf->vma, __func__))
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   85  		return VM_FAULT_SIGBUS;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   86  
5f0694b300b9fb8 drivers/dax/dax.c    Dan Williams 2017-01-30   87  	dax_region = dev_dax->region;
58e646f2ce61dc9 drivers/dax/device.c Joao Martins 2020-07-31   88  	if (dev_dax->align > PAGE_SIZE) {
6daaca522ab464d drivers/dax/device.c Dan Williams 2018-03-05   89  		dev_dbg(dev, "alignment (%#x) > fault size (%#x)\n",
58e646f2ce61dc9 drivers/dax/device.c Joao Martins 2020-07-31   90  			dev_dax->align, fault_size);
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   91  		return VM_FAULT_SIGBUS;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   92  	}
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   93  
58e646f2ce61dc9 drivers/dax/device.c Joao Martins 2020-07-31   94  	if (fault_size != dev_dax->align)
0134ed4fb9e7867 drivers/dax/dax.c    Dave Jiang   2017-03-10   95  		return VM_FAULT_SIGBUS;
0134ed4fb9e7867 drivers/dax/dax.c    Dave Jiang   2017-03-10   96  
736163671bcb163 drivers/dax/device.c Dan Williams 2017-05-04   97  	phys = dax_pgoff_to_phys(dev_dax, vmf->pgoff, PAGE_SIZE);
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14   98  	if (phys == -1) {
6daaca522ab464d drivers/dax/device.c Dan Williams 2018-03-05   99  		dev_dbg(dev, "pgoff_to_phys(%#lx) failed\n", vmf->pgoff);
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14  100  		return VM_FAULT_SIGBUS;
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14  101  	}
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14  102  
e651e2e797b48fb drivers/dax/device.c Dan Williams 2020-07-31  103  	*pfn = phys_to_pfn_t(phys, PFN_DEV|PFN_MAP);
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14  104  
2232c6382a453db drivers/dax/device.c Dan Williams 2018-07-13  105  	return vmf_insert_mixed(vmf->vma, vmf->address, *pfn);
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14  106  }
dee410792419aaa drivers/dax/dax.c    Dan Williams 2016-05-14  107  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index ffb27964deb2..feca1413481c 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..96ef5a8ae0ba 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;
diff --git a/drivers/dax/device.c b/drivers/dax/device.c
index 2bfc5c83e3b0..346c7bb8cf06 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",
@@ -86,13 +85,13 @@  static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax,
 		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 +119,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 +163,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 +266,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 +276,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 +316,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);