linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shaik Ameer Basha <shaik.samsung@gmail.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	 Joerg Roedel <joro@8bytes.org>, Ajay kumar <ajaynumb@gmail.com>,
	 Linux IOMMU <iommu@lists.linux-foundation.org>,
	linux-mm@kvack.org,  Rob Clark <robdclark@gmail.com>,
	jean-philippe@linaro.org, will@kernel.org, hch@lst.de,
	 baolu.lu@linux.intel.com,
	Shaik Ameer Basha <shaik.ameer@samsung.com>
Subject: Re: IOVA allocation dependency between firmware buffer and remaining buffers
Date: Thu, 24 Sep 2020 19:44:19 +0530	[thread overview]
Message-ID: <CAOD6ATp2g7JMvACzF+30EcdGygRNGxwTa-3VkGWuanaWPAdt2w@mail.gmail.com> (raw)
In-Reply-To: <46f10f99-5da5-257a-4a02-984ff8ed8c6f@arm.com>

Hi Robin and Marek,


On Thu, Sep 24, 2020 at 4:36 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> On 2020-09-24 11:47, Marek Szyprowski wrote:
> > Hi Robin,
> >
> > On 24.09.2020 12:40, Robin Murphy wrote:
> >> On 2020-09-24 11:16, Thierry Reding wrote:
> >>> On Thu, Sep 24, 2020 at 10:46:46AM +0200, Marek Szyprowski wrote:
> >>>> On 24.09.2020 10:28, Joerg Roedel wrote:
> >>>>> On Wed, Sep 23, 2020 at 08:48:26AM +0200, Marek Szyprowski wrote:
> >>>>>> It allows to remap given buffer at the specific IOVA address,
> >>>>>> although
> >>>>>> it doesn't guarantee that those specific addresses won't be later
> >>>>>> used
> >>>>>> by the IOVA allocator. Probably it would make sense to add an API for
> >>>>>> generic IOMMU-DMA framework to mark the given IOVA range as
> >>>>>> reserved/unused to protect them.
> >>>>> There is an API for that, the IOMMU driver can return IOVA reserved
> >>>>> regions per device and the IOMMU core code will take care of mapping
> >>>>> these regions and reserving them in the IOVA allocator, so that
> >>>>> DMA-IOMMU code will not use it for allocations.
> >>>>>
> >>>>> Have a look at the iommu_ops->get_resv_regions() and
> >>>>> iommu_ops->put_resv_regions().
> >>>>
> >>>> I know about the reserved regions IOMMU API, but the main problem here,
> >>>> in case of Exynos, is that those reserved regions won't be created by
> >>>> the IOMMU driver but by the IOMMU client device. It is just a result
> >>>> how
> >>>> the media drivers manages their IOVA space. They simply have to load
> >>>> firmware at the IOVA address lower than the any address of the used
> >>>> buffers.
> >>>
> >>> I've been working on adding a way to automatically add direct mappings
> >>> using reserved-memory regions parsed from device tree, see:
> >>>
> >>> https://lore.kernel.org/lkml/20200904130000.691933-1-thierry.reding@gmail.com/
> >>>
> >>> Perhaps this can be of use? With that you should be able to add a
> >>> reserved-memory region somewhere in the lower range that you need for
> >>> firmware images and have that automatically added as a direct mapping
> >>> so that it won't be reused later on for dynamic allocations.
> >>
> >> It can't easily be a *direct* mapping though - if the driver has to
> >> use the DMA masks to ensure that everything stays within the
> >> addressable range, then (as far as I'm aware) there's no physical
> >> memory that low down to equal the DMA addresses.
> >>
> >> TBH I'm not convinced that this is a sufficiently common concern to
> >> justify new APIs, or even to try to make overly generic. I think just
> >> implementing a new DMA attribute to say "please allocate/map this
> >> particular request at the lowest DMA address possible" would be good
> >> enough. Such a thing could also serve PCI drivers that actually care
> >> about SAC/DAC to give us more of a chance of removing the "try a
> >> 32-bit mask first" trick from everyone's hotpath...
> >
> > Hmm, I like the idea of such DMA attribute! It should make things really
> > simple, especially in the drivers. Thanks for the great idea! I will try
> > to implement it then instead of the workarounds I've proposed in
> > s5p-mfc/exynos4-is drivers.
>
> Right, I think it's fair to draw a line and say that anyone who wants a
> *specific* address needs to manage their own IOMMU domain.
>
> In the backend I suspect it's going to be cleanest to implement a
> dedicated iova_alloc_low() (or similar) function in the IOVA API that
> sidesteps all of the existing allocation paths and goes straight to the
> rbtree.

This is the place we started with..

But our solution was to provide an API which limits the allocation
range per device (dynamically) based on the driver request..
Something like,
    limit_iova_alloc_range(dev, low_iova, high_iova); /* via helpers */

When multiple devices use the same IOVA space, how we can handle api's
like " iova_alloc_low()" ?
And providing APIs like " limit_iova_alloc_range()" may cater similar
future requirements from drivers instead of worrying about
high/low/mid etc.

Again, flexibility should be there with user drivers to request the
range they want at any point of time...

Please let us know your inputs.

>
> Robin.


  reply	other threads:[~2020-09-24 14:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20 15:54 IOVA allocation dependency between firmware buffer and remaining buffers Ajay kumar
2020-04-24 15:04 ` Ajay kumar
2020-04-24 15:29   ` Robin Murphy
2020-04-24 16:15     ` Shaik Ameer Basha
2020-09-23  6:48       ` Marek Szyprowski
2020-09-23  6:58         ` Christoph Hellwig
2020-09-23  7:45           ` Ajay kumar
2020-09-23 13:47             ` Christoph Hellwig
2020-09-23  8:25           ` Ajay Kumar
2020-09-24  8:28         ` Joerg Roedel
2020-09-24  8:46           ` Marek Szyprowski
2020-09-24 10:16             ` Thierry Reding
2020-09-24 10:40               ` Robin Murphy
2020-09-24 10:47                 ` Marek Szyprowski
2020-09-24 11:06                   ` Robin Murphy
2020-09-24 14:14                     ` Shaik Ameer Basha [this message]
2020-09-28  6:52                     ` Marek Szyprowski
2020-09-24 10:41               ` Marek Szyprowski
2020-09-24 14:33                 ` Thierry Reding

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=CAOD6ATp2g7JMvACzF+30EcdGygRNGxwTa-3VkGWuanaWPAdt2w@mail.gmail.com \
    --to=shaik.samsung@gmail.com \
    --cc=ajaynumb@gmail.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jean-philippe@linaro.org \
    --cc=joro@8bytes.org \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robdclark@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=shaik.ameer@samsung.com \
    --cc=thierry.reding@gmail.com \
    --cc=will@kernel.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).