Netdev Archive on lore.kernel.org
 help / color / Atom feed
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: Yuusuke Ashizuka <ashiduka@fujitsu.com>,
	"sergei.shtylyov@gmail.com" <sergei.shtylyov@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH v2] ravb: Fixed the problem that rmmod can not be done
Date: Thu, 30 Jul 2020 11:37:44 +0000
Message-ID: <TY2PR01MB36928342A37492E8694A7625D8710@TY2PR01MB3692.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20200730100151.7490-1-ashiduka@fujitsu.com>

Hi Ashizuka-san,

> From: Yuusuke Ashizuka, Sent: Thursday, July 30, 2020 7:02 PM
> Subject: [PATCH v2] ravb: Fixed the problem that rmmod can not be done

Thank you for the patch! I found a similar patch for another driver [1].
So, we should apply this patch to the ravb driver.

[1]
fd5f375c1628 ("net-next: ax88796: Attach MII bus only when open")

> ravb is a module driver, but I cannot rmmod it after insmod it.

I think "When this driver is a module, I cannot ..." is better.

> ravb does mdio_init() at the time of probe, and module->refcnt is incremented

I think "This is because that this driver calls ravb_mdio_init() ..." is better.

According to scripts/checkpatch.pl, I think it's better to be a maximum
75 chars per line in the commit description.

> by alloc_mdio_bitbang() called after that.
> Therefore, even if ifup is not performed, the driver is in use and rmmod cannot
> be performed.
> 
> $ lsmod
> Module                  Size  Used by
> ravb                   40960  1
> $ rmmod ravb
> rmmod: ERROR: Module ravb is in use
> 
> Fixed to execute mdio_init() at open and free_mdio() at close, thereby rmmod is

I think "Fixed to call ravb_mdio_init() at open and ravb_mdio_release() ..." is better.
However, I'm not sure whether that Sergei who is the reviwer of this driver accepts
the descriptions which I suggested though :)

By the way, I think you have to send this patch to the following maintainers too:
# We can get it by using scripts/get_maintainers.pl.
David S. Miller <davem@davemloft.net> (maintainer:NETWORKING DRIVERS,commit_signer:8/8=100%)
Jakub Kicinski <kuba@kernel.org> (maintainer:NETWORKING DRIVERS)

Best regards,
Yoshihiro Shimoda

