* [PATCH net v3] ethernet: ionic: Fix DMA mapping tests
@ 2025-06-19 9:45 Thomas Fourier
2025-06-19 22:28 ` Brett Creeley
2025-06-23 23:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 6+ messages in thread
From: Thomas Fourier @ 2025-06-19 9:45 UTC (permalink / raw)
Cc: Thomas Fourier, Shannon Nelson, Brett Creeley, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev, Vladimir Oltean,
Caleb Sander Mateos, Taehee Yoo, netdev, linux-kernel, bpf
Change error values of `ionic_tx_map_single()` and `ionic_tx_map_frag()`
from 0 to `DMA_MAPPING_ERROR` to prevent collision with 0 as a valid
address.
This also fixes the use of `dma_mapping_error()` to test against 0 in
`ionic_xdp_post_frame()`
Fixes: 0f3154e6bcb3 ("ionic: Add Tx and Rx handling")
Fixes: 56e41ee12d2d ("ionic: better dma-map error handling")
Fixes: ac8813c0ab7d ("ionic: convert Rx queue buffers to use page_pool")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index 2ac59564ded1..d10b58ebf603 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -321,7 +321,7 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame,
len, DMA_TO_DEVICE);
} else /* XDP_REDIRECT */ {
dma_addr = ionic_tx_map_single(q, frame->data, len);
- if (!dma_addr)
+ if (dma_addr == DMA_MAPPING_ERROR)
return -EIO;
}
@@ -357,7 +357,7 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame,
} else {
dma_addr = ionic_tx_map_frag(q, frag, 0,
skb_frag_size(frag));
- if (dma_mapping_error(q->dev, dma_addr)) {
+ if (dma_addr == DMA_MAPPING_ERROR) {
ionic_tx_desc_unmap_bufs(q, desc_info);
return -EIO;
}
@@ -1083,7 +1083,7 @@ static dma_addr_t ionic_tx_map_single(struct ionic_queue *q,
net_warn_ratelimited("%s: DMA single map failed on %s!\n",
dev_name(dev), q->name);
q_to_tx_stats(q)->dma_map_err++;
- return 0;
+ return DMA_MAPPING_ERROR;
}
return dma_addr;
}
@@ -1100,7 +1100,7 @@ static dma_addr_t ionic_tx_map_frag(struct ionic_queue *q,
net_warn_ratelimited("%s: DMA frag map failed on %s!\n",
dev_name(dev), q->name);
q_to_tx_stats(q)->dma_map_err++;
- return 0;
+ return DMA_MAPPING_ERROR;
}
return dma_addr;
}
@@ -1116,7 +1116,7 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb,
int frag_idx;
dma_addr = ionic_tx_map_single(q, skb->data, skb_headlen(skb));
- if (!dma_addr)
+ if (dma_addr == DMA_MAPPING_ERROR)
return -EIO;
buf_info->dma_addr = dma_addr;
buf_info->len = skb_headlen(skb);
@@ -1126,7 +1126,7 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb,
nfrags = skb_shinfo(skb)->nr_frags;
for (frag_idx = 0; frag_idx < nfrags; frag_idx++, frag++) {
dma_addr = ionic_tx_map_frag(q, frag, 0, skb_frag_size(frag));
- if (!dma_addr)
+ if (dma_addr == DMA_MAPPING_ERROR)
goto dma_fail;
buf_info->dma_addr = dma_addr;
buf_info->len = skb_frag_size(frag);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] ethernet: ionic: Fix DMA mapping tests
2025-06-19 9:45 [PATCH net v3] ethernet: ionic: Fix DMA mapping tests Thomas Fourier
@ 2025-06-19 22:28 ` Brett Creeley
2025-06-20 10:51 ` Simon Horman
2025-06-23 23:50 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 6+ messages in thread
From: Brett Creeley @ 2025-06-19 22:28 UTC (permalink / raw)
To: Thomas Fourier
Cc: Shannon Nelson, Brett Creeley, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, Vladimir Oltean, Caleb Sander Mateos,
Taehee Yoo, netdev, linux-kernel, bpf
On 6/19/2025 2:45 AM, Thomas Fourier wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> Change error values of `ionic_tx_map_single()` and `ionic_tx_map_frag()`
> from 0 to `DMA_MAPPING_ERROR` to prevent collision with 0 as a valid
> address.
>
> This also fixes the use of `dma_mapping_error()` to test against 0 in
> `ionic_xdp_post_frame()`
>
> Fixes: 0f3154e6bcb3 ("ionic: Add Tx and Rx handling")
I'm not sure the Fixes commit above should be in the list. Functionally
it's correct, except there being multiple calls to dma_mapping_error()
on the same dma_addr.
Other than the minor nit above the commit looks good. Thanks again for
fixing this.
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
> Fixes: 56e41ee12d2d ("ionic: better dma-map error handling")
> Fixes: ac8813c0ab7d ("ionic: convert Rx queue buffers to use page_pool")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
> drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> index 2ac59564ded1..d10b58ebf603 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> @@ -321,7 +321,7 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame,
> len, DMA_TO_DEVICE);
> } else /* XDP_REDIRECT */ {
> dma_addr = ionic_tx_map_single(q, frame->data, len);
> - if (!dma_addr)
> + if (dma_addr == DMA_MAPPING_ERROR)
> return -EIO;
> }
>
> @@ -357,7 +357,7 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame,
> } else {
> dma_addr = ionic_tx_map_frag(q, frag, 0,
> skb_frag_size(frag));
> - if (dma_mapping_error(q->dev, dma_addr)) {
> + if (dma_addr == DMA_MAPPING_ERROR) {
> ionic_tx_desc_unmap_bufs(q, desc_info);
> return -EIO;
> }
> @@ -1083,7 +1083,7 @@ static dma_addr_t ionic_tx_map_single(struct ionic_queue *q,
> net_warn_ratelimited("%s: DMA single map failed on %s!\n",
> dev_name(dev), q->name);
> q_to_tx_stats(q)->dma_map_err++;
> - return 0;
> + return DMA_MAPPING_ERROR;
> }
> return dma_addr;
> }
> @@ -1100,7 +1100,7 @@ static dma_addr_t ionic_tx_map_frag(struct ionic_queue *q,
> net_warn_ratelimited("%s: DMA frag map failed on %s!\n",
> dev_name(dev), q->name);
> q_to_tx_stats(q)->dma_map_err++;
> - return 0;
> + return DMA_MAPPING_ERROR;
> }
> return dma_addr;
> }
> @@ -1116,7 +1116,7 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb,
> int frag_idx;
>
> dma_addr = ionic_tx_map_single(q, skb->data, skb_headlen(skb));
> - if (!dma_addr)
> + if (dma_addr == DMA_MAPPING_ERROR)
> return -EIO;
> buf_info->dma_addr = dma_addr;
> buf_info->len = skb_headlen(skb);
> @@ -1126,7 +1126,7 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb,
> nfrags = skb_shinfo(skb)->nr_frags;
> for (frag_idx = 0; frag_idx < nfrags; frag_idx++, frag++) {
> dma_addr = ionic_tx_map_frag(q, frag, 0, skb_frag_size(frag));
> - if (!dma_addr)
> + if (dma_addr == DMA_MAPPING_ERROR)
> goto dma_fail;
> buf_info->dma_addr = dma_addr;
> buf_info->len = skb_frag_size(frag);
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] ethernet: ionic: Fix DMA mapping tests
2025-06-19 22:28 ` Brett Creeley
@ 2025-06-20 10:51 ` Simon Horman
2025-06-23 15:44 ` Brett Creeley
0 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2025-06-20 10:51 UTC (permalink / raw)
To: Brett Creeley
Cc: Thomas Fourier, Shannon Nelson, Brett Creeley, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev, Vladimir Oltean,
Caleb Sander Mateos, Taehee Yoo, netdev, linux-kernel, bpf
On Thu, Jun 19, 2025 at 03:28:06PM -0700, Brett Creeley wrote:
>
>
> On 6/19/2025 2:45 AM, Thomas Fourier wrote:
> > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> >
> >
> > Change error values of `ionic_tx_map_single()` and `ionic_tx_map_frag()`
> > from 0 to `DMA_MAPPING_ERROR` to prevent collision with 0 as a valid
> > address.
> >
> > This also fixes the use of `dma_mapping_error()` to test against 0 in
> > `ionic_xdp_post_frame()`
> >
> > Fixes: 0f3154e6bcb3 ("ionic: Add Tx and Rx handling")
>
> I'm not sure the Fixes commit above should be in the list. Functionally it's
> correct, except there being multiple calls to dma_mapping_error() on the
> same dma_addr.
>
> Other than the minor nit above the commit looks good. Thanks again for
> fixing this.
>
> Reviewed-by: Brett Creeley <brett.creeley@amd.com>
Hi Brett and Thomas,
Maybe I misunderstand things, if so I apologise.
If this patch fixes a bug - e.g. the may observe a system crash -
then it should be targeted at net and have a Fixes tag. Where the
Fixes tag generally cites the first commit in which the user may
experience the bug.
If, on the other hand, this does not fix a bug then the patch
should be targeted at net-next and should not have a Fixes tag.
In that case, commits may be cited using following form in
the commit message (before the Signed-off-by and other tags).
And, unlike tags, it may be line wrapped.
commit 0f3154e6bcb3 ("ionic: Add Tx and Rx handling")
E.g.: This was introduce by commit 0f3154e6bcb3 ("ionic: Add Tx and Rx
handling").
I hope this helps. If not, sorry for the noise.
...
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] ethernet: ionic: Fix DMA mapping tests
2025-06-20 10:51 ` Simon Horman
@ 2025-06-23 15:44 ` Brett Creeley
2025-06-23 23:44 ` Jakub Kicinski
0 siblings, 1 reply; 6+ messages in thread
From: Brett Creeley @ 2025-06-23 15:44 UTC (permalink / raw)
To: Simon Horman
Cc: Thomas Fourier, Shannon Nelson, Brett Creeley, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev, Vladimir Oltean,
Caleb Sander Mateos, Taehee Yoo, netdev, linux-kernel, bpf
On 6/20/2025 3:51 AM, Simon Horman wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> On Thu, Jun 19, 2025 at 03:28:06PM -0700, Brett Creeley wrote:
>>
>>
>> On 6/19/2025 2:45 AM, Thomas Fourier wrote:
>>> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>>>
>>>
>>> Change error values of `ionic_tx_map_single()` and `ionic_tx_map_frag()`
>>> from 0 to `DMA_MAPPING_ERROR` to prevent collision with 0 as a valid
>>> address.
>>>
>>> This also fixes the use of `dma_mapping_error()` to test against 0 in
>>> `ionic_xdp_post_frame()`
>>>
>>> Fixes: 0f3154e6bcb3 ("ionic: Add Tx and Rx handling")
>>
>> I'm not sure the Fixes commit above should be in the list. Functionally it's
>> correct, except there being multiple calls to dma_mapping_error() on the
>> same dma_addr.
>>
>> Other than the minor nit above the commit looks good. Thanks again for
>> fixing this.
>>
>> Reviewed-by: Brett Creeley <brett.creeley@amd.com>
>
> Hi Brett and Thomas,
>
> Maybe I misunderstand things, if so I apologise.
>
> If this patch fixes a bug - e.g. the may observe a system crash -
> then it should be targeted at net and have a Fixes tag. Where the
> Fixes tag generally cites the first commit in which the user may
> experience the bug.
>
> If, on the other hand, this does not fix a bug then the patch
> should be targeted at net-next and should not have a Fixes tag.
>
> In that case, commits may be cited using following form in
> the commit message (before the Signed-off-by and other tags).
> And, unlike tags, it may be line wrapped.
>
> commit 0f3154e6bcb3 ("ionic: Add Tx and Rx handling")
>
> E.g.: This was introduce by commit 0f3154e6bcb3 ("ionic: Add Tx and Rx
> handling").
>
> I hope this helps. If not, sorry for the noise.
Simon,
I suspect you are right and this probably shouldn't be categorized as a
bug fix since the change only addresses a corner case that would happen
if the DMA mapping API(s) return 0 as a valid adddress, which wouldn't
cause a crash with/without this patch.
Thanks for the feedback.
Brett
>
> ...
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] ethernet: ionic: Fix DMA mapping tests
2025-06-23 15:44 ` Brett Creeley
@ 2025-06-23 23:44 ` Jakub Kicinski
0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2025-06-23 23:44 UTC (permalink / raw)
To: Brett Creeley
Cc: Simon Horman, Thomas Fourier, Shannon Nelson, Brett Creeley,
Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev, Vladimir Oltean,
Caleb Sander Mateos, Taehee Yoo, netdev, linux-kernel, bpf
On Mon, 23 Jun 2025 08:44:39 -0700 Brett Creeley wrote:
> I suspect you are right and this probably shouldn't be categorized as a
> bug fix since the change only addresses a corner case that would happen
> if the DMA mapping API(s) return 0 as a valid adddress, which wouldn't
> cause a crash with/without this patch.
It's fine either way, so let me apply it and we can move on..
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] ethernet: ionic: Fix DMA mapping tests
2025-06-19 9:45 [PATCH net v3] ethernet: ionic: Fix DMA mapping tests Thomas Fourier
2025-06-19 22:28 ` Brett Creeley
@ 2025-06-23 23:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-23 23:50 UTC (permalink / raw)
To: Thomas Fourier
Cc: shannon.nelson, brett.creeley, andrew+netdev, davem, edumazet,
kuba, pabeni, ast, daniel, hawk, john.fastabend, sdf,
vladimir.oltean, csander, ap420073, netdev, linux-kernel, bpf
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 19 Jun 2025 11:45:30 +0200 you wrote:
> Change error values of `ionic_tx_map_single()` and `ionic_tx_map_frag()`
> from 0 to `DMA_MAPPING_ERROR` to prevent collision with 0 as a valid
> address.
>
> This also fixes the use of `dma_mapping_error()` to test against 0 in
> `ionic_xdp_post_frame()`
>
> [...]
Here is the summary with links:
- [net,v3] ethernet: ionic: Fix DMA mapping tests
https://git.kernel.org/netdev/net/c/d5e3241c5a38
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-23 23:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19 9:45 [PATCH net v3] ethernet: ionic: Fix DMA mapping tests Thomas Fourier
2025-06-19 22:28 ` Brett Creeley
2025-06-20 10:51 ` Simon Horman
2025-06-23 15:44 ` Brett Creeley
2025-06-23 23:44 ` Jakub Kicinski
2025-06-23 23:50 ` patchwork-bot+netdevbpf
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).