Skip to contentSkip to conversation

extcon: extcon-axp288: use low level P-Unit semaphore lock for axp288 register accesses

PATCH Superseded Fabio Aiuto 3 participants 6 messages Sep 9, 2021 – Sep 10, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extcon: extcon-axp288: use low level P-Unit semaphore lock for axp288 register accesses

use low level P-Unit semaphore lock for axp288 register accesses directly and for more than one access a time, to reduce the number of times this semaphore is locked and released which is an expensive operation.

i2c-bus to the XPower is shared between the kernel and the SoCs P-Unit. The P-Unit has a semaphore wich the kernel must lock for axp288 register accesses. When the P-Unit semaphore is locked CPU and GPU power states cannot change or the system will freeze.

The P-Unit semaphore lock is already managed inside the regmap access logic, but for each access the semaphore is locked and released. So use directly iosf_mbi_(un)block_punit_i2c_access(), we are safe in doing so because nested calls to the same semaphore are turned to nops.

---
 drivers/extcon/extcon-axp288.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/extcon/extcon-axp288.c +14 -0
index fdb31954cf2b..460402b14ef2 100644
@@ -24,6 +24,7 @@
 
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
+#include <asm/iosf_mbi.h>
 
 /* Power source status register */
 #define PS_STAT_VBUS_TRIGGER		BIT(0)
@@ -215,6 +216,8 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 	unsigned int cable = info->previous_cable;
 	bool vbus_attach = false;
 
+	iosf_mbi_block_punit_i2c_access();
+
 	vbus_attach = axp288_get_vbus_attach(info);
 	if (!vbus_attach)
 		goto no_vbus;
@@ -253,6 +256,8 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 	}
 
 no_vbus:
+	iosf_mbi_unblock_punit_i2c_access();
+
 	extcon_set_state_sync(info->edev, info->previous_cable, false);
 	if (info->previous_cable == EXTCON_CHG_USB_SDP)
 		extcon_set_state_sync(info->edev, EXTCON_USB, false);
@@ -275,6 +280,8 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 	return 0;
 
 dev_det_ret:
+	iosf_mbi_unblock_punit_i2c_access();
+
 	if (ret < 0)
 		dev_err(info->dev, "failed to detect BC Mod\n");
 
@@ -307,11 +314,14 @@ static irqreturn_t axp288_extcon_isr(int irq, void *data)
 
 static void axp288_extcon_enable(struct axp288_extcon_info *info)
 {
+	iosf_mbi_block_punit_i2c_access();
 	regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
 						BC_GLOBAL_RUN, 0);
 	/* Enable the charger detection logic */
 	regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
 					BC_GLOBAL_RUN, BC_GLOBAL_RUN);
+
+	iosf_mbi_unblock_punit_i2c_access();
 }
 
 static void axp288_put_role_sw(void *data)
@@ -384,10 +394,14 @@ static int axp288_extcon_probe(struct platform_device *pdev)
 		}
 	}
 
+	iosf_mbi_block_punit_i2c_access();
+
 	info->vbus_attach = axp288_get_vbus_attach(info);
 
 	axp288_extcon_log_rsi(info);
 
+	iosf_mbi_unblock_punit_i2c_access();
+
 	/* Initialize extcon device */
 	info->edev = devm_extcon_dev_allocate(&pdev->dev,
 					      axp288_extcon_cables);
Signature · 1 line
2.20.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw

Hi All,

Quoted 11 lines · Fabio Aiuto

use low level P-Unit semaphore lock for axp288 register accesses directly and for more than one access a time, to reduce the number of times this semaphore is locked and released which is an expensive operation.

i2c-bus to the XPower is shared between the kernel and the SoCs P-Unit. The P-Unit has a semaphore wich the kernel must lock for axp288 register accesses. When the P-Unit semaphore is locked CPU and GPU power states cannot change or the system will freeze.

Quoted 8 lines

