Re: [PATCH] arc: Implement arch-specific dma_map_ops.mmap

2016-11-02 Thread Catalin Marinas
On Wed, Nov 02, 2016 at 03:19:43PM +0300, Alexey Brodkin wrote:
> diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
> index 20afc65e22dc..034ec6a8a764 100644
> --- a/arch/arc/mm/dma.c
> +++ b/arch/arc/mm/dma.c
> @@ -105,6 +105,31 @@ static void arc_dma_free(struct device *dev, size_t 
> size, void *vaddr,
>   __free_pages(page, get_order(size));
>  }
>  
> +static int arc_dma_mmap(struct device *dev, struct vm_area_struct *vma,
> + void *cpu_addr, dma_addr_t dma_addr, size_t size,
> + unsigned long attrs)
> +{
> + unsigned long user_count = vma_pages(vma);
> + unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
> + unsigned long pfn = __phys_to_pfn(dma_addr);

I don't think that's correct in all situations. Better as (for arc):

unsigned long pfn = __phys_to_pfn(plat_dma_to_phys(dma_addr));

Other than that:

Reviewed-by: Catalin Marinas 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2] drm/arcpgu: Accommodate adv7511 switch to DRM bridge

2016-11-02 Thread Alexey Brodkin
Hi Daniel, David,

On Mon, 2016-10-24 at 18:33 +, Alexey Brodkin wrote:
> Hi Daniel,
> 
> > 
> > -Original Message-
> > From: linux-snps-arc [mailto:linux-snps-arc-boun...@lists.infradead.org] On 
> > Behalf Of Alexey Brodkin
> > Sent: 19 октября 2016 г. 12:33
> > To: dri-de...@lists.freedesktop.org; arch...@codeaurora.org; 
> > eugeniy.palt...@synopsys.com
> > Cc: linux-snps-arc@lists.infradead.org; linux-ker...@vger.kernel.org
> > Subject: Re: [PATCH v2] drm/arcpgu: Accommodate adv7511 switch to DRM bridge
> > 
> > Hi Archit, all,
> > 
> > On Wed, 2016-10-19 at 14:43 +0530, Archit Taneja wrote:
> > > 
> > > 
> > > On 10/19/2016 01:16 PM, Eugeniy Paltsev wrote:
> > > > 
> > > > 
> > > > ARC PGU driver starts crashing on initialization after
> > > > 'commit e12c2f645557 ("drm/i2c: adv7511: Convert to drm_bridge")'
> > > > This happenes because in "arcpgu_drm_hdmi_init" function we get pointer
> > > > of "drm_i2c_encoder_driver" structure, which doesn't exist after
> > > > adv7511 hdmi encoder interface changed from slave encoder to drm bridge.
> > > > So, when we call "encoder_init" function from this structure driver
> > > > crashes.
> > 
> > [snip]
> > 
> > > 
> > > Looks good now.
> > > 
> > > Reviewed-by: Archit Taneja 
> > 
> > And IMHO it would be really good to get this one back-ported to 4.8
> > because it really fixes kernel crash if ARC PGU driver is used.
> > 
> > It might be a bit of a problem because patch itself a little-bit larger
> > than formal requirement for stable backports but let's see if it gets 
> > accepted.
> 
> Could you please pick this one up?
> I may alternatively send a pull-request to David but not sure if 1 patch 
> worth it.
> 
> Also if that's not really too late it would be good to get this one in 4.9 
> since the patch
> In question fixes a real driver crash on its instantiation.
> Actually driver crash happens since 4.8 but I failed to notice it earlier and 
> given amount
> of changes I think there's barely a chance for it it to be accepted in stable 
> branches...
> which in its turn makes at least 4.9 very desirable.

Any chance this one gets accepted anytime soon?

Regards,
Alexey
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

[PATCH] arc: Implement arch-specific dma_map_ops.mmap

2016-11-02 Thread Alexey Brodkin
We used to use generic implementation of dma_map_ops.mmap which is
dma_common_mmap() but that only worked for simpler cached mappings when
vaddr = paddr.

