Skip to contentSkip to conversation

linux-next: manual merge of the sparc-next tree with the dma-mapping tree

DISCUSSION Stephen Rothwell 4 participants 5 messages Dec 11, 2018 – Dec 12, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

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

arch/sparc/kernel/ioport.c

between commit:

53b7670e5735 ("sparc: factor the dma coherent mapping into helper")

from the dma-mapping tree and commit:

86ef771ed543 ("sparc: Use DT node full_name instead of name for resources")

from the sparc-next tree.

I fixed it up (see below - the resolution looks more complex than it is) 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.

Signature · 131 lines
Cheers,
Stephen Rothwell

diff --cc arch/sparc/kernel/ioport.c
index 51c128d80193,aeaad04fdd14..000000000000
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@@ -245,46 -247,97 +245,46 @@@ static void _sparc_free_io(struct resou
  	release_resource(res);
  }
  
 -#ifdef CONFIG_SBUS
 -
 -void sbus_set_sbus64(struct device *dev, int x)
 -{
 -	printk("sbus_set_sbus64: unsupported\n");
 -}
 -EXPORT_SYMBOL(sbus_set_sbus64);
 -
 -/*
 - * Allocate a chunk of memory suitable for DMA.
 - * Typically devices use them for control blocks.
 - * CPU may access them without any explicit flushing.
 - */
 -static void *sbus_alloc_coherent(struct device *dev, size_t len,
 -				 dma_addr_t *dma_addrp, gfp_t gfp,
 -				 unsigned long attrs)
 +unsigned long sparc_dma_alloc_resource(struct device *dev, size_t len)
  {
 -	struct platform_device *op = to_platform_device(dev);
 -	unsigned long len_total = PAGE_ALIGN(len);
 -	unsigned long va;
  	struct resource *res;
 -	int order;
 -
 -	/* XXX why are some lengths signed, others unsigned? */
 -	if (len <= 0) {
 -		return NULL;
 -	}
 -	/* XXX So what is maxphys for us and how do drivers know it? */
 -	if (len > 256*1024) {			/* __get_free_pages() limit */
 -		return NULL;
 -	}
 -
 -	order = get_order(len_total);
 -	va = __get_free_pages(gfp, order);
 -	if (va == 0)
 -		goto err_nopages;
  
 -	if ((res = kzalloc(sizeof(struct resource), GFP_KERNEL)) == NULL)
 -		goto err_nomem;
 +	res = kzalloc(sizeof(*res), GFP_KERNEL);
 +	if (!res)
 +		return 0;
- 	res->name = dev->of_node->name;
++	res->name = dev->of_node->full_name;
  
 -	if (allocate_resource(&_sparc_dvma, res, len_total,
 -	    _sparc_dvma.start, _sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) {
 -		printk("sbus_alloc_consistent: cannot occupy 0x%lx", len_total);
 -		goto err_nova;
 +	if (allocate_resource(&_sparc_dvma, res, len, _sparc_dvma.start,
 +			      _sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) {
 +		printk("%s: cannot occupy 0x%zx", __func__, len);
 +		kfree(res);
 +		return 0;
  	}
  
 -	// XXX The sbus_map_dma_area does this for us below, see comments.
 -	// srmmu_mapiorange(0, virt_to_phys(va), res->start, len_total);
 -	/*
 -	 * XXX That's where sdev would be used. Currently we load
 -	 * all iommu tables with the same translations.
 -	 */
 -	if (sbus_map_dma_area(dev, dma_addrp, va, res->start, len_total) != 0)
 -		goto err_noiommu;
 -
 -	res->name = op->dev.of_node->full_name;
 -
 -	return (void *)(unsigned long)res->start;
 -
 -err_noiommu:
 -	release_resource(res);
 -err_nova:
 -	kfree(res);
 -err_nomem:
 -	free_pages(va, order);
 -err_nopages:
 -	return NULL;
 +	return res->start;
  }
  
 -static void sbus_free_coherent(struct device *dev, size_t n, void *p,
 -			       dma_addr_t ba, unsigned long attrs)
 +bool sparc_dma_free_resource(void *cpu_addr, size_t size)
  {
 +	unsigned long addr = (unsigned long)cpu_addr;
  	struct resource *res;
 -	struct page *pgv;
  
 -	if ((res = lookup_resource(&_sparc_dvma,
 -	    (unsigned long)p)) == NULL) {
 -		printk("sbus_free_consistent: cannot free %p\n", p);
 -		return;
 +	res = lookup_resource(&_sparc_dvma, addr);
 +	if (!res) {
 +		printk("%s: cannot free %p\n", __func__, cpu_addr);
 +		return false;
  	}
  
 -	if (((unsigned long)p & (PAGE_SIZE-1)) != 0) {
 -		printk("sbus_free_consistent: unaligned va %p\n", p);
 -		return;
 +	if ((addr & (PAGE_SIZE - 1)) != 0) {
 +		printk("%s: unaligned va %p\n", __func__, cpu_addr);
 +		return false;
  	}
  
 -	n = PAGE_ALIGN(n);
 -	if (resource_size(res) != n) {
 -		printk("sbus_free_consistent: region 0x%lx asked 0x%zx\n",
 -		    (long)resource_size(res), n);
 -		return;
 +	size = PAGE_ALIGN(size);
 +	if (resource_size(res) != size) {
 +		printk("%s: region 0x%lx asked 0x%zx\n",
 +			__func__, (long)resource_size(res), size);
 +		return false;
  	}
  
  	release_resource(res);
#1 lore raw
Quoted 8 lines · Stephen Rothwell

Hi all,

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

arch/sparc/kernel/ioport.c

between commit:

Quoted 7 lines

53b7670e5735 ("sparc: factor the dma coherent mapping into helper")

from the dma-mapping tree and commit:

86ef771ed543 ("sparc: Use DT node full_name instead of name for resources")

from the sparc-next tree.

Dave, Sam:

should I just apply a version of Rob's tree that takes the refactoring into account to the dma-mapping tree? That way we should get the right result independent of the merge order.

#2 lore raw
Quoted 5 lines · Christoph Hellwig

Dave, Sam:

should I just apply a version of Rob's tree that takes the refactoring into account to the dma-mapping tree? That way we should get the right result independent of the merge order.

E.g. something like the patch below:

--

Quoted 1 line

From 6ee3d6c39a0c8bc4b58fa601bb4370bdec785be7 Mon Sep 17 00:00:00 2001

From: Christoph Hellwig <[email protected]>
Date: Wed, 12 Dec 2018 17:09:58 +0100
Subject: sparc: use DT node full_name in sparc_dma_alloc_resource

The sparc tree already has this change for the pre-refactored code, but pulling it into the dma-mapping tree like this should ease the merge conflicts a bit.

---
 arch/sparc/kernel/ioport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/ioport.c +1 -1
index 51c128d80193..baa235652c27 100644
@@ -252,7 +252,7 @@ unsigned long sparc_dma_alloc_resource(struct device *dev, size_t len)
 	res = kzalloc(sizeof(*res), GFP_KERNEL);
 	if (!res)
 		return 0;
-	res->name = dev->of_node->name;
+	res->name = dev->of_node->full_name;
 
 	if (allocate_resource(&_sparc_dvma, res, len, _sparc_dvma.start,
 			      _sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) {
Signature · 1 line
2.19.2
#3 lore raw
Quoted 29 lines · Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

Dave, Sam:

should I just apply a version of Rob's tree that takes the refactoring into account to the dma-mapping tree? That way we should get the right result independent of the merge order.

E.g. something like the patch below:

--

Quoted 1 line

From 6ee3d6c39a0c8bc4b58fa601bb4370bdec785be7 Mon Sep 17 00:00:00 2001

From: Christoph Hellwig <[email protected]>
Date: Wed, 12 Dec 2018 17:09:58 +0100
Subject: sparc: use DT node full_name in sparc_dma_alloc_resource

The sparc tree already has this change for the pre-refactored code, but pulling it into the dma-mapping tree like this should ease the merge conflicts a bit.

---
 arch/sparc/kernel/ioport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/ioport.c +0 -0
index 51c128d80193..baa235652c27 100644

arch/sparc/kernel/ioport.c unsigned long sparc_dma_alloc_resource(struct device *dev, size_t len) · line 258

Quoted 8 lines
arch/sparc/kernel/ioport.c +1 -1
@@ -252,7 +252,7 @@ unsigned long sparc_dma_alloc_resource(struct device *dev, size_t len)
 	res = kzalloc(sizeof(*res), GFP_KERNEL);
 	if (!res)
 		return 0;
-	res->name = dev->of_node->name;
+	res->name = dev->of_node->full_name;
 
 	if (allocate_resource(&_sparc_dvma, res, len, _sparc_dvma.start,
 			      _sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) {

Whatever works best for everyone is fine for me, so ack from me.

Sam

maintainer
#4 lore raw

From: Sam Ravnborg <[email protected]>
Date: Wed, 12 Dec 2018 17:32:08 +0100

Quoted 36 lines · Christoph Hellwig
Quoted 35 lines · Christoph Hellwig
Quoted 5 lines

Dave, Sam:

should I just apply a version of Rob's tree that takes the refactoring into account to the dma-mapping tree? That way we should get the right result independent of the merge order.

E.g. something like the patch below:

--

Quoted 1 line

From 6ee3d6c39a0c8bc4b58fa601bb4370bdec785be7 Mon Sep 17 00:00:00 2001

From: Christoph Hellwig <[email protected]>
Date: Wed, 12 Dec 2018 17:09:58 +0100
Subject: sparc: use DT node full_name in sparc_dma_alloc_resource

The sparc tree already has this change for the pre-refactored code, but pulling it into the dma-mapping tree like this should ease the merge conflicts a bit.

---
 arch/sparc/kernel/ioport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/ioport.c +1 -1
index 51c128d80193..baa235652c27 100644
@@ -252,7 +252,7 @@ unsigned long sparc_dma_alloc_resource(struct device *dev, size_t len)
 	res = kzalloc(sizeof(*res), GFP_KERNEL);
 	if (!res)
 		return 0;
-	res->name = dev->of_node->name;
+	res->name = dev->of_node->full_name;
 
Quoted 4 lines

arch/sparc/kernel/ioport.c unsigned long sparc_dma_alloc_resource(struct device *dev, size_t len) · line 258

Quoted 2 lines
arch/sparc/kernel/ioport.c +0 -0
 	if (allocate_resource(&_sparc_dvma, res, len, _sparc_dvma.start,
 			      _sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) {

Whatever works best for everyone is fine for me, so ack from me.

Yeah I'm fine with this too.