The P-Unit semaphore lock is already managed inside the regmap access logic, but for each access the semaphore is locked and released. So use directly iosf_mbi_(un)block_punit_i2c_access(), we are safe in doing so because nested calls to the same semaphore are turned to nops.

Thanks, patch looks good to me:

I've also given it a test run on a Chuwi Hibook which uses this PMIC:

Regards,

Hans

Quoted 74 lines
---
 drivers/extcon/extcon-axp288.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/extcon/extcon-axp288.c +14 -0
index fdb31954cf2b..460402b14ef2 100644
@@ -24,6 +24,7 @@
 
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
+#include <asm/iosf_mbi.h>
 
 /* Power source status register */
 #define PS_STAT_VBUS_TRIGGER		BIT(0)
@@ -215,6 +216,8 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 	unsigned int cable = info->previous_cable;
 	bool vbus_attach = false;
 
+	iosf_mbi_block_punit_i2c_access();
+
 	vbus_attach = axp288_get_vbus_attach(info);
 	if (!vbus_attach)
 		goto no_vbus;
@@ -253,6 +256,8 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 	}
 
 no_vbus:
+	iosf_mbi_unblock_punit_i2c_access();
+
 	extcon_set_state_sync(info->edev, info->previous_cable, false);
 	if (info->previous_cable == EXTCON_CHG_USB_SDP)
 		extcon_set_state_sync(info->edev, EXTCON_USB, false);
@@ -275,6 +280,8 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 	return 0;
 
 dev_det_ret:
+	iosf_mbi_unblock_punit_i2c_access();
+
 	if (ret < 0)
 		dev_err(info->dev, "failed to detect BC Mod\n");
 
@@ -307,11 +314,14 @@ static irqreturn_t axp288_extcon_isr(int irq, void *data)
 
 static void axp288_extcon_enable(struct axp288_extcon_info *info)
 {
+	iosf_mbi_block_punit_i2c_access();
 	regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
 						BC_GLOBAL_RUN, 0);
 	/* Enable the charger detection logic */
 	regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
 					BC_GLOBAL_RUN, BC_GLOBAL_RUN);
+
+	iosf_mbi_unblock_punit_i2c_access();
 }
 
 static void axp288_put_role_sw(void *data)
@@ -384,10 +394,14 @@ static int axp288_extcon_probe(struct platform_device *pdev)
 		}
 	}
 
+	iosf_mbi_block_punit_i2c_access();
+
 	info->vbus_attach = axp288_get_vbus_attach(info);
 
 	axp288_extcon_log_rsi(info);
 
+	iosf_mbi_unblock_punit_i2c_access();
+
 	/* Initialize extcon device */
 	info->edev = devm_extcon_dev_allocate(&pdev->dev,
 					      axp288_extcon_cables);
#2 lore raw
In reply to Fabio Aiuto
Thank you for the patch! Yet something to improve:

Hi Fabio,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on chanwoo-extcon/extcon-next]
[also build test ERROR on v5.14 next-20210909]
[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/Fabio-Aiuto/extcon-extcon-axp288-use-low-level-P-Unit-semaphore-lock-for-axp288-register-accesses/20210909-232054
base:   https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git extcon-next
config: x86_64-randconfig-a011-20210908 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 261cbe98c38f8c1ee1a482fe76511110e790f58a)

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/ecccd5dd3a8acfd5085a5cf9f9c97ed3d4b42a1f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Fabio-Aiuto/extcon-extcon-axp288-use-low-level-P-Unit-semaphore-lock-for-axp288-register-accesses/20210909-232054 git checkout ecccd5dd3a8acfd5085a5cf9f9c97ed3d4b42a1f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

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

All errors (new ones prefixed by >>):

>> drivers/extcon/extcon-axp288.c:219:2: error: implicit declaration of function 'iosf_mbi_block_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_block_punit_i2c_access();
           ^
