Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: srinivas.neeli@amd.com
Cc: nagadheeraj.rottela@amd.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	richardcochran@gmail.com, michal.simek@amd.com,
	bigeasy@linutronix.de, clrkwllms@kernel.org, rostedt@goodmis.org,
	edumazet@kernel.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rt-devel@lists.linux.dev, git@amd.com,
	neelisrinivas18@gmail.com
Subject: Re: [PATCH net-next v4 2/8] net: xilinx: tsn: add TSN endpoint wrapper driver
Date: Tue, 17 Nov 2026 13:14:43 +0000	[thread overview]
Message-ID: <179492128316.3136.9240121203954125694@kernel.org> (raw)
In-Reply-To: <20261113-patches_v2_external-v4-2-56bb26f042a4@amd.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] net: xilinx: tsn: use devm_clk_bulk_get_enable() in
  tsn_ip_probe()

--

> diff --git a/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c b/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c
> --- /dev/null
> +++ b/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c
> @@ -0,0 +1,104 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +/*
> + * Time Sensitive Networking (TSN) Ethernet MAC wrapper driver.
> + *
> + * Copyright (C) 2026 Advanced Micro Devices, Inc.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/device.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_platform.h>
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +#include <linux/types.h>
> +
> +#define TSN_NUM_CLOCKS		6
> +
> +/**
> + * struct xlnx_tsn_ip - wrapper-private IP state
> + * @clks: bulk-managed IP clocks
> + */
> +struct xlnx_tsn_ip {
> +	struct clk_bulk_data clks[TSN_NUM_CLOCKS];
> +};
> +
> +static const char * const tsn_clk_names[TSN_NUM_CLOCKS] = {
> +	"gtx",
> +	"gtx90",
> +	"host_rxfifo",
> +	"host_txfifo",
> +	"ref",
> +	"s_axi",
> +};
> +
> +static void tsn_clk_bulk_disable(void *data)
> +{
> +	struct xlnx_tsn_ip *w = data;
> +
> +	clk_bulk_disable_unprepare(TSN_NUM_CLOCKS, w->clks);
> +}
> +
> +static int tsn_ip_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct xlnx_tsn_ip *w;
> +	int ret;
> +
> +	w = devm_kzalloc(dev, sizeof(*w), GFP_KERNEL);
> +	if (!w)
> +		return -ENOMEM;
> +
> +	for (int i = 0; i < TSN_NUM_CLOCKS; i++)
> +		w->clks[i].id = tsn_clk_names[i];
> +
> +	ret = devm_clk_bulk_get(dev, TSN_NUM_CLOCKS, w->clks);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to get clocks\n");
> +
> +	ret = clk_bulk_prepare_enable(TSN_NUM_CLOCKS, w->clks);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to enable clocks\n");
> +
> +	ret = devm_add_action_or_reset(dev, tsn_clk_bulk_disable, w);
> +	if (ret)
> +		return ret;
> +
> +	return devm_of_platform_populate(dev);
> +}
> +
> +static const struct of_device_id tsn_of_match[] = {
> +	{ .compatible = "xlnx,tsn-endpoint-ethernet-mac-3.0" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, tsn_of_match);
> +
> +static struct platform_driver tsn_driver = {
> +	.probe = tsn_ip_probe,
> +	.driver = {
> +		.name = "xilinx-tsn",
> +		.of_match_table = tsn_of_match,
> +	},
> +};
> +
> +static struct platform_driver * const tsn_drivers[] = {
> +	&tsn_driver,
> +};
> +
> +static int __init xlnx_tsn_init(void)
> +{
> +	return platform_register_drivers(tsn_drivers, ARRAY_SIZE(tsn_drivers));
> +}
> +module_init(xlnx_tsn_init);
> +
> +static void __exit xlnx_tsn_exit(void)
> +{
> +	platform_unregister_drivers(tsn_drivers, ARRAY_SIZE(tsn_drivers));
> +}
> +module_exit(xlnx_tsn_exit);
> +
> +MODULE_AUTHOR("Srinivas Neeli <srinivas.neeli@amd.com>");
> +MODULE_DESCRIPTION("AMD/Xilinx TSN Endpoint Ethernet MAC wrapper driver");
> +MODULE_LICENSE("GPL");
>

[Severity: Low]
This open-codes what devm_clk_bulk_get_enable() already provides.
That helper in drivers/clk/clk-devres.c gets the bulk clocks, prepares
and enables them, and registers a devres release that disables,
unprepares and puts them on probe failure or unbind.

That means three steps can collapse into a single
devm_clk_bulk_get_enable(dev, TSN_NUM_CLOCKS, w->clks) call followed
by one dev_err_probe():

  - devm_clk_bulk_get()
  - clk_bulk_prepare_enable()
  - devm_add_action_or_reset()

The tsn_clk_bulk_disable() callback can then be dropped entirely.

The current code is not functionally wrong. It is just extra
boilerplate in tsn_ip_probe() that the clk framework already
handles. Is there a reason the get and enable steps need to stay
split here, e.g. something planned between them in a later patch?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-patches_v2_external-v4-0-56bb26f042a4%40amd.com


  reply	other threads:[~2026-11-17 13:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 18:46 [PATCH net-next v4 0/8] Add Xilinx TSN Endpoint Ethernet MAC driver Srinivas Neeli
2026-11-12 18:46 ` [PATCH net-next v4 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC Srinivas Neeli
2026-11-13 13:20   ` Andrew Lunn
2026-11-13 14:56     ` Neeli, Srinivas
2026-11-14 21:43       ` Andrew Lunn
2026-11-13 13:23   ` Andrew Lunn
2026-11-17 13:14   ` netdev-bot+sashiko
2026-11-12 18:46 ` [PATCH net-next v4 2/8] net: xilinx: tsn: add TSN endpoint wrapper driver Srinivas Neeli
2026-11-17 13:14   ` netdev-bot+sashiko [this message]
2026-11-12 18:46 ` [PATCH net-next v4 3/8] net: xilinx: tsn: add endpoint MAC driver skeleton Srinivas Neeli
2026-11-12 18:46 ` [PATCH net-next v4 4/8] net: xilinx: tsn: parse endpoint DMA channel configuration Srinivas Neeli
2026-11-17 13:14   ` netdev-bot+sashiko
2026-11-12 18:46 ` [PATCH net-next v4 5/8] net: xilinx: tsn: bring up the endpoint MCDMA channels Srinivas Neeli
2026-11-12 18:46 ` [PATCH net-next v4 6/8] net: xilinx: tsn: add the endpoint RX data path Srinivas Neeli
2026-11-17 13:14   ` netdev-bot+sashiko
2026-11-12 18:46 ` [PATCH net-next v4 7/8] net: xilinx: tsn: add the endpoint TX " Srinivas Neeli
2026-11-17 13:14   ` netdev-bot+sashiko
2026-11-12 18:46 ` [PATCH net-next v4 8/8] net: xilinx: tsn: deliver endpoint RX frames to DSA user ports Srinivas Neeli

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=179492128316.3136.9240121203954125694@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=git@amd.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=michal.simek@amd.com \
    --cc=nagadheeraj.rottela@amd.com \
    --cc=neelisrinivas18@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=robh@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=srinivas.neeli@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