Skip to contentSkip to conversation

driver_core: Auxiliary drvdata helper cleanup

PATCH In review David E. Box 5 participants 14 messages Dec 21, 2021 – Dec 22, 2021

Subsystems (10)
lore
Share & tools
lore
#1 lore raw

PATCH 1/4 RDMA/irdma: Use auxiliary_device driver data helpers

In reply to David E. Box

Use auxiliary_get_drvdata and auxiliary_set_drvdata helpers.

---
 drivers/infiniband/hw/irdma/main.c | 4 ++--
 drivers/infiniband/hw/mlx5/main.c  | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/infiniband/hw/irdma/main.c +2 -2
index 51a41359e0b4..9ccf4d683f8a 100644
@@ -207,7 +207,7 @@ static void irdma_remove(struct auxiliary_device *aux_dev)
 							    struct iidc_auxiliary_dev,
 							    adev);
 	struct ice_pf *pf = iidc_adev->pf;
-	struct irdma_device *iwdev = dev_get_drvdata(&aux_dev->dev);
+	struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev);
 
 	irdma_ib_unregister_device(iwdev);
 	ice_rdma_update_vsi_filter(pf, iwdev->vsi_num, false);
@@ -294,7 +294,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
 	ice_rdma_update_vsi_filter(pf, iwdev->vsi_num, true);
 
 	ibdev_dbg(&iwdev->ibdev, "INIT: Gen2 PF[%d] device probe success\n", PCI_FUNC(rf->pcidev->devfn));
-	dev_set_drvdata(&aux_dev->dev, iwdev);
+	auxiliary_set_drvdata(aux_dev, iwdev);
 
 	return 0;
 
drivers/infiniband/hw/mlx5/main.c +4 -4
index 5ec8bd2f0b2f..85f526c861e9 100644
@@ -4422,7 +4422,7 @@ static int mlx5r_mp_probe(struct auxiliary_device *adev,
 	}
 	mutex_unlock(&mlx5_ib_multiport_mutex);
 
-	dev_set_drvdata(&adev->dev, mpi);
+	auxiliary_set_drvdata(adev, mpi);
 	return 0;
 }
 
@@ -4430,7 +4430,7 @@ static void mlx5r_mp_remove(struct auxiliary_device *adev)
 {
 	struct mlx5_ib_multiport_info *mpi;
 
-	mpi = dev_get_drvdata(&adev->dev);
+	mpi = auxiliary_get_drvdata(adev);
 	mutex_lock(&mlx5_ib_multiport_mutex);
 	if (mpi->ibdev)
 		mlx5_ib_unbind_slave_port(mpi->ibdev, mpi);
@@ -4480,7 +4480,7 @@ static int mlx5r_probe(struct auxiliary_device *adev,
 		return ret;
 	}
 
-	dev_set_drvdata(&adev->dev, dev);
+	auxiliary_set_drvdata(adev, dev);
 	return 0;
 }
 
@@ -4488,7 +4488,7 @@ static void mlx5r_remove(struct auxiliary_device *adev)
 {
 	struct mlx5_ib_dev *dev;
 
-	dev = dev_get_drvdata(&adev->dev);
+	dev = auxiliary_get_drvdata(adev);
 	__mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX);
 }
 
Signature · 1 line
2.25.1
#0 lore raw

cover driver_core: Auxiliary drvdata helper cleanup

Depends on "driver core: auxiliary bus: Add driver data helpers" patch [1]. Applies the helpers to all auxiliary device drivers using dev_(get/set)_drvdata. Drivers were found using the following search:

    grep -lr "struct auxiliary_device" $(grep -lr "drvdata" .)

Changes were build tested using the following configs:

vdpa/mlx5: CONFIG_MLX5_VDPA_NET
net/mlx53: CONFIG_MLX5_CORE_EN
soundwire/intel: CONFIG_SOUNDWIRE_INTEL
RDAM/irdma: CONFIG_INFINIBAND_IRDMA
CONFIG_MLX5_INFINIBAND

