public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Markus Schneider-Pargmann" <msp@baylibre.com>
To: "Marek Vasut" <marek.vasut@mailbox.org>,
	"Markus Schneider-Pargmann" <msp@baylibre.com>,
	"Marek Vasut" <marek.vasut+renesas@mailbox.org>,
	<u-boot@lists.denx.de>
Cc: "Andrew Goodbody" <andrew.goodbody@linaro.org>,
	"Casey Connolly" <casey.connolly@linaro.org>,
	"Mattijs Korpershoek" <mkorpershoek@kernel.org>,
	"Michal Simek" <michal.simek@amd.com>,
	"Simon Glass" <sjg@chromium.org>, "Tom Rini" <trini@konsulko.com>
Subject: Re: [PATCH] dm: Respect dma-ranges size
Date: Tue, 31 Mar 2026 09:00:22 +0200	[thread overview]
Message-ID: <DHGRV9DE9A3T.1I61RAHP95WSW@baylibre.com> (raw)
In-Reply-To: <2c4f13c9-ff78-42c6-b770-71d06f59d522@mailbox.org>

[-- Attachment #1: Type: text/plain, Size: 2689 bytes --]

On Mon Mar 30, 2026 at 7:24 PM CEST, Marek Vasut wrote:
> On 3/30/26 3:34 PM, Markus Schneider-Pargmann wrote:
>
> Hello Markus,
>
>> On Mon Mar 16, 2026 at 12:57 AM CET, Marek Vasut wrote:
>>> Rework dev_phys_to_bus() and dev_bus_to_phys() to respect the size
>>> of the area specified in dma-ranges DT property. The area outside
>>> of ranges is remapped 1:1, while the area in the ranges is remapped
>>> according to the description in the dma-ranges property.
>>>
>>> Adjust the test to test the area within the remapped range, not area
>>> outside the remapped range, which was incorrect.
>>>
>> 
>> Should this have a Fixes tag?
>> 
>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
>> 
>> Not a big expert, but this looks good to me:
>> 
>> Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>
>
> This was broken long enough, so this should go into next so it would get 
> sufficient testing before the next release.
>
> [...]
>
>>> +++ b/include/dm/device.h
>>> @@ -166,8 +166,9 @@ enum {
>>>    *		When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will
>>>    *		add to this list. Memory so-allocated will be freed
>>>    *		automatically when the device is removed / unbound
>>> - * @dma_offset: Offset between the physical address space (CPU's) and the
>>> - *		device's bus address space
>>> + * @dma_cpu: DMA physical address space (CPU's)
>>> + * @dma_bus: DMA device's bus address space
>>> + * @dma_size: DMA window size
>>>    * @iommu: IOMMU device associated with this device
>>>    */
>>>   struct udevice {
>>> @@ -196,7 +197,9 @@ struct udevice {
>>>   	struct list_head devres_head;
>>>   #endif
>>>   #if CONFIG_IS_ENABLED(DM_DMA)
>>> -	ulong dma_offset;
>>> +	phys_addr_t dma_cpu;
>>> +	dma_addr_t dma_bus;
>>> +	u64 dma_size;
>>>   #endif
>
> [...]
>
>>> +++ b/include/phys2bus.h
>>> @@ -21,17 +21,23 @@ static inline unsigned long bus_to_phys(unsigned long bus)
>>>   }
>>>   #endif
>>>   
>>> -#if CONFIG_IS_ENABLED(DM)
>>> +#if CONFIG_IS_ENABLED(DM_DMA)
>> 
>> This is not related to the code changes right?
>
> It is, see the matching hunk above and below why this is guarded by DM_DMA .

Ah thanks, yes, the macro had the check for DM_DMA, I missed that.

Best
Markus

>
>>>   #include <dm/device.h>
>>>   
>>>   static inline dma_addr_t dev_phys_to_bus(struct udevice *dev, phys_addr_t phys)
>>>   {
>>> -	return phys - dev_get_dma_offset(dev);
>>> +	/* If the PA is in the remap range, apply remap. */
>>> +	if (phys >= dev->dma_cpu && phys < dev->dma_cpu + dev->dma_size)
>>> +		phys -= dev->dma_cpu - dev->dma_bus;
>>> +	return phys;
> [...]


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 289 bytes --]

  reply	other threads:[~2026-03-31  7:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-15 23:57 [PATCH] dm: Respect dma-ranges size Marek Vasut
2026-03-30 13:34 ` Markus Schneider-Pargmann
2026-03-30 17:24   ` Marek Vasut
2026-03-31  7:00     ` Markus Schneider-Pargmann [this message]
2026-04-08 14:51 ` Tom Rini

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=DHGRV9DE9A3T.1I61RAHP95WSW@baylibre.com \
    --to=msp@baylibre.com \
    --cc=andrew.goodbody@linaro.org \
    --cc=casey.connolly@linaro.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=marek.vasut@mailbox.org \
    --cc=michal.simek@amd.com \
    --cc=mkorpershoek@kernel.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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