Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-05 Thread Jim Quinlan via iommu
On Fri, Jun 5, 2020 at 1:27 PM Nicolas Saenz Julienne wrote: > > Hi Christoph, > a question arouse, is there a real value to dealing with PFNs (as opposed to > real addresses) in the core DMA code/structures? I see that in some cases it > eases interacting with mm, but the overwhelming usage of sa

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-05 Thread Nicolas Saenz Julienne
Hi Christoph, a question arouse, is there a real value to dealing with PFNs (as opposed to real addresses) in the core DMA code/structures? I see that in some cases it eases interacting with mm, but the overwhelming usage of say, dev->dma_pfn_offset, involves shifting it. Hi Jim, On Thu, 2020-06-0

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Jim Quinlan via iommu
Hi Nicolas, On Thu, Jun 4, 2020 at 12:52 PM Nicolas Saenz Julienne wrote: > > Hi Jim, > > On Thu, 2020-06-04 at 10:35 -0400, Jim Quinlan wrote: > > [...] > > > > > --- a/arch/sh/kernel/dma-coherent.c > > > > +++ b/arch/sh/kernel/dma-coherent.c > > > > @@ -14,6 +14,8 @@ void *arch_dma_alloc(struct

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Nicolas Saenz Julienne
Hi Jim, On Thu, 2020-06-04 at 10:35 -0400, Jim Quinlan wrote: [...] > > > --- a/arch/sh/kernel/dma-coherent.c > > > +++ b/arch/sh/kernel/dma-coherent.c > > > @@ -14,6 +14,8 @@ void *arch_dma_alloc(struct device *dev, size_t size, > > > dma_addr_t *dma_handle, > > > { > > > void *ret, *ret

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Jim Quinlan via iommu
Hi Andy, On Thu, Jun 4, 2020 at 11:05 AM Andy Shevchenko wrote: > > On Thu, Jun 04, 2020 at 10:35:12AM -0400, Jim Quinlan wrote: > > On Thu, Jun 4, 2020 at 9:53 AM Nicolas Saenz Julienne > > wrote: > > > On Wed, 2020-06-03 at 15:20 -0400, Jim Quinlan wrote: > > ... > > > > > + phys = virt_to

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Andy Shevchenko
On Thu, Jun 04, 2020 at 10:35:12AM -0400, Jim Quinlan wrote: > On Thu, Jun 4, 2020 at 9:53 AM Nicolas Saenz Julienne > wrote: > > On Wed, 2020-06-03 at 15:20 -0400, Jim Quinlan wrote: ... > > > + phys = virt_to_phys(ret); > > > + pfn = phys >> PAGE_SHIFT; > > > > nit: not sure it really

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Jim Quinlan via iommu
On Thu, Jun 4, 2020 at 10:20 AM Dan Carpenter wrote: > > On Thu, Jun 04, 2020 at 09:48:49AM -0400, Jim Quinlan wrote: > > > > + r = devm_kcalloc(dev, 1, sizeof(struct dma_pfn_offset_region), > > > > + GFP_KERNEL); > > > > > > Use:r = devm_kzalloc(dev, sizeof(*r), GFP_K

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Jim Quinlan via iommu
On Thu, Jun 4, 2020 at 9:53 AM Nicolas Saenz Julienne wrote: > > Hi Jim, > > On Wed, 2020-06-03 at 15:20 -0400, Jim Quinlan wrote: > > The new field in struct device 'dma_pfn_offset_map' is used to facilitate > > the use of multiple pfn offsets between cpu addrs and dma addrs. It > > subsumes the

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Dan Carpenter
On Thu, Jun 04, 2020 at 09:48:49AM -0400, Jim Quinlan wrote: > > > + r = devm_kcalloc(dev, 1, sizeof(struct dma_pfn_offset_region), > > > + GFP_KERNEL); > > > > Use:r = devm_kzalloc(dev, sizeof(*r), GFP_KERNEL); > Will fix. > > > > > > > > + if (!r) > > > +

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Nicolas Saenz Julienne
Hi Jim, On Wed, 2020-06-03 at 15:20 -0400, Jim Quinlan wrote: > The new field in struct device 'dma_pfn_offset_map' is used to facilitate > the use of multiple pfn offsets between cpu addrs and dma addrs. It > subsumes the role of dev->dma_pfn_offset -- a uniform offset -- and > designates the si

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Jim Quinlan via iommu
Hi Dan, On Thu, Jun 4, 2020 at 7:06 AM Dan Carpenter wrote: > > On Wed, Jun 03, 2020 at 03:20:41PM -0400, Jim Quinlan wrote: > > @@ -786,7 +787,7 @@ static int sun4i_backend_bind(struct device *dev, > > struct device *master, > > const struct sun4i_backend_quirks *quirks; > > struct

Re: [PATCH v3 09/13] device core: Introduce multiple dma pfn offsets

2020-06-04 Thread Dan Carpenter
On Wed, Jun 03, 2020 at 03:20:41PM -0400, Jim Quinlan wrote: > @@ -786,7 +787,7 @@ static int sun4i_backend_bind(struct device *dev, struct > device *master, > const struct sun4i_backend_quirks *quirks; > struct resource *res; > void __iomem *regs; > - int i, ret; > + int