[1] https://www.spinics.net/lists/platform-driver-x86/msg29940.html

David E. Box (4):
RDMA/irdma: Use auxiliary_device driver data helpers
soundwire: intel: Use auxiliary_device driver data helpers net/mlx5e: Use auxiliary_device driver data helpers vdpa/mlx5: Use auxiliary_device driver data helpers

 drivers/infiniband/hw/irdma/main.c                | 4 ++--
 drivers/infiniband/hw/mlx5/main.c                 | 8 ++++----
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 ++++----
 drivers/soundwire/intel.c                         | 8 ++++----
 drivers/soundwire/intel_init.c                    | 2 +-
 drivers/vdpa/mlx5/net/mlx5_vnet.c                 | 4 ++--
 6 files changed, 17 insertions(+), 17 deletions(-)
Signature · 1 line
2.25.1
#4 lore raw

PATCH 2/4 soundwire: intel: Use auxiliary_device driver data helpers

Use auxiliary_get_drvdata and auxiliary_set_drvdata helpers.

---
 drivers/soundwire/intel.c      | 8 ++++----
 drivers/soundwire/intel_init.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/soundwire/intel.c +4 -4
index 78037ffdb09b..d082d18e41a9 100644
@@ -1293,7 +1293,7 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
 	bus->ops = &sdw_intel_ops;
 
 	/* set driver data, accessed by snd_soc_dai_get_drvdata() */
-	dev_set_drvdata(dev, cdns);
+	auxiliary_set_drvdata(auxdev, cdns);
 
 	/* use generic bandwidth allocation algorithm */
 	sdw->cdns.bus.compute_params = sdw_compute_params;
