netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: "claudiu beznea (tuxon)" <claudiu.beznea@tuxon.dev>
Cc: Vineeth Karumanchi <vineeth.karumanchi@amd.com>,
	nicolas.ferre@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 3/6] net: macb: Add IEEE 802.1Qbv TAPRIO REPLACE command offload support
Date: Sat, 26 Jul 2025 17:32:43 +0200	[thread overview]
Message-ID: <aaf014b1-d0c0-491e-99fb-9d1eb5abafb3@lunn.ch> (raw)
In-Reply-To: <64481774-9791-4453-ab81-e4f0c444a2a6@tuxon.dev>

> > +	enst_queue = kcalloc(conf->num_entries, sizeof(*enst_queue), GFP_KERNEL);
> 
> To simplify the error path you can use something like:
> 
>         struct queue_enst_configs *enst_queue __free(kfree) = kcalloc(...);
> 
> and drop the "goto cleanup" below.

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

1.6.5. Using device-managed and cleanup.h constructs

Netdev remains skeptical about promises of all “auto-cleanup” APIs,
including even devm_ helpers, historically. They are not the preferred
style of implementation, merely an acceptable one.

Use of guard() is discouraged within any function longer than 20
lines, scoped_guard() is considered more readable. Using normal
lock/unlock is still (weakly) preferred.

Low level cleanup constructs (such as __free()) can be used when
building APIs and helpers, especially scoped iterators. However,
direct use of __free() within networking core and drivers is
discouraged. Similar guidance applies to declaring variables
mid-function.

> 
> You can use guard(spinlock_irqsave)(&bp->lock) or
> scoped_guard(spinlock_irqsave, &bp->lock)

scoped_guard() if anything.

> 
> > +
> > +	/* Disable ENST queues if running before configuring */
> > +	if (gem_readl(bp, ENST_CONTROL))
> 
> Is this read necessary?
> 
> > +		gem_writel(bp, ENST_CONTROL,
> > +			   GENMASK(bp->num_queues - 1, 0) << GEM_ENST_DISABLE_QUEUE_OFFSET);
> 
> This could be replaced by GEM_BF(GENMASK(...), ENST_DISABLE_QUEUE) if you
> define GEM_ENST_DISABLE_QUEUE_SIZE along with GEM_ENST_DISABLE_QUEUE_OFFSET.
> 
> > +
> > +	for (i = 0; i < conf->num_entries; i++) {
> > +		queue = &bp->queues[enst_queue[i].queue_id];
> > +		/* Configure queue timing registers */
> > +		queue_writel(queue, ENST_START_TIME, enst_queue[i].start_time_mask);
> > +		queue_writel(queue, ENST_ON_TIME, enst_queue[i].on_time_bytes);
> > +		queue_writel(queue, ENST_OFF_TIME, enst_queue[i].off_time_bytes);
> > +	}
> > +
> > +	/* Enable ENST for all configured queues in one write */
> > +	gem_writel(bp, ENST_CONTROL, configured_queues);
> 
> Can this function be executed while other queues are configured? If so,
> would the configured_queues contains it (as well as conf)?
> 
> > +	spin_unlock_irqrestore(&bp->lock, flags);
> > +
> > +	netdev_info(ndev, "TAPRIO configuration completed successfully: %lu entries, %d queues configured\n",
> > +		    conf->num_entries, hweight32(configured_queues));

guard() would put that netdev_info() print inside the guard. Do you
really want to be doing a print, inside a spinlock, with interrupts
potentially disabled? This is one of the reasons i don't like this
magical guard() construct, it is easy to forget how the magic works
and end up with sub optimal code. A scoped_guard() would avoid this
issue. You have to think about where you want to lock released in
order to place the } .

	Andrew

  reply	other threads:[~2025-07-26 15:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22 15:41 [PATCH net-next 0/6] net: macb: Add TAPRIO traffic scheduling support Vineeth Karumanchi
2025-07-22 15:41 ` [PATCH net-next 1/6] net: macb: Define ENST hardware registers for time-aware scheduling Vineeth Karumanchi
2025-07-26 12:23   ` claudiu beznea (tuxon)
2025-07-22 15:41 ` [PATCH net-next 2/6] net: macb: Integrate ENST timing parameters and hardware unit conversion Vineeth Karumanchi
2025-07-26 12:24   ` claudiu beznea (tuxon)
2025-07-22 15:41 ` [PATCH net-next 3/6] net: macb: Add IEEE 802.1Qbv TAPRIO REPLACE command offload support Vineeth Karumanchi
2025-07-23 10:02   ` kernel test robot
2025-07-26 12:25   ` claudiu beznea (tuxon)
2025-07-26 15:32     ` Andrew Lunn [this message]
2025-07-29  8:59     ` Karumanchi, Vineeth
2025-07-31  9:07       ` Claudiu Beznea
2025-07-22 15:41 ` [PATCH net-next 4/6] net: macb: Implement TAPRIO DESTROY command offload for gate cleanup Vineeth Karumanchi
2025-07-26 12:26   ` claudiu beznea (tuxon)
2025-07-22 15:41 ` [PATCH net-next 5/6] net: macb: Implement TAPRIO TC offload command interface Vineeth Karumanchi
2025-07-26 12:29   ` claudiu beznea (tuxon)
2025-07-29  9:38     ` Karumanchi, Vineeth
2025-07-31  9:07       ` Claudiu Beznea
2025-07-28 16:31   ` kernel test robot
2025-07-22 15:41 ` [PATCH net-next 6/6] net: macb: Add MACB_CAPS_QBV capability flag for IEEE 802.1Qbv support Vineeth Karumanchi
2025-07-23 19:05   ` Simon Horman
2025-07-29  9:42     ` Karumanchi, Vineeth
2025-07-24  0:46   ` kernel test robot

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=aaf014b1-d0c0-491e-99fb-9d1eb5abafb3@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=andrew+netdev@lunn.ch \
    --cc=claudiu.beznea@tuxon.dev \
    --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=nicolas.ferre@microchip.com \
    --cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).