2020-01-06 02:35:55

by Jiping Ma

[permalink] [raw]
Subject: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.

Add one notifier for udev changes net device name.

Signed-off-by: Jiping Ma <[email protected]>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b14f46a57154..8d927e455123 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -104,6 +104,7 @@ MODULE_PARM_DESC(chain_mode, "To use chain instead of ring mode");
static irqreturn_t stmmac_interrupt(int irq, void *dev_id);

#ifdef CONFIG_DEBUG_FS
+static const struct net_device_ops stmmac_netdev_ops;
static int stmmac_init_fs(struct net_device *dev);
static void stmmac_exit_fs(struct net_device *dev);
#endif
@@ -4038,6 +4039,34 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
}
DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);

+/* Use network device events to rename debugfs file entries.
+ */
+static int stmmac_device_event(struct notifier_block *unused,
+ unsigned long event, void *ptr)
+{
+ struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+ struct stmmac_priv *priv = netdev_priv(dev);
+
+ if (dev->netdev_ops != &stmmac_netdev_ops)
+ goto done;
+
+ switch (event) {
+ case NETDEV_CHANGENAME:
+ if (priv->dbgfs_dir)
+ priv->dbgfs_dir = debugfs_rename(stmmac_fs_dir,
+ priv->dbgfs_dir,
+ stmmac_fs_dir,
+ dev->name);
+ break;
+ }
+done:
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block stmmac_notifier = {
+ .notifier_call = stmmac_device_event,
+};
+
static int stmmac_init_fs(struct net_device *dev)
{
struct stmmac_priv *priv = netdev_priv(dev);
@@ -4076,6 +4105,8 @@ static int stmmac_init_fs(struct net_device *dev)
return -ENOMEM;
}

+ register_netdevice_notifier(&stmmac_notifier);
+
return 0;
}

@@ -4083,6 +4114,7 @@ static void stmmac_exit_fs(struct net_device *dev)
{
struct stmmac_priv *priv = netdev_priv(dev);

+ unregister_netdevice_notifier(&stmmac_notifier);
debugfs_remove_recursive(priv->dbgfs_dir);
}
#endif /* CONFIG_DEBUG_FS */
--
2.23.0


2020-01-06 21:47:08

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.

From: Jiping Ma <[email protected]>
Date: Mon, 6 Jan 2020 10:33:41 +0800

> Add one notifier for udev changes net device name.
>
> Signed-off-by: Jiping Ma <[email protected]>

This doesn't apply to 'net' and since this is a bug fix that is where
you should target this change.

Thank you.

2020-01-07 01:05:53

by Jiping Ma

[permalink] [raw]
Subject: Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.



On 01/07/2020 05:45 AM, David Miller wrote:
> From: Jiping Ma <[email protected]>
> Date: Mon, 6 Jan 2020 10:33:41 +0800
>
>> Add one notifier for udev changes net device name.
>>
>> Signed-off-by: Jiping Ma <[email protected]>
> This doesn't apply to 'net' and since this is a bug fix that is where
> you should target this change.
What's the next step that I can do?
> Thank you.
>
>

2020-01-07 02:24:18

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.

From: Jiping Ma <[email protected]>
Date: Tue, 7 Jan 2020 09:00:53 +0800

>
>
> On 01/07/2020 05:45 AM, David Miller wrote:
>> From: Jiping Ma <[email protected]>
>> Date: Mon, 6 Jan 2020 10:33:41 +0800
>>
>>> Add one notifier for udev changes net device name.
>>>
>>> Signed-off-by: Jiping Ma <[email protected]>
>> This doesn't apply to 'net' and since this is a bug fix that is where
>> you should target this change.
> What's the next step that I can do?

Respin your patch against the net GIT tree so that it applies clean.y

2020-01-07 03:02:25

by Jiping Ma

[permalink] [raw]
Subject: Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.



On 01/07/2020 10:22 AM, David Miller wrote:
> From: Jiping Ma <[email protected]>
> Date: Tue, 7 Jan 2020 09:00:53 +0800
>
>>
>> On 01/07/2020 05:45 AM, David Miller wrote:
>>> From: Jiping Ma <[email protected]>
>>> Date: Mon, 6 Jan 2020 10:33:41 +0800
>>>
>>>> Add one notifier for udev changes net device name.
>>>>
>>>> Signed-off-by: Jiping Ma <[email protected]>
>>> This doesn't apply to 'net' and since this is a bug fix that is where
>>> you should target this change.
>> What's the next step that I can do?
> Respin your patch against the net GIT tree so that it applies clean.y
OK, I will generate the new patch based on the latest linux kernel code.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Thanks,

2020-01-07 04:45:45

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.



On 1/6/2020 6:59 PM, Jiping Ma wrote:
>
>
> On 01/07/2020 10:22 AM, David Miller wrote:
>> From: Jiping Ma <[email protected]>
>> Date: Tue, 7 Jan 2020 09:00:53 +0800
>>
>>>
>>> On 01/07/2020 05:45 AM, David Miller wrote:
>>>> From: Jiping Ma <[email protected]>
>>>> Date: Mon, 6 Jan 2020 10:33:41 +0800
>>>>
>>>>> Add one notifier for udev changes net device name.
>>>>>
>>>>> Signed-off-by: Jiping Ma <[email protected]>
>>>> This doesn't apply to 'net' and since this is a bug fix that is where
>>>> you should target this change.
>>> What's the next step that I can do?
>> Respin your patch against the net GIT tree so that it applies clean.y
> OK, I will generate the new patch based on the latest linux kernel code.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

That is not quite the tree you should be using, you should be using the
"net" tree, which is here:

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/

and here are some useful pieces of information in the netdev FAQ:

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/tree/Documentation/networking/netdev-FAQ.rst#n28

Also, since this is not the version version of your patch, please make
sure your subject indicates this is not the first version, I have lost
count of the exact number of times you submitted this already (4?) so
this could be [PATCH net v5] in the subject or something like that.

Given you fix a bug please also provide an appropriate Fixes tag, which
should be:

Fixes: 466c5ac8bdf2 ("net: stmmac: create one debugfs dir per net-device")
--
Florian

2020-01-07 21:24:59

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.

From: Jiping Ma <[email protected]>
Date: Tue, 7 Jan 2020 10:59:22 +0800

>
>
> On 01/07/2020 10:22 AM, David Miller wrote:
>> From: Jiping Ma <[email protected]>
>> Date: Tue, 7 Jan 2020 09:00:53 +0800
>>
>>>
>>> On 01/07/2020 05:45 AM, David Miller wrote:
>>>> From: Jiping Ma <[email protected]>
>>>> Date: Mon, 6 Jan 2020 10:33:41 +0800
>>>>
>>>>> Add one notifier for udev changes net device name.
>>>>>
>>>>> Signed-off-by: Jiping Ma <[email protected]>
>>>> This doesn't apply to 'net' and since this is a bug fix that is where
>>>> you should target this change.
>>> What's the next step that I can do?
>> Respin your patch against the net GIT tree so that it applies clean.y
> OK, I will generate the new patch based on the latest linux kernel
> code.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

That's not the networking GIT tree.