@@ -1321,7 +1321,7 @@ int intel_link_startup(struct auxiliary_device *auxdev)
 {
 	struct sdw_cdns_stream_config config;
 	struct device *dev = &auxdev->dev;
-	struct sdw_cdns *cdns = dev_get_drvdata(dev);
+	struct sdw_cdns *cdns = auxiliary_get_drvdata(auxdev);
 	struct sdw_intel *sdw = cdns_to_intel(cdns);
 	struct sdw_bus *bus = &cdns->bus;
 	int link_flags;
@@ -1463,7 +1463,7 @@ int intel_link_startup(struct auxiliary_device *auxdev)
 static void intel_link_remove(struct auxiliary_device *auxdev)
 {
 	struct device *dev = &auxdev->dev;
-	struct sdw_cdns *cdns = dev_get_drvdata(dev);
+	struct sdw_cdns *cdns = auxiliary_get_drvdata(auxdev);
 	struct sdw_intel *sdw = cdns_to_intel(cdns);
 	struct sdw_bus *bus = &cdns->bus;
 
@@ -1488,7 +1488,7 @@ int intel_link_process_wakeen_event(struct auxiliary_device *auxdev)
 	void __iomem *shim;
 	u16 wake_sts;
 
-	sdw = dev_get_drvdata(dev);
+	sdw = auxiliary_get_drvdata(auxdev);
 	bus = &sdw->cdns.bus;
 
 	if (bus->prop.hw_disabled || !sdw->startup_done) {
drivers/soundwire/intel_init.c +1 -1
index e329022e1669..d99807765dfe 100644
@@ -244,7 +244,7 @@ static struct sdw_intel_ctx
 			goto err;
 
 		link = &ldev->link_res;
-		link->cdns = dev_get_drvdata(&ldev->auxdev.dev);
+		link->cdns = auxiliary_get_drvdata(&ldev->auxdev);
 
 		if (!link->cdns) {
 			dev_err(&adev->dev, "failed to get link->cdns\n");
Signature · 1 line
2.25.1
#6 lore raw

PATCH 3/4 net/mlx5e: Use auxiliary_device driver data helpers

In reply to David E. Box

Use auxiliary_get_drvdata and auxiliary_set_drvdata helpers.

---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -4
index 65571593ec5c..244ce8f4e286 100644
@@ -5389,7 +5389,7 @@ void mlx5e_destroy_netdev(struct mlx5e_priv *priv)
 static int mlx5e_resume(struct auxiliary_device *adev)
 {
 	struct mlx5_adev *edev = container_of(adev, struct mlx5_adev, adev);
-	struct mlx5e_priv *priv = dev_get_drvdata(&adev->dev);
+	struct mlx5e_priv *priv = auxiliary_get_drvdata(adev);
 	struct net_device *netdev = priv->netdev;
 	struct mlx5_core_dev *mdev = edev->mdev;
 	int err;
@@ -5412,7 +5412,7 @@ static int mlx5e_resume(struct auxiliary_device *adev)
 
 static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state)
 {
-	struct mlx5e_priv *priv = dev_get_drvdata(&adev->dev);
+	struct mlx5e_priv *priv = auxiliary_get_drvdata(adev);
 	struct net_device *netdev = priv->netdev;
 	struct mlx5_core_dev *mdev = priv->mdev;
 
@@ -5456,7 +5456,7 @@ static int mlx5e_probe(struct auxiliary_device *adev,
 	mlx5e_build_nic_netdev(netdev);
 
 	priv = netdev_priv(netdev);
-	dev_set_drvdata(&adev->dev, priv);
+	auxiliary_set_drvdata(adev, priv);
 
 	priv->profile = profile;
 	priv->ppriv = NULL;
@@ -5504,7 +5504,7 @@ static int mlx5e_probe(struct auxiliary_device *adev,
 
 static void mlx5e_remove(struct auxiliary_device *adev)
 {
-	struct mlx5e_priv *priv = dev_get_drvdata(&adev->dev);
+	struct mlx5e_priv *priv = auxiliary_get_drvdata(adev);
 	pm_message_t state = {};
 
 	mlx5e_dcbnl_delete_app(priv);
Signature · 1 line
2.25.1
#8 lore raw

PATCH 4/4 vdpa/mlx5: Use auxiliary_device driver data helpers

In reply to David E. Box

Use auxiliary_get_drvdata and auxiliary_set_drvdata helpers.

---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index 63813fbb5f62..cf59f7e17c6d 100644
@@ -2683,7 +2683,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
 	if (err)
 		goto reg_err;
 
-	dev_set_drvdata(&adev->dev, mgtdev);
+	auxiliary_set_drvdata(adev, mgtdev);
 
 	return 0;
 
@@ -2696,7 +2696,7 @@ static void mlx5v_remove(struct auxiliary_device *adev)
 {
 	struct mlx5_vdpa_mgmtdev *mgtdev;
 
-	mgtdev = dev_get_drvdata(&adev->dev);
+	mgtdev = auxiliary_get_drvdata(adev);
 	vdpa_mgmtdev_unregister(&mgtdev->mgtdev);
 	kfree(mgtdev);
 }
Signature · 1 line
2.25.1
#10 lore raw
In reply to David E. Box
Quoted 8 lines · David E. Box

Depends on "driver core: auxiliary bus: Add driver data helpers" patch [1]. Applies the helpers to all auxiliary device drivers using dev_(get/set)_drvdata. Drivers were found using the following search:

    grep -lr "struct auxiliary_device" $(grep -lr "drvdata" .)

Changes were build tested using the following configs:

Quoted 7 lines

vdpa/mlx5: CONFIG_MLX5_VDPA_NET
net/mlx53: CONFIG_MLX5_CORE_EN
soundwire/intel: CONFIG_SOUNDWIRE_INTEL
RDAM/irdma: CONFIG_INFINIBAND_IRDMA
CONFIG_MLX5_INFINIBAND

[1] https://www.spinics.net/lists/platform-driver-x86/msg29940.html

I have to say I don't really find this to be a big readability improvement.

Also, what use is 'to_auxiliary_dev()' ? I didn't see any users added..

Jason

#11 lore raw
Quoted 15 lines · Jason Gunthorpe
Quoted 14 lines · David E. Box

Depends on "driver core: auxiliary bus: Add driver data helpers" patch [1]. Applies the helpers to all auxiliary device drivers using dev_(get/set)_drvdata. Drivers were found using the following search:

    grep -lr "struct auxiliary_device" $(grep -lr "drvdata" .)

Changes were build tested using the following configs:

vdpa/mlx5: CONFIG_MLX5_VDPA_NET
net/mlx53: CONFIG_MLX5_CORE_EN
soundwire/intel: CONFIG_SOUNDWIRE_INTEL
RDAM/irdma: CONFIG_INFINIBAND_IRDMA
CONFIG_MLX5_INFINIBAND

Quoted 4 lines
Quoted 1 line

[1] https://www.spinics.net/lists/platform-driver-x86/msg29940.html

I have to say I don't really find this to be a big readability improvement.

I should have referenced the thread [1] discussing the benefit of this change since the question was asked and answered already. The idea is that drivers shouldn't have to touch the device API directly if they are already using a higher level core API (auxiliary bus) that can do that on its behalf.

One benefit of this scheme is that it limits the number of places where changes need to be made if the device core were to change.

[1] https://lore.kernel.org/all/[email protected]/

Quoted 2 lines

Also, what use is 'to_auxiliary_dev()' ? I didn't see any users added..

This was not added by that patch.

Thanks

David

Quoted 2 lines

Jason

#2 lore raw

Re: [PATCH 1/4] RDMA/irdma: Use auxiliary_device driver data helpers

In reply to David E. Box
I love your patch! Perhaps something to improve:

Hi "David,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on staging/staging-testing linus/master v5.16-rc6 next-20211221] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/David-E-Box/driver_core-Auxiliary-drvdata-helper-cleanup/20211222-080023
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20211222/202112221515.JG78ViIG-lkp(a)intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/a9d461b63d0256caecd213865ac56ffb48b60c48
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review David-E-Box/driver_core-Auxiliary-drvdata-helper-cleanup/20211222-080023
git checkout a9d461b63d0256caecd213865ac56ffb48b60c48
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/infiniband/hw/irdma/ drivers/infiniband/hw/mlx5/ drivers/net/ethernet/mellanox/mlx5/core/ drivers/vdpa/mlx5/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/infiniband/hw/irdma/main.c: In function 'irdma_remove':
drivers/infiniband/hw/irdma/main.c:210:38: error: implicit declaration of function 'auxiliary_get_drvdata' [-Werror=implicit-function-declaration]

     210 |         struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev);
         |                                      ^~~~~~~~~~~~~~~~~~~~~
>> drivers/infiniband/hw/irdma/main.c:210:38: warning: initialization of 'struct irdma_device *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   drivers/infiniband/hw/irdma/main.c: In function 'irdma_probe':
   drivers/infiniband/hw/irdma/main.c:297:9: error: implicit declaration of function 'auxiliary_set_drvdata' [-Werror=implicit-function-declaration]
     297 |         auxiliary_set_drvdata(aux_dev, iwdev);
         |         ^~~~~~~~~~~~~~~~~~~~~

cc1: some warnings being treated as errors
--
drivers/infiniband/hw/mlx5/main.c: In function 'mlx5r_mp_probe':
drivers/infiniband/hw/mlx5/main.c:4425:9: error: implicit declaration of function 'auxiliary_set_drvdata' [-Werror=implicit-function-declaration]

    4425 |         auxiliary_set_drvdata(adev, mpi);
         |         ^~~~~~~~~~~~~~~~~~~~~
   drivers/infiniband/hw/mlx5/main.c: In function 'mlx5r_mp_remove':
   drivers/infiniband/hw/mlx5/main.c:4433:15: error: implicit declaration of function 'auxiliary_get_drvdata' [-Werror=implicit-function-declaration]
    4433 |         mpi = auxiliary_get_drvdata(adev);
         |               ^~~~~~~~~~~~~~~~~~~~~
>> drivers/infiniband/hw/mlx5/main.c:4433:13: warning: assignment to 'struct mlx5_ib_multiport_info *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    4433 |         mpi = auxiliary_get_drvdata(adev);
         |             ^
   drivers/infiniband/hw/mlx5/main.c: In function 'mlx5r_remove':
>> drivers/infiniband/hw/mlx5/main.c:4491:13: warning: assignment to 'struct mlx5_ib_dev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    4491 |         dev = auxiliary_get_drvdata(adev);
         |             ^

cc1: some warnings being treated as errors

vim +210 drivers/infiniband/hw/irdma/main.c

203
204 static void irdma_remove(struct auxiliary_device *aux_dev)
205 {
206 struct iidc_auxiliary_dev *iidc_adev = container_of(aux_dev,
207 struct iidc_auxiliary_dev,
208 adev);
209 struct ice_pf *pf = iidc_adev->pf;

 > 210		struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev);

211
212 irdma_ib_unregister_device(iwdev);
213 ice_rdma_update_vsi_filter(pf, iwdev->vsi_num, false);
214
215 pr_debug("INIT: Gen2 PF[%d] device remove success\n", PCI_FUNC(pf->pdev->devfn));
216 }
217

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#7 lore raw

Re: [PATCH 3/4] net/mlx5e: Use auxiliary_device driver data helpers

In reply to David E. Box
I love your patch! Perhaps something to improve:

Hi "David,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on staging/staging-testing linus/master v5.16-rc6 next-20211221] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/David-E-Box/driver_core-Auxiliary-drvdata-helper-cleanup/20211222-080023
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20211222/202112221705.OaQ9zc1H-lkp(a)intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/1b4157338957cb848baaecc20e2cd01271bb1324
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review David-E-Box/driver_core-Auxiliary-drvdata-helper-cleanup/20211222-080023
git checkout 1b4157338957cb848baaecc20e2cd01271bb1324
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/infiniband/hw/irdma/ drivers/infiniband/hw/mlx5/ drivers/net/ethernet/mellanox/mlx5/core/ drivers/vdpa/mlx5/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/net/ethernet/mellanox/mlx5/core/en_main.c: In function 'mlx5e_resume':
drivers/net/ethernet/mellanox/mlx5/core/en_main.c:5392:35: error: implicit declaration of function 'auxiliary_get_drvdata' [-Werror=implicit-function-declaration]

    5392 |         struct mlx5e_priv *priv = auxiliary_get_drvdata(adev);
         |                                   ^~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/mellanox/mlx5/core/en_main.c:5392:35: warning: initialization of 'struct mlx5e_priv *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c: In function 'mlx5e_suspend':
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c:5415:35: warning: initialization of 'struct mlx5e_priv *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    5415 |         struct mlx5e_priv *priv = auxiliary_get_drvdata(adev);
         |                                   ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c: In function 'mlx5e_probe':
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c:5459:9: error: implicit declaration of function 'auxiliary_set_drvdata' [-Werror=implicit-function-declaration]
    5459 |         auxiliary_set_drvdata(adev, priv);
         |         ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c: In function 'mlx5e_remove':
   drivers/net/ethernet/mellanox/mlx5/core/en_main.c:5507:35: warning: initialization of 'struct mlx5e_priv *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    5507 |         struct mlx5e_priv *priv = auxiliary_get_drvdata(adev);
         |                                   ^~~~~~~~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

vim +5392 drivers/net/ethernet/mellanox/mlx5/core/en_main.c

5388
5389 static int mlx5e_resume(struct auxiliary_device *adev)
5390 {
5391 struct mlx5_adev *edev = container_of(adev, struct mlx5_adev, adev);

> 5392		struct mlx5e_priv *priv = auxiliary_get_drvdata(adev);

5393 struct net_device *netdev = priv->netdev;
5394 struct mlx5_core_dev *mdev = edev->mdev;
5395 int err;
5396
5397 if (netif_device_present(netdev))
5398 return 0;
5399
5400 err = mlx5e_create_mdev_resources(mdev);
5401 if (err)
5402 return err;
5403
5404 err = mlx5e_attach_netdev(priv);
5405 if (err) {
5406 mlx5e_destroy_mdev_resources(mdev);
5407 return err;
5408 }
5409
5410 return 0;
5411 }
5412

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

Reviewed-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] soundwire: intel: Use auxiliary_device driver data helpers

In reply to David E. Box
Quoted 1 line · David E. Box

Use auxiliary_get_drvdata and auxiliary_set_drvdata helpers.

Quoted 62 lines
---
 drivers/soundwire/intel.c      | 8 ++++----
 drivers/soundwire/intel_init.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/soundwire/intel.c +4 -4
index 78037ffdb09b..d082d18e41a9 100644
@@ -1293,7 +1293,7 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
 	bus->ops = &sdw_intel_ops;
 
 	/* set driver data, accessed by snd_soc_dai_get_drvdata() */
-	dev_set_drvdata(dev, cdns);
+	auxiliary_set_drvdata(auxdev, cdns);
 
 	/* use generic bandwidth allocation algorithm */
 	sdw->cdns.bus.compute_params = sdw_compute_params;
@@ -1321,7 +1321,7 @@ int intel_link_startup(struct auxiliary_device *auxdev)
 {
 	struct sdw_cdns_stream_config config;
 	struct device *dev = &auxdev->dev;
-	struct sdw_cdns *cdns = dev_get_drvdata(dev);
+	struct sdw_cdns *cdns = auxiliary_get_drvdata(auxdev);
 	struct sdw_intel *sdw = cdns_to_intel(cdns);
 	struct sdw_bus *bus = &cdns->bus;
 	int link_flags;
@@ -1463,7 +1463,7 @@ int intel_link_startup(struct auxiliary_device *auxdev)
 static void intel_link_remove(struct auxiliary_device *auxdev)
 {
 	struct device *dev = &auxdev->dev;
-	struct sdw_cdns *cdns = dev_get_drvdata(dev);
+	struct sdw_cdns *cdns = auxiliary_get_drvdata(auxdev);
 	struct sdw_intel *sdw = cdns_to_intel(cdns);
 	struct sdw_bus *bus = &cdns->bus;
 
@@ -1488,7 +1488,7 @@ int intel_link_process_wakeen_event(struct auxiliary_device *auxdev)
 	void __iomem *shim;
 	u16 wake_sts;
 
-	sdw = dev_get_drvdata(dev);
+	sdw = auxiliary_get_drvdata(auxdev);
 	bus = &sdw->cdns.bus;
 
 	if (bus->prop.hw_disabled || !sdw->startup_done) {
drivers/soundwire/intel_init.c +1 -1
index e329022e1669..d99807765dfe 100644
@@ -244,7 +244,7 @@ static struct sdw_intel_ctx
 			goto err;
 
 		link = &ldev->link_res;
-		link->cdns = dev_get_drvdata(&ldev->auxdev.dev);
+		link->cdns = auxiliary_get_drvdata(&ldev->auxdev);
 
 		if (!link->cdns) {
 			dev_err(&adev->dev, "failed to get link->cdns\n");
Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH 4/4] vdpa/mlx5: Use auxiliary_device driver data helpers

In reply to David E. Box
I love your patch! Perhaps something to improve:

Hi "David,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on staging/staging-testing linus/master v5.16-rc6 next-20211221] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/David-E-Box/driver_core-Auxiliary-drvdata-helper-cleanup/20211222-080023
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20211222/202112222008.UErq9RfO-lkp(a)intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/2d64ea213a12338ed3706a0ebf6fd7b356bc5a5f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review David-E-Box/driver_core-Auxiliary-drvdata-helper-cleanup/20211222-080023
git checkout 2d64ea213a12338ed3706a0ebf6fd7b356bc5a5f
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/infiniband/hw/irdma/ drivers/infiniband/hw/mlx5/ drivers/net/ethernet/mellanox/mlx5/core/ drivers/vdpa/mlx5/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/vdpa/mlx5/net/mlx5_vnet.c: In function 'mlx5v_probe':
drivers/vdpa/mlx5/net/mlx5_vnet.c:2686:9: error: implicit declaration of function 'auxiliary_set_drvdata' [-Werror=implicit-function-declaration]

    2686 |         auxiliary_set_drvdata(adev, mgtdev);
         |         ^~~~~~~~~~~~~~~~~~~~~
   drivers/vdpa/mlx5/net/mlx5_vnet.c: In function 'mlx5v_remove':
   drivers/vdpa/mlx5/net/mlx5_vnet.c:2699:18: error: implicit declaration of function 'auxiliary_get_drvdata' [-Werror=implicit-function-declaration]
    2699 |         mgtdev = auxiliary_get_drvdata(adev);
         |                  ^~~~~~~~~~~~~~~~~~~~~
>> drivers/vdpa/mlx5/net/mlx5_vnet.c:2699:16: warning: assignment to 'struct mlx5_vdpa_mgmtdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    2699 |         mgtdev = auxiliary_get_drvdata(adev);
         |                ^

cc1: some warnings being treated as errors

vim +2699 drivers/vdpa/mlx5/net/mlx5_vnet.c

2694
2695 static void mlx5v_remove(struct auxiliary_device *adev)
2696 {
2697 struct mlx5_vdpa_mgmtdev *mgtdev;
2698

> 2699		mgtdev = auxiliary_get_drvdata(adev);

2700 vdpa_mgmtdev_unregister(&mgtdev->mgtdev);
2701 kfree(mgtdev);
2702 }
2703

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw

Re: [PATCH 1/4] RDMA/irdma: Use auxiliary_device driver data helpers

In reply to David E. Box

drivers/infiniband/hw/irdma/main.c

Quoted 12 lines · David E. Box

Use auxiliary_get_drvdata and auxiliary_set_drvdata helpers.

---
  drivers/infiniband/hw/irdma/main.c | 4 ++--
  drivers/infiniband/hw/mlx5/main.c  | 8 ++++----
  2 files changed, 6 insertions(+), 6 deletions(-)
drivers/infiniband/hw/irdma/main.c +0 -0
index 51a41359e0b4..9ccf4d683f8a 100644

While two occurrences of aux_dev->dev have been addressed here for irdma/main.c, there is one more that probably could get updated too:

static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidrc_event *event)

{
	struct irdma_device *iwdev = dev_get_drvdata(&pf->adev->dev);

(...)
}

Note: the declaration of struct ice_pf reads:

struct ice_pf {
(...)

	struct auxiliary_device *adev;

(...)
};

leads into suggestion:

	struct  irdma_device *iwdev = auxiliary_get_drvdata(pf->adev);

Of course, even if I'm right about this, such change could be applied with a separate patch and does not block the current review.

Regards,
Czarek

Reviewed-by on the v1 series
#13 lore raw
In reply to David E. Box
Quoted 22 lines · David E. Box

Depends on "driver core: auxiliary bus: Add driver data helpers" patch [1]. Applies the helpers to all auxiliary device drivers using dev_(get/set)_drvdata. Drivers were found using the following search:

     grep -lr "struct auxiliary_device" $(grep -lr "drvdata" .)

Changes were build tested using the following configs:

vdpa/mlx5: CONFIG_MLX5_VDPA_NET
net/mlx53: CONFIG_MLX5_CORE_EN
soundwire/intel: CONFIG_SOUNDWIRE_INTEL
RDAM/irdma: CONFIG_INFINIBAND_IRDMA
CONFIG_MLX5_INFINIBAND

[1] https://www.spinics.net/lists/platform-driver-x86/msg29940.html

David E. Box (4):
RDMA/irdma: Use auxiliary_device driver data helpers
soundwire: intel: Use auxiliary_device driver data helpers net/mlx5e: Use auxiliary_device driver data helpers vdpa/mlx5: Use auxiliary_device driver data helpers

Quoted 7 lines
  drivers/infiniband/hw/irdma/main.c                | 4 ++--
  drivers/infiniband/hw/mlx5/main.c                 | 8 ++++----
  drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 ++++----
  drivers/soundwire/intel.c                         | 8 ++++----
  drivers/soundwire/intel_init.c                    | 2 +-
  drivers/vdpa/mlx5/net/mlx5_vnet.c                 | 4 ++--
  6 files changed, 17 insertions(+), 17 deletions(-)

Changes look good, I did post one question regarding possible occurrence of dev_get_drvdata() not being accounted for in patch:
[PATCH 1/4] RDMA/irdma: Use auxiliary_device driver data helpers

However, it does look like a blocker so:

For the record, I did scan the following files (users of struct auxiliary_device) from drivers/ directory for the missing occurrences and found only a single one (as mentioned earlier):

drivers/net/ethernet/mellanox/mlx5/core/dev.c drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.h drivers/net/ethernet/mellanox/mlx5/core/en_rep.c drivers/net/ethernet/mellanox/mlx5/core/en_main.c drivers/net/ethernet/intel/i40e/i40e_client.c drivers/net/ethernet/intel/ice/ice.h drivers/net/ethernet/intel/ice/ice_idc.c drivers/infiniband/hw/irdma/main.c drivers/infiniband/hw/irdma/i40iw_if.c drivers/infiniband/hw/mlx5/main.c drivers/infiniband/hw/mlx5/ib_rep.c drivers/vdpa/mlx5/net/mlx5_vnet.c drivers/gpu/drm/bridge/ti-sn65dsi86.c drivers/soundwire/intel_init.c drivers/soundwire/intel.c

Regards,
Czarek

#12 lore raw
In reply to David E. Box
Quoted 18 lines · David E. Box
Quoted 17 lines · Jason Gunthorpe
Quoted 15 lines · David E. Box

Depends on "driver core: auxiliary bus: Add driver data helpers" patch [1]. Applies the helpers to all auxiliary device drivers using dev_(get/set)_drvdata. Drivers were found using the following search:

    grep -lr "struct auxiliary_device" $(grep -lr "drvdata" .)

Changes were build tested using the following configs:

vdpa/mlx5: CONFIG_MLX5_VDPA_NET
net/mlx53: CONFIG_MLX5_CORE_EN
soundwire/intel: CONFIG_SOUNDWIRE_INTEL
RDAM/irdma: CONFIG_INFINIBAND_IRDMA
CONFIG_MLX5_INFINIBAND

[1] https://www.spinics.net/lists/platform-driver-x86/msg29940.html

Quoted 7 lines
Quoted 2 lines

I have to say I don't really find this to be a big readability improvement.

I should have referenced the thread [1] discussing the benefit of this change since the question was asked and answered already. The idea is that drivers shouldn't have to touch the device API directly if they are already using a higher level core API (auxiliary bus) that can do that on its behalf.

Driver writers should rarely use the auxilary device type directly, the should always immediately container_of it to their proper derived type.

Quoted 3 lines
Quoted 1 line

Also, what use is 'to_auxiliary_dev()' ? I didn't see any users added..

This was not added by that patch.

It was added by the referenced patch, and seems totally pointless cut and paste, again because nothing should be using the auxiliary_device type for anything more than container_of'ing to their own type.

We've been ripping out bus specific APIs in favour of generic ones (see the work on the DMA API for instance) so this whole concept seems regressive, particularly when applied to auxiliary bus which does not have an API of its own.

Jason