> possible in the ifdown state.
> 
> Signed-off-by: Yuusuke Ashizuka <ashiduka@fujitsu.com>
> ---
> Changes in v2:
>  - Fix build error
> 
>  drivers/net/ethernet/renesas/ravb_main.c | 110 +++++++++++------------
>  1 file changed, 55 insertions(+), 55 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 99f7aae102ce..df89d09b253e 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -1342,6 +1342,51 @@ static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler,
>  	return error;
>  }
> 
> +/* MDIO bus init function */
> +static int ravb_mdio_init(struct ravb_private *priv)
> +{
> +	struct platform_device *pdev = priv->pdev;
> +	struct device *dev = &pdev->dev;
> +	int error;
> +
> +	/* Bitbang init */
> +	priv->mdiobb.ops = &bb_ops;
> +
> +	/* MII controller setting */
> +	priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb);
> +	if (!priv->mii_bus)
> +		return -ENOMEM;
> +
> +	/* Hook up MII support for ethtool */
> +	priv->mii_bus->name = "ravb_mii";
> +	priv->mii_bus->parent = dev;
> +	snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
> +		 pdev->name, pdev->id);
> +
> +	/* Register MDIO bus */
> +	error = of_mdiobus_register(priv->mii_bus, dev->of_node);
> +	if (error)
> +		goto out_free_bus;
> +
> +	return 0;
> +
> +out_free_bus:
> +	free_mdio_bitbang(priv->mii_bus);
> +	return error;
> +}
> +
> +/* MDIO bus release function */
> +static int ravb_mdio_release(struct ravb_private *priv)
> +{
> +	/* Unregister mdio bus */
> +	mdiobus_unregister(priv->mii_bus);
> +
> +	/* Free bitbang info */
> +	free_mdio_bitbang(priv->mii_bus);
> +
> +	return 0;
> +}
> +
>  /* Network device open function for Ethernet AVB */
>  static int ravb_open(struct net_device *ndev)
>  {
> @@ -1350,6 +1395,13 @@ static int ravb_open(struct net_device *ndev)
>  	struct device *dev = &pdev->dev;
>  	int error;
> 
> +	/* MDIO bus init */
> +	error = ravb_mdio_init(priv);
> +	if (error) {
> +		netdev_err(ndev, "failed to initialize MDIO\n");
> +		return error;
> +	}
> +
>  	napi_enable(&priv->napi[RAVB_BE]);
>  	napi_enable(&priv->napi[RAVB_NC]);
> 
> @@ -1427,6 +1479,7 @@ static int ravb_open(struct net_device *ndev)
>  out_napi_off:
>  	napi_disable(&priv->napi[RAVB_NC]);
>  	napi_disable(&priv->napi[RAVB_BE]);
> +	ravb_mdio_release(priv);
>  	return error;
>  }
> 
> @@ -1736,6 +1789,8 @@ static int ravb_close(struct net_device *ndev)
>  	ravb_ring_free(ndev, RAVB_BE);
>  	ravb_ring_free(ndev, RAVB_NC);
> 
> +	ravb_mdio_release(priv);
> +
>  	return 0;
>  }
> 
> @@ -1887,51 +1942,6 @@ static const struct net_device_ops ravb_netdev_ops = {
>  	.ndo_set_features	= ravb_set_features,
>  };
> 
> -/* MDIO bus init function */
> -static int ravb_mdio_init(struct ravb_private *priv)
> -{
> -	struct platform_device *pdev = priv->pdev;
> -	struct device *dev = &pdev->dev;
> -	int error;
> -
> -	/* Bitbang init */
> -	priv->mdiobb.ops = &bb_ops;
> -
> -	/* MII controller setting */
> -	priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb);
> -	if (!priv->mii_bus)
> -		return -ENOMEM;
> -
> -	/* Hook up MII support for ethtool */
> -	priv->mii_bus->name = "ravb_mii";
> -	priv->mii_bus->parent = dev;
> -	snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
> -		 pdev->name, pdev->id);
> -
> -	/* Register MDIO bus */
> -	error = of_mdiobus_register(priv->mii_bus, dev->of_node);
> -	if (error)
> -		goto out_free_bus;
> -
> -	return 0;
> -
> -out_free_bus:
> -	free_mdio_bitbang(priv->mii_bus);
> -	return error;
> -}
> -
> -/* MDIO bus release function */
> -static int ravb_mdio_release(struct ravb_private *priv)
> -{
> -	/* Unregister mdio bus */
> -	mdiobus_unregister(priv->mii_bus);
> -
> -	/* Free bitbang info */
> -	free_mdio_bitbang(priv->mii_bus);
> -
> -	return 0;
> -}
> -
>  static const struct of_device_id ravb_match_table[] = {
>  	{ .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 },
>  	{ .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 },
> @@ -2174,13 +2184,6 @@ static int ravb_probe(struct platform_device *pdev)
>  		eth_hw_addr_random(ndev);
>  	}
> 
> -	/* MDIO bus init */
> -	error = ravb_mdio_init(priv);
> -	if (error) {
> -		dev_err(&pdev->dev, "failed to initialize MDIO\n");
> -		goto out_dma_free;
> -	}
> -
>  	netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll, 64);
>  	netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll, 64);
> 
> @@ -2202,8 +2205,6 @@ static int ravb_probe(struct platform_device *pdev)
>  out_napi_del:
>  	netif_napi_del(&priv->napi[RAVB_NC]);
>  	netif_napi_del(&priv->napi[RAVB_BE]);
> -	ravb_mdio_release(priv);
> -out_dma_free:
>  	dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
>  			  priv->desc_bat_dma);
> 
> @@ -2235,7 +2236,6 @@ static int ravb_remove(struct platform_device *pdev)
>  	unregister_netdev(ndev);
>  	netif_napi_del(&priv->napi[RAVB_NC]);
>  	netif_napi_del(&priv->napi[RAVB_BE]);
> -	ravb_mdio_release(priv);
>  	pm_runtime_disable(&pdev->dev);
>  	free_netdev(ndev);
>  	platform_set_drvdata(pdev, NULL);
> --
> 2.17.1


  reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30  3:56 [PATCH] " Yuusuke Ashizuka
2020-07-30  7:55 ` kernel test robot
2020-07-30 10:01 ` [PATCH v2] " Yuusuke Ashizuka
2020-07-30 11:37   ` Yoshihiro Shimoda [this message]
2020-07-30 16:24     ` Sergei Shtylyov
2020-07-31  6:43       ` Yoshihiro Shimoda
2020-07-31 17:45         ` Sergei Shtylyov
2020-07-30 16:04   ` Sergei Shtylyov
2020-07-31 10:18     ` ashiduka
2020-07-31 16:28       ` Sergei Shtylyov
2020-08-06  2:26         ` ashiduka
2020-07-31 18:32   ` Sergei Shtylyov
2020-08-06  2:28     ` ashiduka

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=TY2PR01MB36928342A37492E8694A7625D8710@TY2PR01MB3692.jpnprd01.prod.outlook.com \
    --to=yoshihiro.shimoda.uh@renesas.com \
    --cc=ashiduka@fujitsu.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@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

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git