netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata()
@ 2017-08-15  6:33 Zhu Yanjun
       [not found] ` <1502778786-14738-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  2017-08-15  7:13 ` Leon Romanovsky
  0 siblings, 2 replies; 7+ messages in thread
From: Zhu Yanjun @ 2017-08-15  6:33 UTC (permalink / raw)
  To: saeedm-VPRAkNaXOzVWk0Htik3J/w, matanb-VPRAkNaXOzVWk0Htik3J/w,
	leonro-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA

The driver core clears the driver data to NULL after device_release
or on probe failure. Thus, it is not necessary to manually clear the
device driver data to NULL.

Cc: Joe Jin <joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: Junxiao Bi <junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 09b9bc1..df9b0ef 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -3782,7 +3782,6 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data,
 
 err_disable_pdev:
 	mlx4_pci_disable_device(&priv->dev);
-	pci_set_drvdata(pdev, NULL);
 	return err;
 }
 
@@ -3997,7 +3996,6 @@ static void mlx4_remove_one(struct pci_dev *pdev)
 	devlink_unregister(devlink);
 	kfree(dev->persist);
 	devlink_free(devlink);
-	pci_set_drvdata(pdev, NULL);
 }
 
 static int restore_current_port_types(struct mlx4_dev *dev,
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] mlx5: remove unnecessary pci_set_drvdata()
       [not found] ` <1502778786-14738-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
@ 2017-08-15  6:33   ` Zhu Yanjun
       [not found]     ` <1502778786-14738-2-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  2017-08-15 23:46   ` [PATCH 1/2] mlx4: " David Miller
  1 sibling, 1 reply; 7+ messages in thread
From: Zhu Yanjun @ 2017-08-15  6:33 UTC (permalink / raw)
  To: saeedm-VPRAkNaXOzVWk0Htik3J/w, matanb-VPRAkNaXOzVWk0Htik3J/w,
	leonro-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA

The driver core clears the driver data to NULL after device_release
or on probe failure. Thus, it is not necessary to manually clear the
device driver data to NULL.

