Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: eric.joyner@amd.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, brett.creeley@amd.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, prabu.ponrajthayalan@amd.com
Subject: Re: [PATCH net v2 5/5] ionic: fix completion descriptor access with 2x desc size
Date: Thu,  7 May 2026 08:59:28 -0700	[thread overview]
Message-ID: <20260507155928.2537928-1-kuba@kernel.org> (raw)
In-Reply-To: <20260506035706.12373-6-eric.joyner@amd.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
ionic: fix completion descriptor access with 2x desc size

This commit fixes completion descriptor access when the IONIC_Q_F_2X_CQ_DESC
flag is set. It introduces pointer arithmetic to correctly calculate the
offset of the 32-byte completion descriptor slot.

> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
[ ... ]
> @@ -729,7 +725,12 @@ static bool __ionic_rx_service(struct ionic_cq *cq, struct bpf_prog *xdp_prog)
>  	struct ionic_queue *q = cq->bound_q;
>  	struct ionic_rxq_comp *comp;
>  
> -	comp = &((struct ionic_rxq_comp *)cq->base)[cq->tail_idx];
> +	if (likely(cq->desc_size == sizeof(*comp)))
> +		comp = &((struct ionic_rxq_comp *)cq->base)[cq->tail_idx];
> +	else
> +		comp = cq->base +
> +		       cq->desc_size * cq->tail_idx +
> +		       cq->desc_size - sizeof(*comp);
>  
>  	if (!color_match(comp->pkt_type_color, cq->done_color))
>  		return false;

This is a pre-existing issue, but since the descriptor access is being
modified here, should there be a dma_rmb() after the color_match() check?

Without a read memory barrier, weakly-ordered CPU architectures might
speculatively read other fields of the descriptor from memory before checking
the color bit. This could result in processing stale data from the previous
ring cycle.

[ ... ]
> @@ -1244,7 +1240,12 @@ static bool ionic_tx_service(struct ionic_cq *cq,
>  	unsigned int pkts = 0;
>  	u16 index;
>  
> -	comp = &((struct ionic_txq_comp *)cq->base)[cq->tail_idx];
> +	if (likely(cq->desc_size == sizeof(*comp)))
> +		comp = &((struct ionic_txq_comp *)cq->base)[cq->tail_idx];
> +	else
> +		comp = cq->base +
> +		       cq->desc_size * cq->tail_idx +
> +		       cq->desc_size - sizeof(*comp);
>  
>  	if (!color_match(comp->color, cq->done_color))
>  		return false;

Does this color_match() check also need a dma_rmb() immediately following it
to prevent stale descriptor reads on the transmit side?

      reply	other threads:[~2026-05-07 15:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06  3:57 [PATCH net v2 0/5] ionic: Various bugfixes Eric Joyner
2026-05-06  3:57 ` [PATCH net v2 1/5] ionic: Allow the first devcmd to trigger deferred probe Eric Joyner
2026-05-07 15:57   ` Jakub Kicinski
2026-05-07 15:59   ` Jakub Kicinski
2026-05-06  3:57 ` [PATCH net v2 2/5] ionic: Handle failures from ionic_reset() when relevant Eric Joyner
2026-05-06  3:57 ` [PATCH net v2 3/5] ionic: Fix unexpected dev_cmd failures Eric Joyner
2026-05-07 15:59   ` Jakub Kicinski
2026-05-06  3:57 ` [PATCH net v2 4/5] ionic: Fix check in ionic_get_link_ext_stats Eric Joyner
2026-05-06  3:57 ` [PATCH net v2 5/5] ionic: fix completion descriptor access with 2x desc size Eric Joyner
2026-05-07 15:59   ` Jakub Kicinski [this message]

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=20260507155928.2537928-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.joyner@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=prabu.ponrajthayalan@amd.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