From: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
To: Denis Kirjanov <dkirjanov@suse.de>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: "Sergey Shtylyov" <s.shtylyov@omp.ru>,
"Claudiu Beznea" <claudiu.beznea.uj@bp.renesas.com>,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: ethernet: ravb: fix dma mapping failure handling
Date: Fri, 12 Jan 2024 15:04:17 +0600 [thread overview]
Message-ID: <804a4586-1909-44ee-a40c-d9cb615f75ad@cogentembedded.com> (raw)
In-Reply-To: <64deebbd-93d0-47dc-835e-f719655e076c@suse.de>
12.01.2024 14:56, Denis Kirjanov wrote:
>
>
> On 1/12/24 08:06, Nikita Yushchenko wrote:
>> dma_mapping_error() depends on getting full 64-bit dma_addr_t and does
>> not work correctly if 32-bit value is passed instead.
>>
>> Fix handling of dma_map_single() failures on Rx ring entries:
>> - do not store return value of dma_map_signle() in 32-bit variable,
>> - do not use dma_mapping_error() against 32-bit descriptor field when
>> checking if unmap is needed, check for zero size instead.
>
> Hmm, something is wrong here since you're mixing DMA api and forced 32bit values.
> if dma uses 32bit addresses then dma_addr_t need only be 32 bits wide
dma_addr_t is arch-wide type and it is 64bit on arm64
Still, some devices use 32-bit dma addresses.
Proper setting of dma masks and/of configuring iommu ensures that in no error case, dma address fits
into 32 bits.
Still, in error case dma_map_single() returns ~((dma_addr_t)0) which uses fill dma_addr_t width and gets
corrupted if assigned to 32-bit value, then later call to dma_mapping_error() does not recognize it. The
patch fixes exactly this issue.
next prev parent reply other threads:[~2024-01-12 9:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 5:06 [PATCH] net: ethernet: ravb: fix dma mapping failure handling Nikita Yushchenko
2024-01-12 8:56 ` Denis Kirjanov
2024-01-12 9:04 ` Nikita Yushchenko [this message]
2024-01-12 22:08 ` Florian Fainelli
2024-01-12 20:15 ` Sergey Shtylyov
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=804a4586-1909-44ee-a40c-d9cb615f75ad@cogentembedded.com \
--to=nikita.yoush@cogentembedded.com \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=davem@davemloft.net \
--cc=dkirjanov@suse.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=s.shtylyov@omp.ru \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wsa+renesas@sang-engineering.com \
--cc=yoshihiro.shimoda.uh@renesas.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