Cc: Joe Jin <joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: Junxiao Bi <junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index c065132..2cafbdc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1407,7 +1407,6 @@ static int init_one(struct pci_dev *pdev,
 	cleanup_srcu_struct(&priv->pfault_srcu);
 clean_dev:
 #endif
-	pci_set_drvdata(pdev, NULL);
 	devlink_free(devlink);
 
 	return err;
@@ -1434,7 +1433,6 @@ static void remove_one(struct pci_dev *pdev)
 #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
 	cleanup_srcu_struct(&priv->pfault_srcu);
 #endif
-	pci_set_drvdata(pdev, NULL);
 	devlink_free(devlink);
 }
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata()
  2017-08-15  6:33 [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata() Zhu Yanjun
       [not found] ` <1502778786-14738-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
@ 2017-08-15  7:13 ` Leon Romanovsky
  2017-08-15 17:21   ` Jason Gunthorpe
  1 sibling, 1 reply; 7+ messages in thread
From: Leon Romanovsky @ 2017-08-15  7:13 UTC (permalink / raw)
  To: Zhu Yanjun; +Cc: saeedm, matanb, netdev, linux-rdma, yuval.shaia

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

On Tue, Aug 15, 2017 at 02:33:05AM -0400, Zhu Yanjun wrote:
> The driver core clears the driver data to NULL after device_release
> or on probe failure. Thus, it is not necessary to manually clear the
> device driver data to NULL.
>

It makes sense and I'm pretty sure that you are right, but I'm failing
to find the function in device core which sets it to NULL. Can you help
me and present the actual call stack to that code place?

Thanks,

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata()
  2017-08-15  7:13 ` Leon Romanovsky
@ 2017-08-15 17:21   ` Jason Gunthorpe
       [not found]     ` <20170815172149.GC15171-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Gunthorpe @ 2017-08-15 17:21 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Zhu Yanjun, saeedm, matanb, netdev, linux-rdma, yuval.shaia

On Tue, Aug 15, 2017 at 10:13:36AM +0300, Leon Romanovsky wrote:
> On Tue, Aug 15, 2017 at 02:33:05AM -0400, Zhu Yanjun wrote:
> > The driver core clears the driver data to NULL after device_release
> > or on probe failure. Thus, it is not necessary to manually clear the
> > device driver data to NULL.
> >
> 
> It makes sense and I'm pretty sure that you are right, but I'm failing
> to find the function in device core which sets it to NULL. Can you help
> me and present the actual call stack to that code place?

http://elixir.free-electrons.com/linux/v4.13-rc1/source/drivers/base/dd.c#L840

The call to the remove callback is on line 833.

This is done after dropping devres, so you could allocate the drv data
inside a devm object and everything would unwind correctly.

In this case, the kfree is explicit, so I would advocate for still putting
the null near the kfree to minimize the time where a free'd pointer is
present - eg incase a devm callback or some other bug accidently
touches it.

Jason

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata()
       [not found]     ` <20170815172149.GC15171-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2017-08-15 18:00       ` Leon Romanovsky
  0 siblings, 0 replies; 7+ messages in thread
From: Leon Romanovsky @ 2017-08-15 18:00 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Zhu Yanjun, saeedm-VPRAkNaXOzVWk0Htik3J/w,
	matanb-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA

[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]

On Tue, Aug 15, 2017 at 11:21:49AM -0600, Jason Gunthorpe wrote:
> On Tue, Aug 15, 2017 at 10:13:36AM +0300, Leon Romanovsky wrote:
> > On Tue, Aug 15, 2017 at 02:33:05AM -0400, Zhu Yanjun wrote:
> > > The driver core clears the driver data to NULL after device_release
> > > or on probe failure. Thus, it is not necessary to manually clear the
> > > device driver data to NULL.
> > >
> >
> > It makes sense and I'm pretty sure that you are right, but I'm failing
> > to find the function in device core which sets it to NULL. Can you help
> > me and present the actual call stack to that code place?
>
> http://elixir.free-electrons.com/linux/v4.13-rc1/source/drivers/base/dd.c#L840
>
> The call to the remove callback is on line 833.
>
> This is done after dropping devres, so you could allocate the drv data
> inside a devm object and everything would unwind correctly.

Thanks for the pointer. Will it be called in case of failure during
initialization too?

>
> In this case, the kfree is explicit, so I would advocate for still putting
> the null near the kfree to minimize the time where a free'd pointer is
> present - eg incase a devm callback or some other bug accidently
> touches it.
>
> Jason

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata()
       [not found] ` <1502778786-14738-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  2017-08-15  6:33   ` [PATCH 2/2] mlx5: " Zhu Yanjun
@ 2017-08-15 23:46   ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2017-08-15 23:46 UTC (permalink / raw)
  To: yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA
  Cc: saeedm-VPRAkNaXOzVWk0Htik3J/w, matanb-VPRAkNaXOzVWk0Htik3J/w,
	leonro-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA

From: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Date: Tue, 15 Aug 2017 02:33:05 -0400

> The driver core clears the driver data to NULL after device_release
> or on probe failure. Thus, it is not necessary to manually clear the
> device driver data to NULL.
> 
> Cc: Joe Jin <joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Cc: Junxiao Bi <junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] mlx5: remove unnecessary pci_set_drvdata()
       [not found]     ` <1502778786-14738-2-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
@ 2017-08-15 23:47       ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-08-15 23:47 UTC (permalink / raw)
  To: yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA
  Cc: saeedm-VPRAkNaXOzVWk0Htik3J/w, matanb-VPRAkNaXOzVWk0Htik3J/w,
	leonro-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA

From: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Date: Tue, 15 Aug 2017 02:33:06 -0400

> The driver core clears the driver data to NULL after device_release
> or on probe failure. Thus, it is not necessary to manually clear the
> device driver data to NULL.
> 
> Cc: Joe Jin <joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Cc: Junxiao Bi <junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-08-15 23:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-15  6:33 [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata() Zhu Yanjun
     [not found] ` <1502778786-14738-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-08-15  6:33   ` [PATCH 2/2] mlx5: " Zhu Yanjun
     [not found]     ` <1502778786-14738-2-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-08-15 23:47       ` David Miller
2017-08-15 23:46   ` [PATCH 1/2] mlx4: " David Miller
2017-08-15  7:13 ` Leon Romanovsky
2017-08-15 17:21   ` Jason Gunthorpe
     [not found]     ` <20170815172149.GC15171-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-08-15 18:00       ` Leon Romanovsky

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).