>> drivers/extcon/extcon-axp288.c:259:2: error: implicit declaration of function 'iosf_mbi_unblock_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_unblock_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:259:2: note: did you mean 'iosf_mbi_block_punit_i2c_access'?
   drivers/extcon/extcon-axp288.c:219:2: note: 'iosf_mbi_block_punit_i2c_access' declared here
           iosf_mbi_block_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:317:2: error: implicit declaration of function 'iosf_mbi_block_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_block_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:324:2: error: implicit declaration of function 'iosf_mbi_unblock_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_unblock_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:397:2: error: implicit declaration of function 'iosf_mbi_block_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_block_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:403:2: error: implicit declaration of function 'iosf_mbi_unblock_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_unblock_punit_i2c_access();
           ^

6 errors generated.

vim +/iosf_mbi_block_punit_i2c_access +219 drivers/extcon/extcon-axp288.c

211
212 static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
213 {
214 int ret, stat, cfg;
215 u8 chrg_type;
216 unsigned int cable = info->previous_cable;
217 bool vbus_attach = false;
218

 > 219		iosf_mbi_block_punit_i2c_access();
   220	
   221		vbus_attach = axp288_get_vbus_attach(info);
   222		if (!vbus_attach)
   223			goto no_vbus;
   224	
   225		/* Check charger detection completion status */
   226		ret = regmap_read(info->regmap, AXP288_BC_GLOBAL_REG, &cfg);
   227		if (ret < 0)
   228			goto dev_det_ret;
   229		if (cfg & BC_GLOBAL_DET_STAT) {
   230			dev_dbg(info->dev, "can't complete the charger detection\n");
   231			goto dev_det_ret;
   232		}
   233	
   234		ret = regmap_read(info->regmap, AXP288_BC_DET_STAT_REG, &stat);
   235		if (ret < 0)
   236			goto dev_det_ret;
   237	
   238		chrg_type = (stat & DET_STAT_MASK) >> DET_STAT_SHIFT;
   239	
   240		switch (chrg_type) {
   241		case DET_STAT_SDP:
   242			dev_dbg(info->dev, "sdp cable is connected\n");
   243			cable = EXTCON_CHG_USB_SDP;
   244			break;
   245		case DET_STAT_CDP:
   246			dev_dbg(info->dev, "cdp cable is connected\n");
   247			cable = EXTCON_CHG_USB_CDP;
   248			break;
   249		case DET_STAT_DCP:
   250			dev_dbg(info->dev, "dcp cable is connected\n");
   251			cable = EXTCON_CHG_USB_DCP;
   252			break;
   253		default:
   254			dev_warn(info->dev, "unknown (reserved) bc detect result\n");
   255			cable = EXTCON_CHG_USB_SDP;
   256		}
   257	
   258	no_vbus:
 > 259		iosf_mbi_unblock_punit_i2c_access();

260
261 extcon_set_state_sync(info->edev, info->previous_cable, false);
262 if (info->previous_cable == EXTCON_CHG_USB_SDP)
263 extcon_set_state_sync(info->edev, EXTCON_USB, false);
264
265 if (vbus_attach) {
266 extcon_set_state_sync(info->edev, cable, vbus_attach);
267 if (cable == EXTCON_CHG_USB_SDP)
268 extcon_set_state_sync(info->edev, EXTCON_USB,
269 vbus_attach);
270
271 info->previous_cable = cable;
272 }
273
274 if (info->role_sw && info->vbus_attach != vbus_attach) {
275 info->vbus_attach = vbus_attach;
276 /* Setting the role can take a while */
277 queue_work(system_long_wq, &info->role_work);
278 }
279
280 return 0;
281
282 dev_det_ret:
283 iosf_mbi_unblock_punit_i2c_access();
284
285 if (ret < 0)
286 dev_err(info->dev, "failed to detect BC Mod\n");
287
288 return ret;
289 }
290

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

#5 lore raw
In reply to Fabio Aiuto
Thank you for the patch! Yet something to improve:

