Message ID | 20220130191225.303115-3-terry.bowman@amd.com |
---|---|
State | Superseded |
Headers | show |
Series | Watchdog: sp5100_tco: Replace cd6h/cd7h port I/O accesses with MMIO accesses | expand |
Hi Terry, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on groeck-staging/hwmon-next] [also build test WARNING on linux/master linus/master v5.17-rc2 next-20220128] [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/Terry-Bowman/Watchdog-sp5100_tco-Replace-cd6h-cd7h-port-I-O-accesses-with-MMIO-accesses/20220131-031525 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next config: x86_64-randconfig-m001-20220131 (https://download.01.org/0day-ci/archive/20220131/202201311012.U53Rg3e2-lkp@intel.com/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/e6855f66e7e915cd09a8f8dae411997df8a7c641 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Terry-Bowman/Watchdog-sp5100_tco-Replace-cd6h-cd7h-port-I-O-accesses-with-MMIO-accesses/20220131-031525 git checkout e6855f66e7e915cd09a8f8dae411997df8a7c641 # save the config file to linux build tree mkdir build_dir make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/watchdog/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): In file included from include/linux/device.h:15, from include/linux/pci.h:37, from drivers/watchdog/sp5100_tco.c:40: drivers/watchdog/sp5100_tco.c: In function 'sp5100_tco_prepare_base': >> drivers/watchdog/sp5100_tco.c:270:16: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'void *' [-Wformat=] 270 | dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/dev_printk.h:110:16: note: in definition of macro 'dev_printk_index_wrap' 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ | ^~~ include/linux/dev_printk.h:150:51: note: in expansion of macro 'dev_fmt' 150 | dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~ drivers/watchdog/sp5100_tco.c:270:2: note: in expansion of macro 'dev_info' 270 | dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); | ^~~~~~~~ drivers/watchdog/sp5100_tco.c:270:28: note: format string is defined here 270 | dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); | ~~~^ | | | unsigned int | %08p vim +270 drivers/watchdog/sp5100_tco.c 238 239 static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, 240 u32 mmio_addr, 241 u32 alt_mmio_addr, 242 const char *dev_name) 243 { 244 struct device *dev = tco->wdd.parent; 245 246 dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); 247 248 if (!mmio_addr && !alt_mmio_addr) 249 return -ENODEV; 250 251 /* Check for MMIO address and alternate MMIO address conflicts */ 252 if (mmio_addr) 253 mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); 254 255 if (!mmio_addr && alt_mmio_addr) 256 mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); 257 258 if (!mmio_addr) { 259 dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); 260 return -EBUSY; 261 } 262 263 tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); 264 if (!tco->tcobase) { 265 dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); 266 devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); 267 return -ENOMEM; 268 } 269 > 270 dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); 271 272 return 0; 273 } 274 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Terry, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on groeck-staging/hwmon-next] [also build test WARNING on linux/master linus/master v5.17-rc2 next-20220128] [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/Terry-Bowman/Watchdog-sp5100_tco-Replace-cd6h-cd7h-port-I-O-accesses-with-MMIO-accesses/20220131-031525 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next config: x86_64-randconfig-a013-20220131 (https://download.01.org/0day-ci/archive/20220131/202201311102.xyggUF8Z-lkp@intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project f1c18acb07aa40f42b87b70462a6d1ab77a4825c) 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/e6855f66e7e915cd09a8f8dae411997df8a7c641 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Terry-Bowman/Watchdog-sp5100_tco-Replace-cd6h-cd7h-port-I-O-accesses-with-MMIO-accesses/20220131-031525 git checkout e6855f66e7e915cd09a8f8dae411997df8a7c641 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/watchdog/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/watchdog/sp5100_tco.c:270:60: warning: format specifies type 'unsigned int' but the argument has type 'void *' [-Wformat] dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); ~~~~ ^~~~~~~~~~~~ include/linux/dev_printk.h:150:67: note: expanded from macro 'dev_info' dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__) ~~~ ^~~~~~~~~~~ include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap' _p_func(dev, fmt, ##__VA_ARGS__); \ ~~~ ^~~~~~~~~~~ 1 warning generated. vim +270 drivers/watchdog/sp5100_tco.c 238 239 static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, 240 u32 mmio_addr, 241 u32 alt_mmio_addr, 242 const char *dev_name) 243 { 244 struct device *dev = tco->wdd.parent; 245 246 dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); 247 248 if (!mmio_addr && !alt_mmio_addr) 249 return -ENODEV; 250 251 /* Check for MMIO address and alternate MMIO address conflicts */ 252 if (mmio_addr) 253 mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); 254 255 if (!mmio_addr && alt_mmio_addr) 256 mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); 257 258 if (!mmio_addr) { 259 dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); 260 return -EBUSY; 261 } 262 263 tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); 264 if (!tco->tcobase) { 265 dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); 266 devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); 267 return -ENOMEM; 268 } 269 > 270 dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); 271 272 return 0; 273 } 274 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On 1/30/22 11:12, Terry Bowman wrote: > Combine MMIO base address and alternate base address detection. Combine > based on layout type. This will simplify the function by eliminating > a switch case. > > Move existing request/release code into functions. This currently only > supports port I/O request/release. The move into a separate function > will make it ready for adding MMIO region support. > > Co-developed-by: Robert Richter <rrichter@amd.com> > Signed-off-by: Robert Richter <rrichter@amd.com> > Signed-off-by: Terry Bowman <terry.bowman@amd.com> > Tested-by: Jean Delvare <jdelvare@suse.de> > Reviewed-by: Jean Delvare <jdelvare@suse.de> > --- > drivers/watchdog/sp5100_tco.c | 155 ++++++++++++++++++---------------- > drivers/watchdog/sp5100_tco.h | 1 + > 2 files changed, 82 insertions(+), 74 deletions(-) > > diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c > index b365bbc9ac36..16e122d5045e 100644 > --- a/drivers/watchdog/sp5100_tco.c > +++ b/drivers/watchdog/sp5100_tco.c > @@ -223,6 +223,55 @@ static u32 sp5100_tco_read_pm_reg32(u8 index) > return val; > } > > +static u32 sp5100_tco_request_region(struct device *dev, > + u32 mmio_addr, > + const char *dev_name) > +{ > + if (!devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, > + dev_name)) { > + dev_dbg(dev, "MMIO address 0x%08x already in use\n", mmio_addr); > + return 0; > + } > + > + return mmio_addr; > +} > + > +static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, > + u32 mmio_addr, > + u32 alt_mmio_addr, > + const char *dev_name) > +{ > + struct device *dev = tco->wdd.parent; > + > + dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); > + > + if (!mmio_addr && !alt_mmio_addr) > + return -ENODEV; > + > + /* Check for MMIO address and alternate MMIO address conflicts */ > + if (mmio_addr) > + mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); > + > + if (!mmio_addr && alt_mmio_addr) > + mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); > + > + if (!mmio_addr) { > + dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); > + return -EBUSY; > + } > + > + tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); > + if (!tco->tcobase) { > + dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); > + devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); > + return -ENOMEM; > + } > + > + dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); > + I know this is the same as the old code, but I think it would make sense to change this as suggested by 0-day and use %px instead. Thanks, Guenter
On 2/1/22 09:31, Guenter Roeck wrote: > On 1/30/22 11:12, Terry Bowman wrote: >> Combine MMIO base address and alternate base address detection. Combine >> based on layout type. This will simplify the function by eliminating >> a switch case. >> >> Move existing request/release code into functions. This currently only >> supports port I/O request/release. The move into a separate function >> will make it ready for adding MMIO region support. >> >> Co-developed-by: Robert Richter <rrichter@amd.com> >> Signed-off-by: Robert Richter <rrichter@amd.com> >> Signed-off-by: Terry Bowman <terry.bowman@amd.com> >> Tested-by: Jean Delvare <jdelvare@suse.de> >> Reviewed-by: Jean Delvare <jdelvare@suse.de> >> --- >> drivers/watchdog/sp5100_tco.c | 155 ++++++++++++++++++---------------- >> drivers/watchdog/sp5100_tco.h | 1 + >> 2 files changed, 82 insertions(+), 74 deletions(-) >> >> diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c >> index b365bbc9ac36..16e122d5045e 100644 >> --- a/drivers/watchdog/sp5100_tco.c >> +++ b/drivers/watchdog/sp5100_tco.c >> @@ -223,6 +223,55 @@ static u32 sp5100_tco_read_pm_reg32(u8 index) >> return val; >> } >> +static u32 sp5100_tco_request_region(struct device *dev, >> + u32 mmio_addr, >> + const char *dev_name) >> +{ >> + if (!devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, >> + dev_name)) { >> + dev_dbg(dev, "MMIO address 0x%08x already in use\n", mmio_addr); >> + return 0; >> + } >> + >> + return mmio_addr; >> +} >> + >> +static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, >> + u32 mmio_addr, >> + u32 alt_mmio_addr, >> + const char *dev_name) >> +{ >> + struct device *dev = tco->wdd.parent; >> + >> + dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); >> + >> + if (!mmio_addr && !alt_mmio_addr) >> + return -ENODEV; >> + >> + /* Check for MMIO address and alternate MMIO address conflicts */ >> + if (mmio_addr) >> + mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); >> + >> + if (!mmio_addr && alt_mmio_addr) >> + mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); >> + >> + if (!mmio_addr) { >> + dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); >> + return -EBUSY; >> + } >> + >> + tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); >> + if (!tco->tcobase) { >> + dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); >> + devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); >> + return -ENOMEM; >> + } >> + >> + dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); >> + > > I know this is the same as the old code, but I think it would make sense to change > this as suggested by 0-day and use %px instead. > > Thanks, > Guenter Hi Guenter, I'll add the change to v5. Regards, Terry
On 2/1/22 10:46, Terry Bowman wrote: > > > On 2/1/22 09:31, Guenter Roeck wrote: >> On 1/30/22 11:12, Terry Bowman wrote: >>> Combine MMIO base address and alternate base address detection. Combine >>> based on layout type. This will simplify the function by eliminating >>> a switch case. >>> >>> Move existing request/release code into functions. This currently only >>> supports port I/O request/release. The move into a separate function >>> will make it ready for adding MMIO region support. >>> >>> Co-developed-by: Robert Richter <rrichter@amd.com> >>> Signed-off-by: Robert Richter <rrichter@amd.com> >>> Signed-off-by: Terry Bowman <terry.bowman@amd.com> >>> Tested-by: Jean Delvare <jdelvare@suse.de> >>> Reviewed-by: Jean Delvare <jdelvare@suse.de> >>> --- >>> drivers/watchdog/sp5100_tco.c | 155 ++++++++++++++++++---------------- >>> drivers/watchdog/sp5100_tco.h | 1 + >>> 2 files changed, 82 insertions(+), 74 deletions(-) >>> >>> diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c >>> index b365bbc9ac36..16e122d5045e 100644 >>> --- a/drivers/watchdog/sp5100_tco.c >>> +++ b/drivers/watchdog/sp5100_tco.c >>> @@ -223,6 +223,55 @@ static u32 sp5100_tco_read_pm_reg32(u8 index) >>> return val; >>> } >>> +static u32 sp5100_tco_request_region(struct device *dev, >>> + u32 mmio_addr, >>> + const char *dev_name) >>> +{ >>> + if (!devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, >>> + dev_name)) { >>> + dev_dbg(dev, "MMIO address 0x%08x already in use\n", mmio_addr); >>> + return 0; >>> + } >>> + >>> + return mmio_addr; >>> +} >>> + >>> +static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, >>> + u32 mmio_addr, >>> + u32 alt_mmio_addr, >>> + const char *dev_name) >>> +{ >>> + struct device *dev = tco->wdd.parent; >>> + >>> + dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); >>> + >>> + if (!mmio_addr && !alt_mmio_addr) >>> + return -ENODEV; >>> + >>> + /* Check for MMIO address and alternate MMIO address conflicts */ >>> + if (mmio_addr) >>> + mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); >>> + >>> + if (!mmio_addr && alt_mmio_addr) >>> + mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); >>> + >>> + if (!mmio_addr) { >>> + dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); >>> + return -EBUSY; >>> + } >>> + >>> + tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); >>> + if (!tco->tcobase) { >>> + dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); >>> + devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); >>> + return -ENOMEM; >>> + } >>> + >>> + dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); >>> + >> >> I know this is the same as the old code, but I think it would make sense to change >> this as suggested by 0-day and use %px instead. >> >> Thanks, >> Guenter > > Hi Guenter, This line was changed in v4 and should be reverted. It should be using the mmio_addr physical address with '0x%08x' formatting instead of tco->tcobase. This would be: dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", mmio_addr); The dmesg then provides: [ 5.972921] sp5100_tco: SP5100/SB800 TCO WatchDog Timer Driver [ 5.978238] sp5100-tco sp5100-tco: Using 0xfeb00000 for watchdog MMIO address [ 5.978252] sp5100-tco sp5100-tco: Watchdog hardware is disabled Do your agree? Regards, Terry
On 2/1/22 12:32, Terry Bowman wrote: > > > On 2/1/22 10:46, Terry Bowman wrote: >> >> >> On 2/1/22 09:31, Guenter Roeck wrote: >>> On 1/30/22 11:12, Terry Bowman wrote: >>>> Combine MMIO base address and alternate base address detection. Combine >>>> based on layout type. This will simplify the function by eliminating >>>> a switch case. >>>> >>>> Move existing request/release code into functions. This currently only >>>> supports port I/O request/release. The move into a separate function >>>> will make it ready for adding MMIO region support. >>>> >>>> Co-developed-by: Robert Richter <rrichter@amd.com> >>>> Signed-off-by: Robert Richter <rrichter@amd.com> >>>> Signed-off-by: Terry Bowman <terry.bowman@amd.com> >>>> Tested-by: Jean Delvare <jdelvare@suse.de> >>>> Reviewed-by: Jean Delvare <jdelvare@suse.de> >>>> --- >>>> drivers/watchdog/sp5100_tco.c | 155 ++++++++++++++++++---------------- >>>> drivers/watchdog/sp5100_tco.h | 1 + >>>> 2 files changed, 82 insertions(+), 74 deletions(-) >>>> >>>> diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c >>>> index b365bbc9ac36..16e122d5045e 100644 >>>> --- a/drivers/watchdog/sp5100_tco.c >>>> +++ b/drivers/watchdog/sp5100_tco.c >>>> @@ -223,6 +223,55 @@ static u32 sp5100_tco_read_pm_reg32(u8 index) >>>> return val; >>>> } >>>> +static u32 sp5100_tco_request_region(struct device *dev, >>>> + u32 mmio_addr, >>>> + const char *dev_name) >>>> +{ >>>> + if (!devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, >>>> + dev_name)) { >>>> + dev_dbg(dev, "MMIO address 0x%08x already in use\n", mmio_addr); >>>> + return 0; >>>> + } >>>> + >>>> + return mmio_addr; >>>> +} >>>> + >>>> +static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, >>>> + u32 mmio_addr, >>>> + u32 alt_mmio_addr, >>>> + const char *dev_name) >>>> +{ >>>> + struct device *dev = tco->wdd.parent; >>>> + >>>> + dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); >>>> + >>>> + if (!mmio_addr && !alt_mmio_addr) >>>> + return -ENODEV; >>>> + >>>> + /* Check for MMIO address and alternate MMIO address conflicts */ >>>> + if (mmio_addr) >>>> + mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); >>>> + >>>> + if (!mmio_addr && alt_mmio_addr) >>>> + mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); >>>> + >>>> + if (!mmio_addr) { >>>> + dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); >>>> + return -EBUSY; >>>> + } >>>> + >>>> + tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); >>>> + if (!tco->tcobase) { >>>> + dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); >>>> + devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); >>>> + return -ENOMEM; >>>> + } >>>> + >>>> + dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); >>>> + >>> >>> I know this is the same as the old code, but I think it would make sense to change >>> this as suggested by 0-day and use %px instead. >>> >>> Thanks, >>> Guenter >> >> > Hi Guenter, > > This line was changed in v4 and should be reverted. It should be using the mmio_addr > physical address with '0x%08x' formatting instead of tco->tcobase. This would be: > > dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", mmio_addr); > > The dmesg then provides: > > [ 5.972921] sp5100_tco: SP5100/SB800 TCO WatchDog Timer Driver > [ 5.978238] sp5100-tco sp5100-tco: Using 0xfeb00000 for watchdog MMIO address > [ 5.978252] sp5100-tco sp5100-tco: Watchdog hardware is disabled > > Do your agree? > Yes. Displaying the mapped address has zero if any value. Guenter
diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c index b365bbc9ac36..16e122d5045e 100644 --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c @@ -223,6 +223,55 @@ static u32 sp5100_tco_read_pm_reg32(u8 index) return val; } +static u32 sp5100_tco_request_region(struct device *dev, + u32 mmio_addr, + const char *dev_name) +{ + if (!devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, + dev_name)) { + dev_dbg(dev, "MMIO address 0x%08x already in use\n", mmio_addr); + return 0; + } + + return mmio_addr; +} + +static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, + u32 mmio_addr, + u32 alt_mmio_addr, + const char *dev_name) +{ + struct device *dev = tco->wdd.parent; + + dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); + + if (!mmio_addr && !alt_mmio_addr) + return -ENODEV; + + /* Check for MMIO address and alternate MMIO address conflicts */ + if (mmio_addr) + mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); + + if (!mmio_addr && alt_mmio_addr) + mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); + + if (!mmio_addr) { + dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); + return -EBUSY; + } + + tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); + if (!tco->tcobase) { + dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); + devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); + return -ENOMEM; + } + + dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); + + return 0; +} + static int sp5100_tco_timer_init(struct sp5100_tco *tco) { struct watchdog_device *wdd = &tco->wdd; @@ -264,6 +313,7 @@ static int sp5100_tco_setupdevice(struct device *dev, struct sp5100_tco *tco = watchdog_get_drvdata(wdd); const char *dev_name; u32 mmio_addr = 0, val; + u32 alt_mmio_addr = 0; int ret; /* Request the IO ports used by this driver */ @@ -282,11 +332,32 @@ static int sp5100_tco_setupdevice(struct device *dev, dev_name = SP5100_DEVNAME; mmio_addr = sp5100_tco_read_pm_reg32(SP5100_PM_WATCHDOG_BASE) & 0xfffffff8; + + /* + * Secondly, find the watchdog timer MMIO address + * from SBResource_MMIO register. + */ + + /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */ + pci_read_config_dword(sp5100_tco_pci, + SP5100_SB_RESOURCE_MMIO_BASE, + &val); + + /* Verify MMIO is enabled and using bar0 */ + if ((val & SB800_ACPI_MMIO_MASK) == SB800_ACPI_MMIO_DECODE_EN) + alt_mmio_addr = (val & ~0xfff) + SB800_PM_WDT_MMIO_OFFSET; break; case sb800: dev_name = SB800_DEVNAME; mmio_addr = sp5100_tco_read_pm_reg32(SB800_PM_WATCHDOG_BASE) & 0xfffffff8; + + /* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */ + val = sp5100_tco_read_pm_reg32(SB800_PM_ACPI_MMIO_EN); + + /* Verify MMIO is enabled and using bar0 */ + if ((val & SB800_ACPI_MMIO_MASK) == SB800_ACPI_MMIO_DECODE_EN) + alt_mmio_addr = (val & ~0xfff) + SB800_PM_WDT_MMIO_OFFSET; break; case efch: dev_name = SB800_DEVNAME; @@ -305,87 +376,23 @@ static int sp5100_tco_setupdevice(struct device *dev, val = sp5100_tco_read_pm_reg8(EFCH_PM_DECODEEN); if (val & EFCH_PM_DECODEEN_WDT_TMREN) mmio_addr = EFCH_PM_WDT_ADDR; + + val = sp5100_tco_read_pm_reg8(EFCH_PM_ISACONTROL); + if (val & EFCH_PM_ISACONTROL_MMIOEN) + alt_mmio_addr = EFCH_PM_ACPI_MMIO_ADDR + + EFCH_PM_ACPI_MMIO_WDT_OFFSET; break; default: return -ENODEV; } - /* Check MMIO address conflict */ - if (!mmio_addr || - !devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, - dev_name)) { - if (mmio_addr) - dev_dbg(dev, "MMIO address 0x%08x already in use\n", - mmio_addr); - switch (tco->tco_reg_layout) { - case sp5100: - /* - * Secondly, Find the watchdog timer MMIO address - * from SBResource_MMIO register. - */ - /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */ - pci_read_config_dword(sp5100_tco_pci, - SP5100_SB_RESOURCE_MMIO_BASE, - &mmio_addr); - if ((mmio_addr & (SB800_ACPI_MMIO_DECODE_EN | - SB800_ACPI_MMIO_SEL)) != - SB800_ACPI_MMIO_DECODE_EN) { - ret = -ENODEV; - goto unreg_region; - } - mmio_addr &= ~0xFFF; - mmio_addr += SB800_PM_WDT_MMIO_OFFSET; - break; - case sb800: - /* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */ - mmio_addr = - sp5100_tco_read_pm_reg32(SB800_PM_ACPI_MMIO_EN); - if ((mmio_addr & (SB800_ACPI_MMIO_DECODE_EN | - SB800_ACPI_MMIO_SEL)) != - SB800_ACPI_MMIO_DECODE_EN) { - ret = -ENODEV; - goto unreg_region; - } - mmio_addr &= ~0xFFF; - mmio_addr += SB800_PM_WDT_MMIO_OFFSET; - break; - case efch: - val = sp5100_tco_read_pm_reg8(EFCH_PM_ISACONTROL); - if (!(val & EFCH_PM_ISACONTROL_MMIOEN)) { - ret = -ENODEV; - goto unreg_region; - } - mmio_addr = EFCH_PM_ACPI_MMIO_ADDR + - EFCH_PM_ACPI_MMIO_WDT_OFFSET; - break; - } - dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", - mmio_addr); - if (!devm_request_mem_region(dev, mmio_addr, - SP5100_WDT_MEM_MAP_SIZE, - dev_name)) { - dev_dbg(dev, "MMIO address 0x%08x already in use\n", - mmio_addr); - ret = -EBUSY; - goto unreg_region; - } - } - - tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); - if (!tco->tcobase) { - dev_err(dev, "failed to get tcobase address\n"); - ret = -ENOMEM; - goto unreg_region; + ret = sp5100_tco_prepare_base(tco, mmio_addr, alt_mmio_addr, dev_name); + if (!ret) { + /* Setup the watchdog timer */ + tco_timer_enable(tco); + ret = sp5100_tco_timer_init(tco); } - dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", mmio_addr); - - /* Setup the watchdog timer */ - tco_timer_enable(tco); - - ret = sp5100_tco_timer_init(tco); - -unreg_region: release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE); return ret; } diff --git a/drivers/watchdog/sp5100_tco.h b/drivers/watchdog/sp5100_tco.h index adf015aa4126..daee872f9b71 100644 --- a/drivers/watchdog/sp5100_tco.h +++ b/drivers/watchdog/sp5100_tco.h @@ -58,6 +58,7 @@ #define SB800_PM_WATCHDOG_SECOND_RES GENMASK(1, 0) #define SB800_ACPI_MMIO_DECODE_EN BIT(0) #define SB800_ACPI_MMIO_SEL BIT(1) +#define SB800_ACPI_MMIO_MASK GENMASK(1, 0) #define SB800_PM_WDT_MMIO_OFFSET 0xB00