linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mike Campin <campin@pobox.com>
To: linux-arm-kernel@lists.infradead.org
Subject: Unable to map uncached buffer for PCI DMA to userspace on Cortex-A53
Date: Mon, 7 Oct 2019 08:26:22 -0700	[thread overview]
Message-ID: <20191007152622.GA15000@localhost> (raw)

I've been trying for several days to map an uncached buffer for PCI DMA in
userspace without luck. The only way I can get the DMA transfer to work is
to wrap it with __builtin___clear_cache().

Details.
  - 96boards SC2A11 with Cortex-A53 with my device plugged into a PCIe slot.
  - Kernel 5.2.13-200.fc30.aarch64 (Fedora 30).
  - /proc/cmdline 
      BOOT_IMAGE=(hd1,gpt2)/vmlinuz-5.2.13-200.fc30.aarch64 root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap
  - Simplified code:
      init_dma_attrs(&attrs);
      dma_set_attr(DMA_ATTR_FORCE_CONTIGUOUS,  &attrs);
      dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs);
      dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
      vaddr = dma_alloc_attrs(dev, size, &iaddr, GFP_KERNEL | __GFP_ZERO, &attrs);
 
      vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
      dma_mmap_attrs(dev, vma, vaddr, iaddr, size, &attrs);

I've tried several permutations. Here's a few examples:
  - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
  - vma->vm_flags |= VM_IO;
  - With and without DMA_ATTR_NO_KERNEL_MAPPING.
  - remap_pfn_range(vma, vma->vm_start, iaddr >> PAGE_SHIFT, size, vma->vm_page_prot);
  - dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
  - Even tried using get_arch_dma_ops() to get a pointer to arm_dma_ops.

-- 
Mike Campin
arm at timequake dot net

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

                 reply	other threads:[~2019-10-07 15:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191007152622.GA15000@localhost \
    --to=campin@pobox.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).