Hi Fabio,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on chanwoo-extcon/extcon-next]
[also build test ERROR on v5.14 next-20210909]
[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/Fabio-Aiuto/extcon-extcon-axp288-use-low-level-P-Unit-semaphore-lock-for-axp288-register-accesses/20210909-232054
base:   https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git extcon-next
config: x86_64-randconfig-r033-20210908 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/ecccd5dd3a8acfd5085a5cf9f9c97ed3d4b42a1f
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Fabio-Aiuto/extcon-extcon-axp288-use-low-level-P-Unit-semaphore-lock-for-axp288-register-accesses/20210909-232054
        git checkout ecccd5dd3a8acfd5085a5cf9f9c97ed3d4b42a1f
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

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

All errors (new ones prefixed by >>):

drivers/extcon/extcon-axp288.c: In function 'axp288_handle_chrg_det_event':

>> drivers/extcon/extcon-axp288.c:219:2: error: implicit declaration of function 'iosf_mbi_block_punit_i2c_access' [-Werror=implicit-function-declaration]
     219 |  iosf_mbi_block_punit_i2c_access();
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/extcon/extcon-axp288.c:259:2: error: implicit declaration of function 'iosf_mbi_unblock_punit_i2c_access' [-Werror=implicit-function-declaration]
     259 |  iosf_mbi_unblock_punit_i2c_access();
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

vim +/iosf_mbi_block_punit_i2c_access +219 drivers/extcon/extcon-axp288.c

211
212 static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
213 {
214 int ret, stat, cfg;
215 u8 chrg_type;
216 unsigned int cable = info->previous_cable;
217 bool vbus_attach = false;
218

 > 219		iosf_mbi_block_punit_i2c_access();
   220	
   221		vbus_attach = axp288_get_vbus_attach(info);
   222		if (!vbus_attach)
   223			goto no_vbus;
   224	
   225		/* Check charger detection completion status */
   226		ret = regmap_read(info->regmap, AXP288_BC_GLOBAL_REG, &cfg);
   227		if (ret < 0)
   228			goto dev_det_ret;
   229		if (cfg & BC_GLOBAL_DET_STAT) {
   230			dev_dbg(info->dev, "can't complete the charger detection\n");
   231			goto dev_det_ret;
   232		}
   233	
   234		ret = regmap_read(info->regmap, AXP288_BC_DET_STAT_REG, &stat);
   235		if (ret < 0)
   236			goto dev_det_ret;
   237	
   238		chrg_type = (stat & DET_STAT_MASK) >> DET_STAT_SHIFT;
   239	
   240		switch (chrg_type) {
   241		case DET_STAT_SDP:
   242			dev_dbg(info->dev, "sdp cable is connected\n");
   243			cable = EXTCON_CHG_USB_SDP;
   244			break;
   245		case DET_STAT_CDP:
   246			dev_dbg(info->dev, "cdp cable is connected\n");
   247			cable = EXTCON_CHG_USB_CDP;
   248			break;
   249		case DET_STAT_DCP:
   250			dev_dbg(info->dev, "dcp cable is connected\n");
   251			cable = EXTCON_CHG_USB_DCP;
   252			break;
   253		default:
   254			dev_warn(info->dev, "unknown (reserved) bc detect result\n");
   255			cable = EXTCON_CHG_USB_SDP;
   256		}
   257	
   258	no_vbus:
 > 259		iosf_mbi_unblock_punit_i2c_access();

260
261 extcon_set_state_sync(info->edev, info->previous_cable, false);
262 if (info->previous_cable == EXTCON_CHG_USB_SDP)
263 extcon_set_state_sync(info->edev, EXTCON_USB, false);
264
265 if (vbus_attach) {
266 extcon_set_state_sync(info->edev, cable, vbus_attach);
267 if (cable == EXTCON_CHG_USB_SDP)
268 extcon_set_state_sync(info->edev, EXTCON_USB,
269 vbus_attach);
270
271 info->previous_cable = cable;
272 }
273
274 if (info->role_sw && info->vbus_attach != vbus_attach) {
275 info->vbus_attach = vbus_attach;
276 /* Setting the role can take a while */
277 queue_work(system_long_wq, &info->role_work);
278 }
279
280 return 0;
281
282 dev_det_ret:
283 iosf_mbi_unblock_punit_i2c_access();
284
285 if (ret < 0)
286 dev_err(info->dev, "failed to detect BC Mod\n");
287
288 return ret;
289 }
290

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

#3 lore raw
In reply to kernel test robot

Hi,

Quoted 51 lines · kernel test robot

Hi Fabio,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on chanwoo-extcon/extcon-next]
[also build test ERROR on v5.14 next-20210909]
[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/Fabio-Aiuto/extcon-extcon-axp288-use-low-level-P-Unit-semaphore-lock-for-axp288-register-accesses/20210909-232054
base:   https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git extcon-next
config: x86_64-randconfig-a011-20210908 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 261cbe98c38f8c1ee1a482fe76511110e790f58a)

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/ecccd5dd3a8acfd5085a5cf9f9c97ed3d4b42a1f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Fabio-Aiuto/extcon-extcon-axp288-use-low-level-P-Unit-semaphore-lock-for-axp288-register-accesses/20210909-232054 git checkout ecccd5dd3a8acfd5085a5cf9f9c97ed3d4b42a1f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

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

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/extcon/extcon-axp288.c:219:2: error: implicit declaration of function 'iosf_mbi_block_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]

           iosf_mbi_block_punit_i2c_access();
           ^
