mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolai Buchwitz <nb@tipi-net.de>
To: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
Cc: theo.lebrun@bootlin.com, conor.dooley@microchip.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, git@amd.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] net: macb: configure ENST registers for all queues
Date: Fri, 24 Jul 2026 21:57:49 +0200	[thread overview]
Message-ID: <49ccdd6682366239fef37bcfd99a908c@tipi-net.de> (raw)
In-Reply-To: <20260724043257.2221030-3-vineeth.karumanchi@amd.com>

Hi Vineeth

On 24.7.2026 06:32, Vineeth Karumanchi wrote:
> The initial "tc" command was not overwriting the reset value of ENST
> registers if only a subset of queues were configured, leading to an
> invalid setup. To fix this, configure all queues unconditionally.
> Unconfigured queues are zero-initialized via kcalloc(), ensuring a
> complete and consistent configuration.
> 
> The queue_id field in struct macb_queue_enst_config becomes redundant
> once the array is indexed by queue id, so drop it.
> 
> Key changes:
> - Drop queue_id from struct macb_queue_enst_config
> - Allocate enst_queue[] based on bp->num_queues instead of
>   conf->num_entries
> - Index enst_queue[] directly with the queue number
> - Program ENST registers for all queues
> 
> Fixes: 89934dbf169e ("net: macb: Add TAPRIO traffic scheduling 
> support")

In addition to what Théo already mentioned:

The series targets net-next, but if this is a real bug fix it should
probably be routed via net. The offending commit is in stable since 
v6.18.

> Signed-off-by: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
> ---
>  drivers/net/ethernet/cadence/macb.h      |  2 --
>  drivers/net/ethernet/cadence/macb_main.c | 20 +++++++++-----------
>  2 files changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb.h 
> b/drivers/net/ethernet/cadence/macb.h
> index a11052565436..4cc9aa9b2f9e 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -1490,7 +1490,6 @@ struct macb_platform_data {
>   * @start_time_mask:  Bitmask representing the start time for the 
> queue
>   * @on_time_bytes:    "on" time nsec expressed in bytes
>   * @off_time_bytes:   "off" time nsec expressed in bytes
> - * @queue_id:         Identifier for the queue
>   *
>   * This structure holds the configuration parameters for an ENST 
> queue,
>   * used to control time-based transmission scheduling in the MACB 
> driver.
> @@ -1499,7 +1498,6 @@ struct macb_queue_enst_config {
>  	u32 start_time_mask;
>  	u32 on_time_bytes;
>  	u32 off_time_bytes;
> -	u8 queue_id;
>  };
> 
>  #endif /* _MACB_H */
> diff --git a/drivers/net/ethernet/cadence/macb_main.c 
> b/drivers/net/ethernet/cadence/macb_main.c
> index d394f1f43b68..d58430fe9c41 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4329,7 +4329,7 @@ static int macb_taprio_setup_replace(struct 
> net_device *ndev,
>  	struct macb_queue *queue;
>  	u32 queue_mask;
>  	u8 queue_id;
> -	size_t i;
> +	size_t i, q;
>  	int err;
> 
>  	if (conf->num_entries > bp->num_queues) {
> @@ -4357,7 +4357,7 @@ static int macb_taprio_setup_replace(struct 
> net_device *ndev,
>  		return -EINVAL;
>  	}
> 
> -	enst_queue = kcalloc(conf->num_entries, sizeof(*enst_queue), 
> GFP_KERNEL);
> +	enst_queue = kcalloc(bp->num_queues, sizeof(*enst_queue), 
> GFP_KERNEL);
>  	if (unlikely(!enst_queue))
>  		return -ENOMEM;
> 
> @@ -4416,13 +4416,12 @@ static int macb_taprio_setup_replace(struct 
> net_device *ndev,
>  			goto cleanup;
>  		}
> 
> -		enst_queue[i].queue_id = queue_id;
> -		enst_queue[i].start_time_mask =
> +		enst_queue[queue_id].start_time_mask =
>  			(start_time_sec << GEM_START_TIME_SEC_OFFSET) |
>  			start_time_nsec;
> -		enst_queue[i].on_time_bytes =
> +		enst_queue[queue_id].on_time_bytes =
>  			enst_ns_to_hw_units(entry->interval, speed);
> -		enst_queue[i].off_time_bytes =
> +		enst_queue[queue_id].off_time_bytes =
>  			enst_ns_to_hw_units(conf->cycle_time - entry->interval, speed);
> 
>  		configured_queues |= entry->gate_mask;
> @@ -4448,15 +4447,14 @@ static int macb_taprio_setup_replace(struct 
> net_device *ndev,
>  		gem_writel(bp, ENST_CONTROL,
>  			   queue_mask << GEM_ENST_DISABLE_QUEUE_OFFSET);
> 
> -		for (i = 0; i < conf->num_entries; i++) {
> -			queue = &bp->queues[enst_queue[i].queue_id];
> +		for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
>  			/* Configure queue timing registers */
>  			queue_writel(queue, ENST_START_TIME,
> -				     enst_queue[i].start_time_mask);
> +				     enst_queue[q].start_time_mask);
>  			queue_writel(queue, ENST_ON_TIME,
> -				     enst_queue[i].on_time_bytes);
> +				     enst_queue[q].on_time_bytes);
>  			queue_writel(queue, ENST_OFF_TIME,
> -				     enst_queue[i].off_time_bytes);
> +				     enst_queue[q].off_time_bytes);
>  		}
> 
>  		/* Enable ENST for all configured queues in one write */

Regards,
Nicolai

  parent reply	other threads:[~2026-07-24 19:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  4:32 [PATCH net-next 0/2] net: macb: fix ENST configuration " Vineeth Karumanchi
2026-07-24  4:32 ` [PATCH net-next 1/2] net: macb: remove unused ENST Q0/Q1 time register defines Vineeth Karumanchi
2026-07-24 17:49   ` Théo Lebrun
2026-07-24 19:40   ` Nicolai Buchwitz
2026-07-24  4:32 ` [PATCH net-next 2/2] net: macb: configure ENST registers for all queues Vineeth Karumanchi
2026-07-24 18:06   ` Théo Lebrun
2026-07-27  5:32     ` Karumanchi, Vineeth
2026-07-27 12:05       ` Théo Lebrun
2026-07-27 12:52         ` Théo Lebrun
2026-07-28 13:53         ` Karumanchi, Vineeth
2026-07-24 19:57   ` Nicolai Buchwitz [this message]
2026-07-27 10:01     ` Karumanchi, Vineeth

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=49ccdd6682366239fef37bcfd99a908c@tipi-net.de \
    --to=nb@tipi-net.de \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor.dooley@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=git@amd.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=theo.lebrun@bootlin.com \
    --cc=vineeth.karumanchi@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

all inboxes | Powered by JetHome®