All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniele Alessandrelli <daniele.alessandrelli@gmail.com>
To: Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>
Cc: iommu@lists.linux-foundation.org,
	Vladimir Murzin <vladimir.murzin@arm.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: [BUG] dma-ranges, reserved memory regions, dma_alloc_coherent: possible bug?
Date: Sun, 13 Oct 2019 15:28:28 +0100	[thread overview]
Message-ID: <CAA2QUqLv+eLXuA_TdJ7zM4oBnGoFVOjRjAimuct2y=0MDuaZVQ@mail.gmail.com> (raw)

Hi,

It looks like dma_alloc_coherent() is setting the dma_handle output
parameter to the memory physical address and not the device bus
address when the device is using reserved memory regions for DMA
allocation. This is despite using 'dma_ranges' in the device tree to
describe the DMA memory mapping. Is this expected behavior or a bug?

Here is a reduced version of the device tree I'm using:
\ {
        reserved-memory {
                #address-cells = <2>;
                #size-cells = <2>;
                ranges;
                mydev_rsvd: rsvd_mem@494800000 {
                        compatible = "shared-dma-pool";
                        reg = <0x4 0x94800000 0x0 0x200000>;
                        no-map;
                };
        };
        soc {
                compatible = "simple-bus";
                #address-cells = <2>;
                #size-cells = <2>;
                ranges;
                dma_ranges;

                mybus {
                        ranges = <>;
                        dma-ranges = <>;
                        compatible = "simple-bus";
                        #address-cells = <2>;
                        #size-cells = <2>;
                        ranges =     <0x0 0x0  0x0 0x0  0x0 0x80000000>;
                        dma-ranges = <0x0 0x80000000  0x4 0x80000000
0x0 0x80000000>;

                        mydevice {
                                compatible = "my-compatible-string";
                                memory-region = <&mydev_rsvd>;
                        }
                }
        }
};

It looks like this issue was previously fixed by commit c41f9ea998f3
("drivers: dma-coherent: Account dma_pfn_offset when used with device
tree") which introduced a new function ('dma_get_device_base()') to
return the reserved memory address as seen by the device. However,
such a function, even if still there, is not used anymore in latest
code (as of v5.4-rc2). Was that done for a specific reason? Or is it
just a mistake?

Regards,
Daniele
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

             reply	other threads:[~2019-10-14 13:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-13 14:28 Daniele Alessandrelli [this message]
2019-10-14 13:54 ` [BUG] dma-ranges, reserved memory regions, dma_alloc_coherent: possible bug? Robin Murphy
2019-10-14 15:01   ` Vladimir Murzin
2019-10-17  9:46     ` Vladimir Murzin
2019-10-17 10:03       ` Alexandre Torgue
2019-10-17 10:16         ` Vladimir Murzin
2019-10-17 10:33           ` Alexandre Torgue
2019-10-24 12:43       ` Vladimir Murzin
2019-10-24 15:20         ` Alexandre Torgue
2019-10-24 15:27           ` Vladimir Murzin
2019-10-28 10:55             ` Alexandre Torgue
2019-10-28 10:59               ` Vladimir Murzin
2019-10-29  9:43                 ` Daniele Alessandrelli
2019-10-29 16:52                   ` Daniele Alessandrelli
2019-10-30 10:16                     ` Vladimir Murzin

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='CAA2QUqLv+eLXuA_TdJ7zM4oBnGoFVOjRjAimuct2y=0MDuaZVQ@mail.gmail.com' \
    --to=daniele.alessandrelli@gmail.com \
    --cc=arnd@arndb.de \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=vladimir.murzin@arm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.