Quoted 1 line
Quoted 1 line

drivers/extcon/extcon-axp288.c:259:2: error: implicit declaration of function 'iosf_mbi_unblock_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]

           iosf_mbi_unblock_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:259:2: note: did you mean 'iosf_mbi_block_punit_i2c_access'?
   drivers/extcon/extcon-axp288.c:219:2: note: 'iosf_mbi_block_punit_i2c_access' declared here
           iosf_mbi_block_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:317:2: error: implicit declaration of function 'iosf_mbi_block_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_block_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:324:2: error: implicit declaration of function 'iosf_mbi_unblock_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_unblock_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:397:2: error: implicit declaration of function 'iosf_mbi_block_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_block_punit_i2c_access();
           ^
   drivers/extcon/extcon-axp288.c:403:2: error: implicit declaration of function 'iosf_mbi_unblock_punit_i2c_access' [-Werror,-Wimplicit-function-declaration]
           iosf_mbi_unblock_punit_i2c_access();
           ^
Quoted 1 line

6 errors generated.

Ah yes, I should have caught this, we had the same issue with a similar patch to the axp288-fuel-gauge driver.

The fix is this:

drivers/extcon/Kconfig +1 -1
index c69d40ae5619..aab87c9b35c8 100644
@@ -23,7 +23,7 @@ config EXTCON_ADC_JACK
 
 config EXTCON_AXP288
 	tristate "X-Power AXP288 EXTCON support"
-	depends on MFD_AXP20X && USB_SUPPORT && X86 && ACPI
+	depends on MFD_AXP20X && USB_SUPPORT && X86 && ACPI && IOSF_MBI
 	select USB_ROLE_SWITCH
 	help
 	  Say Y here to enable support for USB peripheral detection

The new depends on is fine since all boards which use the AXP288 should always have IOSF_MBI enabled anyways.

Fabio, can you send a v2 with this Kconfig change added please ?

(and please also add my earlier Reviewed-by and Tested-by to the v2)

Quoted 89 lines

