iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Shaik Ameer Basha <shaik.samsung@gmail.com>,
	Robin Murphy <robin.murphy@arm.com>
Cc: jean-philippe@linaro.org,
	Shaik Ameer Basha <shaik.ameer@samsung.com>,
	linux-mm@kvack.org,
	Linux IOMMU <iommu@lists.linux-foundation.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Ajay kumar <ajaynumb@gmail.com>,
	will@kernel.org, hch@lst.de
Subject: Re: IOVA allocation dependency between firmware buffer and remaining buffers
Date: Wed, 23 Sep 2020 08:48:26 +0200	[thread overview]
Message-ID: <11584d09-5995-6133-3bd3-8f7a0afd0e01@samsung.com> (raw)
In-Reply-To: <CAOD6ATrWYLPT0ydz2vFhNwWhqHum_q_pyCe=oGJWOcEqjmNOqQ@mail.gmail.com>

Hi Shaik,

I've run into similar problem while adapting S5P-MFC and Exynos4-IS 
drivers for generic IOMMU-DMA framework. Here is my first solution: 
https://lore.kernel.org/linux-samsung-soc/20200918144833.14618-1-m.szyprowski@samsung.com/T/ 


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.

Best regards
Marek Szyprowski, PhD
Samsung R&D Institute Poland

On 24.04.2020 18:15, Shaik Ameer Basha wrote:
> On Fri, Apr 24, 2020 at 8:59 PM Robin Murphy <robin.murphy@arm.com> wrote:
>> On 2020-04-24 4:04 pm, Ajay kumar wrote:
>>> Can someone check this?
>>>
>>> On Mon, Apr 20, 2020 at 9:24 PM Ajay kumar <ajaynumb@gmail.com> wrote:
>>>> Hi All,
>>>>
>>>> I have an IOMMU master which has limitations as mentioned below:
>>>> 1) The IOMMU master internally executes a firmware, and the firmware memory
>>>> is allocated by the same master driver.
>>>> The firmware buffer address should be of the lowest range than other address
>>>> allocated by the device, or in other words, all the remaining buffer addresses
>>>> should always be in a higher range than the firmware address.
>>>> 2) None of the buffer addresses should go beyond 0xC000_0000
>> That particular constraint could (and perhaps should) be expressed as a
>> DMA mask/limit for the device, but if you have specific requirements to
> Yes Robin. We do use 0xC000_0000 address to set the DMA mask in our driver.
>
>> place buffers at particular addresses then you might be better off
>> managing your own IOMMU domain like some other (mostly DRM) drivers do.
> If you remember any of such drivers can you please point the driver path ?
>
>> The DMA APIs don't offer any guarantees about what addresses you'll get
>> other than that they won't exceed the appropriate mask.
> True, we have gone through most of the APIs and didn't find any way to match our
> requirements with the existing DMA APIs
>
>>>> example:
>>>> If firmware buffer address is buf_fw = 0x8000_5000;
>>>> All other addresses given to the device should be greater than
>>>> (0x8000_5000 + firmware size) and less than 0xC000_0000
>> Out of curiosity, how do you control that in the no-IOMMU or IOMMU
>> passthrough cases?
> We manage the no-IOMMU or pass through cases using the reserved-memory.
>
>> Robin.
>>
>>>> Currently, this is being handled with one of the below hacks:
>>>> 1) By keeping dma_mask in lower range while allocating firmware buffer,
>>>> and then increasing the dma_mask to higher range for other buffers.
>>>> 2) By reserving IOVA for firmware at the lowest range and creating direct mappings for the same.
>>>>
>>>> I want to know if there is a better way this can be handled with current framework,
>>>> or if anybody is facing similar problems with their devices,
>>>> please share how it is taken care.
>>>>
>>>> I also think there should be some way the masters can specify the IOVA
>>>> range they want to limit to for current allocation.
>>>> Something like a new iommu_ops callback like below:
>>>> limit_iova_alloc_range(dev, iova_start, iova_end)
>>>>
>>>> And, in my driver, the sequence will be:
>>>> limit_iova_alloc_range(dev, 0x0000_0000, 0x1000_0000); /* via helpers */
>>>> alloc( ) firmware buffer using DMA API
>>>> limit_iova_alloc_range(dev, 0x1000_0000, 0xC000_0000); /* via helpers */
>>>> alloc( ) other buffers using DMA API
>>>>
> Just want to understand more from you, on the new iommu_ops we suggested.
> Shouldn't device have that flexibility to allocate IOVA as per it's requirement?
> If you see our device as example, we need to have control on the
> allocated IOVA region
> based on where device is using this buffer.
>
> If we have these callbacks in place, then the low level IOMMU driver
> can implement and
> manage such requests when needed.
>
> If this can't be taken forward for some right reasons, then we will
> definitely try to understand
> on how to manage the IOMMU domain from our driver as per your suggestion
>
> - Shaik.
>
>>>> Thanks,
>>>> Ajay Kumar

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

  reply	other threads:[~2020-09-23  6:48 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 [this message]
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
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=11584d09-5995-6133-3bd3-8f7a0afd0e01@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=ajaynumb@gmail.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jean-philippe@linaro.org \
    --cc=linux-mm@kvack.org \
    --cc=robin.murphy@arm.com \
    --cc=shaik.ameer@samsung.com \
    --cc=shaik.samsung@gmail.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).