Subject: linux-next: manual merge of the akpm-current tree with Linus' tree

From: Stephen Rothwell <[email-masked]>
Date: Tue, 8 Sep 2020 19:24:10 +1000

Hi all,

Today's linux-next merge of the akpm-current tree got a conflict in:

  drivers/dax/device.c

between commit:

  4533d3aed857 ("memremap: rename MEMORY_DEVICE_DEVDAX to MEMORY_DEVICE_GENERIC")

from Linus' tree and commit:

  ceb1b473719c ("device-dax: make pgmap optional for instance creation")

from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/dax/device.c
index 1e89513f3c59,cc1f4ce185bf..000000000000
--- a/drivers/dax/device.c
+++ b/drivers/dax/device.c
@@@ -420,17 -396,37 +396,37 @@@ int dev_dax_probe(struct dev_dax *dev_d
  	struct inode *inode;
  	struct cdev *cdev;
  	void *addr;
- 	int rc;
+ 	int rc, i;
  
- 	/* 1:1 map region resource range to device-dax instance range */
- 	if (!devm_request_mem_region(dev, res->start, resource_size(res),
- 				dev_name(dev))) {
- 		dev_warn(dev, "could not reserve region %pR\n", res);
- 		return -EBUSY;
+ 	pgmap = dev_dax->pgmap;
+ 	if (dev_WARN_ONCE(dev, pgmap && dev_dax->nr_range > 1,
+ 			"static pgmap / multi-range device conflict\n"))
+ 		return -EINVAL;
+ 
+ 	if (!pgmap) {
+ 		pgmap = devm_kzalloc(dev, sizeof(*pgmap) + sizeof(struct range)
+ 				* (dev_dax->nr_range - 1), GFP_KERNEL);
+ 		if (!pgmap)
+ 			return -ENOMEM;
+ 		pgmap->nr_range = dev_dax->nr_range;
+ 	}
+ 
+ 	for (i = 0; i < dev_dax->nr_range; i++) {
+ 		struct range *range = &dev_dax->ranges[i].range;
+ 
+ 		if (!devm_request_mem_region(dev, range->start,
+ 					range_len(range), dev_name(dev))) {
+ 			dev_warn(dev, "mapping%d: %#llx-%#llx could not reserve range\n",
+ 					i, range->start, range->end);
+ 			return -EBUSY;
+ 		}
+ 		/* don't update the range for static pgmap */
+ 		if (!dev_dax->pgmap)
+ 			pgmap->ranges[i] = *range;
  	}
  
- 	dev_dax->pgmap.type = MEMORY_DEVICE_GENERIC;
- 	addr = devm_memremap_pages(dev, &dev_dax->pgmap);
 -	pgmap->type = MEMORY_DEVICE_DEVDAX;
++	pgmap->type = MEMORY_DEVICE_GENERIC;
+ 	addr = devm_memremap_pages(dev, pgmap);
  	if (IS_ERR(addr))
  		return PTR_ERR(addr);