vim +/iosf_mbi_block_punit_i2c_access +219 drivers/extcon/extcon-axp288.c

   211	
   212	static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
   213	{
   214		int ret, stat, cfg;
   215		u8 chrg_type;
   216		unsigned int cable = info->previous_cable;
   217		bool vbus_attach = false;
   218	
Quoted 1 line

219 iosf_mbi_block_punit_i2c_access();

220

   221		vbus_attach = axp288_get_vbus_attach(info);
   222		if (!vbus_attach)
   223			goto no_vbus;
   224	
   225		/* Check charger detection completion status */
   226		ret = regmap_read(info->regmap, AXP288_BC_GLOBAL_REG, &cfg);
   227		if (ret < 0)
   228			goto dev_det_ret;
   229		if (cfg & BC_GLOBAL_DET_STAT) {
   230			dev_dbg(info->dev, "can't complete the charger detection\n");
   231			goto dev_det_ret;
   232		}
   233	
   234		ret = regmap_read(info->regmap, AXP288_BC_DET_STAT_REG, &stat);
   235		if (ret < 0)
   236			goto dev_det_ret;
   237	
   238		chrg_type = (stat & DET_STAT_MASK) >> DET_STAT_SHIFT;
   239	
   240		switch (chrg_type) {
   241		case DET_STAT_SDP:
   242			dev_dbg(info->dev, "sdp cable is connected\n");
   243			cable = EXTCON_CHG_USB_SDP;
   244			break;
   245		case DET_STAT_CDP:
   246			dev_dbg(info->dev, "cdp cable is connected\n");
   247			cable = EXTCON_CHG_USB_CDP;
   248			break;
   249		case DET_STAT_DCP:
   250			dev_dbg(info->dev, "dcp cable is connected\n");
   251			cable = EXTCON_CHG_USB_DCP;
   252			break;
   253		default:
   254			dev_warn(info->dev, "unknown (reserved) bc detect result\n");
   255			cable = EXTCON_CHG_USB_SDP;
   256		}
   257	
   258	no_vbus:
Quoted 1 line

259 iosf_mbi_unblock_punit_i2c_access();

260

   261		extcon_set_state_sync(info->edev, info->previous_cable, false);
   262		if (info->previous_cable == EXTCON_CHG_USB_SDP)
   263			extcon_set_state_sync(info->edev, EXTCON_USB, false);
   264	
   265		if (vbus_attach) {
   266			extcon_set_state_sync(info->edev, cable, vbus_attach);
   267			if (cable == EXTCON_CHG_USB_SDP)
   268				extcon_set_state_sync(info->edev, EXTCON_USB,
   269							vbus_attach);
   270	
   271			info->previous_cable = cable;
   272		}
   273	
   274		if (info->role_sw && info->vbus_attach != vbus_attach) {
   275			info->vbus_attach = vbus_attach;
   276			/* Setting the role can take a while */
   277			queue_work(system_long_wq, &info->role_work);
   278		}
   279	
   280		return 0;
   281	
   282	dev_det_ret:
   283		iosf_mbi_unblock_punit_i2c_access();
   284	
   285		if (ret < 0)
   286			dev_err(info->dev, "failed to detect BC Mod\n");
   287	
   288		return ret;
   289	}
   290	

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

#4 lore raw

Hi Hans,

Quoted 1 line · Hans de Goede

Hi,

<snip>

Quoted 22 lines
Quoted 2 lines
           ^

6 errors generated.

Ah yes, I should have caught this, we had the same issue with a similar patch to the axp288-fuel-gauge driver.

The fix is this:

drivers/extcon/Kconfig +1 -1
index c69d40ae5619..aab87c9b35c8 100644
@@ -23,7 +23,7 @@ config EXTCON_ADC_JACK
 
 config EXTCON_AXP288
 	tristate "X-Power AXP288 EXTCON support"
-	depends on MFD_AXP20X && USB_SUPPORT && X86 && ACPI
+	depends on MFD_AXP20X && USB_SUPPORT && X86 && ACPI && IOSF_MBI
 	select USB_ROLE_SWITCH
 	help
 	  Say Y here to enable support for USB peripheral detection
Quoted 6 lines

The new depends on is fine since all boards which use the AXP288 should always have IOSF_MBI enabled anyways.

Fabio, can you send a v2 with this Kconfig change added please ?

(and please also add my earlier Reviewed-by and Tested-by to the v2)

sure will fix and resend

Quoted 4 lines
Quoted 4 lines

thank you,

fabio