If a driver requests uncached DMA buffer kernel maps it to virtual
address so that MMU gets involved and page uncached status takes into
account. In that case usage of dma_common_mmap() lead to mapping of
vaddr to vaddr for user-space which is obviously wrong. For more detals
please refer to verbose explanation here [1].

So here we implement our own version of mmap() which always deals
with dma_addr and maps underlying memory to user-space properly
(note that DMA buffer mapped to user-space is always uncached
because there's no way to properly manage cache from user-space).

[1] https://lkml.org/lkml/2016/10/26/973

Signed-off-by: Alexey Brodkin 
Cc: Catalin Marinas 
Cc: Marek Szyprowski 
Cc: sta...@vger.kernel.org
---
 arch/arc/mm/dma.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
index 20afc65e22dc..034ec6a8a764 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -105,6 +105,31 @@ static void arc_dma_free(struct device *dev, size_t size, 
void *vaddr,
__free_pages(page, get_order(size));
 }
 
+static int arc_dma_mmap(struct device *dev, struct vm_area_struct *vma,
+   void *cpu_addr, dma_addr_t dma_addr, size_t size,
+   unsigned long attrs)
+{
+   unsigned long user_count = vma_pages(vma);
+   unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
+   unsigned long pfn = __phys_to_pfn(dma_addr);
+   unsigned long off = vma->vm_pgoff;
+   int ret = -ENXIO;
+
+   vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+   if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, ))
+   return ret;
+
+   if (off < count && user_count <= (count - off)) {
+   ret = remap_pfn_range(vma, vma->vm_start,
+ pfn + off,
+ user_count << PAGE_SHIFT,
+ vma->vm_page_prot);
+   }
+
+   return ret;
+}
+
 /*
  * streaming DMA Mapping API...
  * CPU accesses page via normal paddr, thus needs to explicitly made
@@ -193,6 +218,7 @@ static int arc_dma_supported(struct device *dev, u64 
dma_mask)
 struct dma_map_ops arc_dma_ops = {
.alloc  = arc_dma_alloc,
.free   = arc_dma_free,
+   .mmap   = arc_dma_mmap,
.map_page   = arc_dma_map_page,
.map_sg = arc_dma_map_sg,
.sync_single_for_device = arc_dma_sync_single_for_device,
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v3 0/3] dmaengine: DW DMAC: split pdata to hardware properties

2016-11-02 Thread Eugeniy Paltsev
Hi Andy,
Could you possibly tell me your ideas about these changes?
Thanks.

On Fri, 2016-10-28 at 18:59 +0300, Eugeniy Paltsev wrote:
> This series is to address a proposal by Andy in these threads:
> http://www.spinics.net/lists/dmaengine/msg11506.html
> http://www.spinics.net/lists/dmaengine/msg11541.html
> Split platform data to actual hardware properties, and platform
> quirks.
> Now we able to use quirks and hardware properties separately from
> different sources (pdata, device tree or autoconfig registers)
> 
> Changes for v3:
>  -   Split changes to separate patches.
>  -   Add "DW_DMA_IS_LLP_SUPPORTED" flag and get rid of "dwc->nollp"
>  as separate variable.
>  -   Make "dw_dma_slave" documentation comments more clear about
> quirks.
>  "is_memcpy" and "is_private" are quirks, "is_nollp" is regular 
>  pdata property.
> 
> Eugeniy Paltsev (3):
>   dmaengine: DW DMAC: split pdata to hardware properties and platform
> quirks
>   dmaengine: DW DMAC: convert to unified device property API
>   dmaengine: DW DMAC: move "nollp" to "dwc->flags"
> 
>  drivers/dma/dw/core.c| 34 +--
>  drivers/dma/dw/platform.c| 53 +++---
> --
>  drivers/dma/dw/regs.h|  2 +-
>  include/linux/platform_data/dma-dw.h |  5 
>  4 files changed, 54 insertions(+), 40 deletions(-)
> 
-- 
 Paltsev Eugeniy
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc