public inbox for dri-devel@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Mikko Perttunen <mperttunen@nvidia.com>
Subject: Re: [PATCH 4/5] drm/tegra: Restrict IOVA space to DMA mask
Date: Wed, 23 Jan 2019 17:33:15 +0300	[thread overview]
Message-ID: <31ee097b-3863-250b-edb2-85d1f7aaf8d8@gmail.com> (raw)
In-Reply-To: <20190123140406.GA16034@ulmo>

23.01.2019 17:04, Thierry Reding пишет:
> On Wed, Jan 23, 2019 at 04:41:44PM +0300, Dmitry Osipenko wrote:
>> 23.01.2019 12:39, Thierry Reding пишет:
>>> From: Thierry Reding <treding@nvidia.com>
>>>
>>> On Tegra186 and later, the ARM SMMU provides an input address space that
>>> is 48 bits wide. However, memory clients can only address up to 40 bits.
>>> If the geometry is used as-is, allocations of IOVA space can end up in a
>>> region that cannot be addressed by the memory clients.
>>>
>>> To fix this, restrict the IOVA space to the DMA mask of the host1x
>>> device. Note that, technically, the IOVA space needs to be restricted to
>>> the intersection of the DMA masks for all clients that are attached to
>>> the IOMMU domain. In practice using the DMA mask of the host1x device is
>>> sufficient because all host1x clients share the same DMA mask.
>>>
>>> Signed-off-by: Thierry Reding <treding@nvidia.com>
>>> ---
>>>  drivers/gpu/drm/tegra/drm.c | 5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
>>> index 271c7a5fc954..0c5f1e6a0446 100644
>>> --- a/drivers/gpu/drm/tegra/drm.c
>>> +++ b/drivers/gpu/drm/tegra/drm.c
>>> @@ -136,11 +136,12 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
>>>  
>>>  	if (tegra->domain) {
>>>  		u64 carveout_start, carveout_end, gem_start, gem_end;
>>> +		u64 dma_mask = dma_get_mask(&device->dev);
>>>  		dma_addr_t start, end;
>>>  		unsigned long order;
>>>  
>>> -		start = tegra->domain->geometry.aperture_start;
>>> -		end = tegra->domain->geometry.aperture_end;
>>> +		start = tegra->domain->geometry.aperture_start & dma_mask;
>>> +		end = tegra->domain->geometry.aperture_end & dma_mask;
>>>  
>>>  		gem_start = start;
>>>  		gem_end = end - CARVEOUT_SZ;
>>>
>>
>> Wow, so IOVA could address >32bits on later Tegra's. AFAIK, currently
>> there is no support for a proper programming of the 64bit addresses in
>> the drivers code, hence.. won't it make sense to force IOVA mask to
>> 32bit for now and hope that the second halve of address registers
>> happen to be 0x00000000 in HW?
> 
> I think this restriction only applies to display at this point. In
> practice you'd be hard put to trigger that case because IOVA memory is
> allocated from the bottom, so you'd actually need to use up to 4 GiB of
> IOVA space before hitting that.
> 
> That said, I vaguely remember typing up the patch to support writing the
> WINBUF_START_ADDR_HI register and friends, but it looks as if that was
> never merged.
> 
> I'll try to dig out that patch (or rewrite it, shouldn't be very
> difficult) and make it part of this series. I'd rather fix that issue
> than arbitrarily restrict the IOVA space, because that's likely to come
> back and bite us at some point.

You could also try to change the IOVA allocation logic and see what will fail :)
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-01-23 14:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-23  9:39 [PATCH 0/5] drm/tegra: Fix IOVA space on Tegra186 and later Thierry Reding
2019-01-23  9:39 ` [PATCH 1/5] drm/tegra: Store parent pointer in Tegra DRM clients Thierry Reding
2019-01-23 14:06   ` Dmitry Osipenko
2019-01-23  9:39 ` [PATCH 2/5] drm/tegra: vic: Load firmware on demand Thierry Reding
2019-01-23 12:47   ` Dmitry Osipenko
2019-01-23 14:06     ` Thierry Reding
2019-01-23 14:19   ` Dmitry Osipenko
2019-01-23  9:39 ` [PATCH 3/5] drm/tegra: Setup shared IOMMU domain after initialization Thierry Reding
2019-01-23 14:55   ` Dmitry Osipenko
2019-01-23 16:28   ` Dmitry Osipenko
2019-01-23  9:39 ` [PATCH 4/5] drm/tegra: Restrict IOVA space to DMA mask Thierry Reding
2019-01-23 13:41   ` Dmitry Osipenko
2019-01-23 14:04     ` Thierry Reding
2019-01-23 14:33       ` Dmitry Osipenko [this message]
2019-01-23 15:55       ` Dmitry Osipenko
2019-01-23 19:42         ` Dmitry Osipenko
2019-01-24 10:24           ` Mikko Perttunen
2019-01-24 13:15             ` Dmitry Osipenko
2019-01-24 13:27               ` Mikko Perttunen
2019-01-24 13:51                 ` Dmitry Osipenko
2019-01-24 18:08     ` Thierry Reding
2019-01-23  9:39 ` [PATCH 5/5] gpu: host1x: Supports 40-bit addressing on Tegra186 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=31ee097b-3863-250b-edb2-85d1f7aaf8d8@gmail.com \
    --to=digetx@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=thierry.reding@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox