In order to add the hardware lock for Wangxun devices with minimal modification, pass struct dw_i2c_dev to the acquire and release lock functions.
Cc: stable@vger.kernel.org Fixes: 2f8d1ed79345 ("i2c: designware: Add driver support for Wangxun 10Gb NIC") Signed-off-by: Jiawen Wu jiawenwu@trustnetic.com --- drivers/i2c/busses/i2c-designware-amdpsp.c | 4 ++-- drivers/i2c/busses/i2c-designware-baytrail.c | 14 ++++++++++++-- drivers/i2c/busses/i2c-designware-common.c | 4 ++-- drivers/i2c/busses/i2c-designware-core.h | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c index 63454b06e5da..ee7cc4b33f4b 100644 --- a/drivers/i2c/busses/i2c-designware-amdpsp.c +++ b/drivers/i2c/busses/i2c-designware-amdpsp.c @@ -167,7 +167,7 @@ static void psp_release_i2c_bus_deferred(struct work_struct *work) } static DECLARE_DELAYED_WORK(release_queue, psp_release_i2c_bus_deferred);
-static int psp_acquire_i2c_bus(void) +static int psp_acquire_i2c_bus(struct dw_i2c_dev *dev) { int status;
@@ -206,7 +206,7 @@ static int psp_acquire_i2c_bus(void) return 0; }
-static void psp_release_i2c_bus(void) +static void psp_release_i2c_bus(struct dw_i2c_dev *dev) { mutex_lock(&psp_i2c_access_mutex);
diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c b/drivers/i2c/busses/i2c-designware-baytrail.c index 45774aa47c28..9dde796e0fcc 100644 --- a/drivers/i2c/busses/i2c-designware-baytrail.c +++ b/drivers/i2c/busses/i2c-designware-baytrail.c @@ -12,6 +12,16 @@
#include "i2c-designware-core.h"
+static int iosf_mbi_block_punit_i2c_access_dev(struct dw_i2c_dev *dev) +{ + return iosf_mbi_block_punit_i2c_access(); +} + +static void iosf_mbi_unblock_punit_i2c_access_dev(struct dw_i2c_dev *dev) +{ + return iosf_mbi_unblock_punit_i2c_access(); +} + int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev) { acpi_status status; @@ -36,8 +46,8 @@ int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev) return -EPROBE_DEFER;
dev_info(dev->dev, "I2C bus managed by PUNIT\n"); - dev->acquire_lock = iosf_mbi_block_punit_i2c_access; - dev->release_lock = iosf_mbi_unblock_punit_i2c_access; + dev->acquire_lock = iosf_mbi_block_punit_i2c_access_dev; + dev->release_lock = iosf_mbi_unblock_punit_i2c_access_dev; dev->shared_with_punit = true;
return 0; diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c index e8a688d04aee..743875090356 100644 --- a/drivers/i2c/busses/i2c-designware-common.c +++ b/drivers/i2c/busses/i2c-designware-common.c @@ -524,7 +524,7 @@ int i2c_dw_acquire_lock(struct dw_i2c_dev *dev) if (!dev->acquire_lock) return 0;
- ret = dev->acquire_lock(); + ret = dev->acquire_lock(dev); if (!ret) return 0;
@@ -536,7 +536,7 @@ int i2c_dw_acquire_lock(struct dw_i2c_dev *dev) void i2c_dw_release_lock(struct dw_i2c_dev *dev) { if (dev->release_lock) - dev->release_lock(); + dev->release_lock(dev); }
/* diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h index e9606c00b8d1..12b77f464fb5 100644 --- a/drivers/i2c/busses/i2c-designware-core.h +++ b/drivers/i2c/busses/i2c-designware-core.h @@ -291,8 +291,8 @@ struct dw_i2c_dev { u16 fp_lcnt; u16 hs_hcnt; u16 hs_lcnt; - int (*acquire_lock)(void); - void (*release_lock)(void); + int (*acquire_lock)(struct dw_i2c_dev *dev); + void (*release_lock)(struct dw_i2c_dev *dev); int semaphore_idx; bool shared_with_punit; void (*disable)(struct dw_i2c_dev *dev);
On Fri, Aug 23, 2024 at 11:02:41AM +0800, Jiawen Wu wrote:
In order to add the hardware lock for Wangxun devices with minimal modification, pass struct dw_i2c_dev to the acquire and release lock functions.
...
+static int iosf_mbi_block_punit_i2c_access_dev(struct dw_i2c_dev *dev)
+static void iosf_mbi_unblock_punit_i2c_access_dev(struct dw_i2c_dev *dev)
Rather name them in accordance with the namespace of this module.
On 8/23/24 05:02, Jiawen Wu wrote:
In order to add the hardware lock for Wangxun devices with minimal modification, pass struct dw_i2c_dev to the acquire and release lock functions.
Cc: stable@vger.kernel.org Fixes: 2f8d1ed79345 ("i2c: designware: Add driver support for Wangxun 10Gb NIC") Signed-off-by: Jiawen Wu jiawenwu@trustnetic.com
drivers/i2c/busses/i2c-designware-amdpsp.c | 4 ++-- drivers/i2c/busses/i2c-designware-baytrail.c | 14 ++++++++++++-- drivers/i2c/busses/i2c-designware-common.c | 4 ++-- drivers/i2c/busses/i2c-designware-core.h | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c index 63454b06e5da..ee7cc4b33f4b 100644 --- a/drivers/i2c/busses/i2c-designware-amdpsp.c +++ b/drivers/i2c/busses/i2c-designware-amdpsp.c @@ -167,7 +167,7 @@ static void psp_release_i2c_bus_deferred(struct work_struct *work) } static DECLARE_DELAYED_WORK(release_queue, psp_release_i2c_bus_deferred); -static int psp_acquire_i2c_bus(void) +static int psp_acquire_i2c_bus(struct dw_i2c_dev *dev) { int status;
This function is used in a few other places in this compilation unit. You need to update all the users accordingly.
@@ -206,7 +206,7 @@ static int psp_acquire_i2c_bus(void) return 0; } -static void psp_release_i2c_bus(void) +static void psp_release_i2c_bus(struct dw_i2c_dev *dev) { mutex_lock(&psp_i2c_access_mutex);
The same here.
Cheers,
Paolo
Hi Jiawen,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jiawen-Wu/net-txgbe-add-IO-ad... base: net/main patch link: https://lore.kernel.org/r/20240823030242.3083528-3-jiawenwu%40trustnetic.com patch subject: [PATCH net 2/3] i2c: designware: add device private data passing to lock functions config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20240829/202408291212.L5DejDpz-lkp@i...) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240829/202408291212.L5DejDpz-lkp@i...)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot lkp@intel.com | Closes: https://lore.kernel.org/oe-kbuild-all/202408291212.L5DejDpz-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/i2c/busses/i2c-designware-amdpsp.c:246:22: error: too few arguments to function call, single argument 'dev' was not specified
246 | psp_acquire_i2c_bus(); | ~~~~~~~~~~~~~~~~~~~ ^ drivers/i2c/busses/i2c-designware-amdpsp.c:170:12: note: 'psp_acquire_i2c_bus' declared here 170 | static int psp_acquire_i2c_bus(struct dw_i2c_dev *dev) | ^ ~~~~~~~~~~~~~~~~~~~~~~ drivers/i2c/busses/i2c-designware-amdpsp.c:259:22: error: too few arguments to function call, single argument 'dev' was not specified 259 | psp_acquire_i2c_bus(); | ~~~~~~~~~~~~~~~~~~~ ^ drivers/i2c/busses/i2c-designware-amdpsp.c:170:12: note: 'psp_acquire_i2c_bus' declared here 170 | static int psp_acquire_i2c_bus(struct dw_i2c_dev *dev) | ^ ~~~~~~~~~~~~~~~~~~~~~~ drivers/i2c/busses/i2c-designware-amdpsp.c:267:22: error: too few arguments to function call, single argument 'dev' was not specified 267 | psp_release_i2c_bus(); | ~~~~~~~~~~~~~~~~~~~ ^ drivers/i2c/busses/i2c-designware-amdpsp.c:209:13: note: 'psp_release_i2c_bus' declared here 209 | static void psp_release_i2c_bus(struct dw_i2c_dev *dev) | ^ ~~~~~~~~~~~~~~~~~~~~~~ 3 errors generated.
vim +/dev +246 drivers/i2c/busses/i2c-designware-amdpsp.c
78d5e9e299e31bc Jan Dabros 2022-02-08 235 78d5e9e299e31bc Jan Dabros 2022-02-08 236 /* 78d5e9e299e31bc Jan Dabros 2022-02-08 237 * Locking methods are based on the default implementation from 78d5e9e299e31bc Jan Dabros 2022-02-08 238 * drivers/i2c/i2c-core-base.c, but with psp acquire and release operations 78d5e9e299e31bc Jan Dabros 2022-02-08 239 * added. With this in place we can ensure that i2c clients on the bus shared 78d5e9e299e31bc Jan Dabros 2022-02-08 240 * with psp are able to lock HW access to the bus for arbitrary number of 78d5e9e299e31bc Jan Dabros 2022-02-08 241 * operations - that is e.g. write-wait-read. 78d5e9e299e31bc Jan Dabros 2022-02-08 242 */ 78d5e9e299e31bc Jan Dabros 2022-02-08 243 static void i2c_adapter_dw_psp_lock_bus(struct i2c_adapter *adapter, 78d5e9e299e31bc Jan Dabros 2022-02-08 244 unsigned int flags) 78d5e9e299e31bc Jan Dabros 2022-02-08 245 { 78d5e9e299e31bc Jan Dabros 2022-02-08 @246 psp_acquire_i2c_bus(); 78d5e9e299e31bc Jan Dabros 2022-02-08 247 rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter)); 78d5e9e299e31bc Jan Dabros 2022-02-08 248 } 78d5e9e299e31bc Jan Dabros 2022-02-08 249
linux-stable-mirror@lists.linaro.org