netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jens Axboe <axboe@kernel.dk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [net-next PATCH v3 01/14] net: dsa: qca8k: cache match data to speed up access
Date: Sun, 24 Jul 2022 22:42:20 +0200	[thread overview]
Message-ID: <62ddd221.1c69fb81.95457.a4ee@mx.google.com> (raw)
In-Reply-To: <20220724230626.rzynvd2pxdcd2z3r@skbuf>

On Mon, Jul 25, 2022 at 02:06:26AM +0300, Vladimir Oltean wrote:
> On Sun, Jul 24, 2022 at 10:27:13PM +0200, Christian Marangi wrote:
> > > > diff --git a/drivers/net/dsa/qca/qca8k.c b/drivers/net/dsa/qca/qca8k.c
> > > > index 1cbb05b0323f..212b284f9f73 100644
> > > > --- a/drivers/net/dsa/qca/qca8k.c
> > > > +++ b/drivers/net/dsa/qca/qca8k.c
> > > > @@ -3168,6 +3155,11 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
> > > >  	if (ret)
> > > >  		return ret;
> > > >  
> > > > +	/* Cache match data in priv struct.
> > > > +	 * Match data is already checked in read_switch_id.
> > > > +	 */
> > > > +	priv->info = of_device_get_match_data(priv->dev);
> > > > +
> > > 
> > > So why don't you set priv->info right before calling qca8k_read_switch_id(),
> > > then?
> > > 
> > 
> > The idea was to make the read_switch_id a function to check if the
> > switch is compatible... But yhea now that i think about it doesn't
> > really make sense.
> 
> I am not saying qca8k_read_switch_id() should do anything more than
> reading the switch id. I am saying why can't qca8k_read_switch_id()
> already find priv->info be pre-populated, just like any other function.
> Why don't you set priv->info a lot earlier, see below.
>

Sure, it was just a stupid idea to set everything not strictly neeeded
only after verifying that we have a correct switch... But it doesn't
make sense as qca8k_priv is freed anyway if that's the case.

Will do the change in v5.

> diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
> index fa91517e930b..590ff810c95e 100644
> --- a/drivers/net/dsa/qca/qca8k-8xxx.c
> +++ b/drivers/net/dsa/qca/qca8k-8xxx.c
> @@ -1892,6 +1892,7 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
>  
>  	priv->bus = mdiodev->bus;
>  	priv->dev = &mdiodev->dev;
> +	priv->info = of_device_get_match_data(priv->dev);
>  
>  	priv->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset",
>  						   GPIOD_ASIS);
> @@ -1924,11 +1925,6 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
>  	if (ret)
>  		return ret;
>  
> -	/* Cache match data in priv struct.
> -	 * Match data is already checked in read_switch_id.
> -	 */
> -	priv->info = of_device_get_match_data(priv->dev);
> -
>  	priv->ds = devm_kzalloc(&mdiodev->dev, sizeof(*priv->ds), GFP_KERNEL);
>  	if (!priv->ds)
>  		return -ENOMEM;
> diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c
> index e6294d6a7b8f..8f634edc52c2 100644
> --- a/drivers/net/dsa/qca/qca8k-common.c
> +++ b/drivers/net/dsa/qca/qca8k-common.c
> @@ -1211,23 +1211,19 @@ qca8k_port_lag_leave(struct dsa_switch *ds, int port,
>  
>  int qca8k_read_switch_id(struct qca8k_priv *priv)
>  {
> -	const struct qca8k_match_data *data;
>  	u32 val;
>  	u8 id;
>  	int ret;
>  
> -	/* get the switches ID from the compatible */
> -	data = of_device_get_match_data(priv->dev);
> -	if (!data)
> -		return -ENODEV;
> -
>  	ret = qca8k_read(priv, QCA8K_REG_MASK_CTRL, &val);
>  	if (ret < 0)
>  		return -ENODEV;
>  
>  	id = QCA8K_MASK_CTRL_DEVICE_ID(val);
> -	if (id != data->id) {
> -		dev_err(priv->dev, "Switch id detected %x but expected %x", id, data->id);
> +	if (id != priv->info->id) {
> +		dev_err(priv->dev,
> +			"Switch id detected %x but expected %x",
> +			id, priv->info->id);
>  		return -ENODEV;
>  	}
>  
> 
> Also note how the "Switch id detected ... but expected ..." message
> lacks a trailing \n.
> 

Will fix this when the read_switch_id function is moved to common file.

> > (Just for reference I just sent v4 as I got a report from kernel test
> > bot... it's really just this series with a change in 0002 patch that set
> > the struct for ops as a pointer... didn't encounter this with gcc but it
> > seems kernel test bot use some special config...)
> 
> Yea, I was still kinda reviewing v3... Anyway, now you'll have to wait
> for me to finish my v3 feedback on the v4, and then send the v5 after at
> least 24 more hours.

Sure and sorry for the mess.

-- 
	Ansuel

  reply	other threads:[~2022-07-24 23:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-23 14:18 [net-next PATCH v3 00/14] net: dsa: qca8k: code split for qca8k Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 01/14] net: dsa: qca8k: cache match data to speed up access Christian Marangi
2022-07-24 22:30   ` Vladimir Oltean
2022-07-24 20:27     ` Christian Marangi
2022-07-24 23:06       ` Vladimir Oltean
2022-07-24 20:42         ` Christian Marangi [this message]
2022-07-24 23:18           ` Vladimir Oltean
2022-07-24 20:49             ` Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 02/14] net: dsa: qca8k: make mib autocast feature optional Christian Marangi
2022-07-24 22:33   ` Vladimir Oltean
2022-07-24 20:29     ` Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 03/14] net: dsa: qca8k: move mib struct to common code Christian Marangi
2022-07-23 23:52   ` kernel test robot
2022-07-23 14:18 ` [net-next PATCH v3 04/14] net: dsa: qca8k: move qca8k read/write/rmw and reg table " Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 05/14] net: dsa: qca8k: move qca8k bulk read/write helper " Christian Marangi
2022-07-26  0:11   ` Vladimir Oltean
2022-07-23 14:18 ` [net-next PATCH v3 06/14] net: dsa: qca8k: move mib init function " Christian Marangi
2022-07-26  0:13   ` Vladimir Oltean
2022-07-23 14:18 ` [net-next PATCH v3 07/14] net: dsa: qca8k: move port set status/eee/ethtool stats " Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 08/14] net: dsa: qca8k: move bridge functions " Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 09/14] net: dsa: qca8k: move set age/MTU/port enable/disable " Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 10/14] net: dsa: qca8k: move port FDB/MDB function " Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 11/14] net: dsa: qca8k: move port mirror functions " Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 12/14] net: dsa: qca8k: move port VLAN " Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 13/14] net: dsa: qca8k: move port LAG " Christian Marangi
2022-07-23 14:18 ` [net-next PATCH v3 14/14] net: dsa: qca8k: move read_switch_id function " Christian Marangi

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=62ddd221.1c69fb81.95457.a4ee@mx.google.com \
    --to=ansuelsmth@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=vivien.didelot@gmail.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).