* [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state @ 2023-04-27 5:06 Kai-Heng Feng 2023-04-27 5:06 ` [PATCH v3 2/2] ata: libata: Defer rescan on suspended device Kai-Heng Feng 2023-04-27 8:52 ` [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state kernel test robot 0 siblings, 2 replies; 5+ messages in thread From: Kai-Heng Feng @ 2023-04-27 5:06 UTC (permalink / raw) To: jejb, martin.petersen Cc: bblock, acelan.kao, Kai-Heng Feng, Rafael J. Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman, linux-pm, linux-kernel Define pm_suspend_target_state so it can still be used when CONFIG_SUSPEND or CONFIG_PM_SLEEP is not set. Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> --- v3: - New patch to resolve undefined pm_suspend_target_state. drivers/base/power/wakeup.c | 5 ----- include/linux/suspend.h | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 7cc0c0cf8eaa..a917219feea6 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -19,11 +19,6 @@ #include "power.h" -#ifndef CONFIG_SUSPEND -suspend_state_t pm_suspend_target_state; -#define pm_suspend_target_state (PM_SUSPEND_ON) -#endif - #define list_for_each_entry_rcu_locked(pos, head, member) \ list_for_each_entry_rcu(pos, head, member, \ srcu_read_lock_held(&wakeup_srcu)) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index cfe19a028918..ff64a596be4b 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -530,6 +530,7 @@ static inline void ksys_sync_helper(void) {} #define pm_notifier(fn, pri) do { (void)(fn); } while (0) +#define pm_suspend_target_state (PM_SUSPEND_ON) static inline bool pm_wakeup_pending(void) { return false; } static inline void pm_system_wakeup(void) {} static inline void pm_wakeup_clear(bool reset) {} -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] ata: libata: Defer rescan on suspended device 2023-04-27 5:06 [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state Kai-Heng Feng @ 2023-04-27 5:06 ` Kai-Heng Feng 2023-04-27 10:56 ` kernel test robot 2023-04-27 11:38 ` kernel test robot 2023-04-27 8:52 ` [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state kernel test robot 1 sibling, 2 replies; 5+ messages in thread From: Kai-Heng Feng @ 2023-04-27 5:06 UTC (permalink / raw) To: jejb, martin.petersen Cc: bblock, acelan.kao, Kai-Heng Feng, Damien Le Moal, linux-ide, linux-kernel During system resume, if an EH is schduled after ATA host is resumed (i.e. ATA_PFLAG_PM_PENDING cleared), but before the disk device is fully resumed, the device_lock hold by scsi_rescan_device() is never released so the dpm_resume() of the disk is blocked forerver. That's because scsi_attach_vpd() is expecting the disk device is in operational state, as it doesn't work on suspended device. To avoid such deadlock, defer rescan if the disk is still suspended so the resume process of the disk device can proceed. At the end of the resume process, use the complete() callback to schedule the rescan task. Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> --- v3: - New patch to resolve undefined pm_suspend_target_state. v2: - Schedule rescan task at the end of system resume phase. - Wording. drivers/ata/libata-core.c | 11 +++++++++++ drivers/ata/libata-eh.c | 11 +++++++++-- include/linux/libata.h | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 14c17c3bda4e..564d72bf1ec6 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5093,6 +5093,16 @@ static int ata_port_pm_poweroff(struct device *dev) return 0; } +static void ata_port_pm_complete(struct device *dev) +{ + struct ata_port *ap = to_ata_port(dev); + + if (ap->pflags & ATA_PFLAG_DEFER_RESCAN) + schedule_work(&(ap->scsi_rescan_task)); + + ap->pflags &= ~ATA_PFLAG_DEFER_RESCAN; +} + static const unsigned int ata_port_resume_ehi = ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; @@ -5158,6 +5168,7 @@ static const struct dev_pm_ops ata_port_pm_ops = { .thaw = ata_port_pm_resume, .poweroff = ata_port_pm_poweroff, .restore = ata_port_pm_resume, + .complete = ata_port_pm_complete, .runtime_suspend = ata_port_runtime_suspend, .runtime_resume = ata_port_runtime_resume, diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index a6c901811802..0881b590fb7e 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -15,6 +15,7 @@ #include <linux/blkdev.h> #include <linux/export.h> #include <linux/pci.h> +#include <linux/suspend.h> #include <scsi/scsi.h> #include <scsi/scsi_host.h> #include <scsi/scsi_eh.h> @@ -2983,8 +2984,14 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link, */ ehc->i.flags |= ATA_EHI_SETMODE; - /* schedule the scsi_rescan_device() here */ - schedule_work(&(ap->scsi_rescan_task)); + /* Schedule the scsi_rescan_device() here. + * Defer the rescan if it's in process of + * suspending or resuming. + */ + if (pm_suspend_target_state != PM_SUSPEND_ON) + ap->pflags |= ATA_PFLAG_DEFER_RESCAN; + else + schedule_work(&(ap->scsi_rescan_task)); } else if (dev->class == ATA_DEV_UNKNOWN && ehc->tries[dev->devno] && ata_class_enabled(ehc->classes[dev->devno])) { diff --git a/include/linux/libata.h b/include/linux/libata.h index a759dfbdcc91..aaa549444abc 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -189,6 +189,7 @@ enum { ATA_PFLAG_UNLOADING = (1 << 9), /* driver is being unloaded */ ATA_PFLAG_UNLOADED = (1 << 10), /* driver is unloaded */ + ATA_PFLAG_DEFER_RESCAN = (1 << 16), /* peform deferred rescan on system resume */ ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ ATA_PFLAG_INIT_GTM_VALID = (1 << 19), /* initial gtm data valid */ -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 2/2] ata: libata: Defer rescan on suspended device 2023-04-27 5:06 ` [PATCH v3 2/2] ata: libata: Defer rescan on suspended device Kai-Heng Feng @ 2023-04-27 10:56 ` kernel test robot 2023-04-27 11:38 ` kernel test robot 1 sibling, 0 replies; 5+ messages in thread From: kernel test robot @ 2023-04-27 10:56 UTC (permalink / raw) To: Kai-Heng Feng, jejb, martin.petersen Cc: oe-kbuild-all, bblock, acelan.kao, Kai-Heng Feng, Damien Le Moal, linux-ide, linux-kernel Hi Kai-Heng, kernel test robot noticed the following build errors: [auto build test ERROR on rafael-pm/linux-next] [also build test ERROR on linus/master v6.3 next-20230426] [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#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Kai-Heng-Feng/ata-libata-Defer-rescan-on-suspended-device/20230427-130726 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20230427050603.612145-2-kai.heng.feng%40canonical.com patch subject: [PATCH v3 2/2] ata: libata: Defer rescan on suspended device config: i386-randconfig-a005 (https://download.01.org/0day-ci/archive/20230427/202304271800.2IH4Swv7-lkp@intel.com/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/0e5dc37a85d9e0c92e2ae38903928499b2b17d04 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Kai-Heng-Feng/ata-libata-Defer-rescan-on-suspended-device/20230427-130726 git checkout 0e5dc37a85d9e0c92e2ae38903928499b2b17d04 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=i386 olddefconfig make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202304271800.2IH4Swv7-lkp@intel.com/ All errors (new ones prefixed by >>, old ones prefixed by <<): >> ERROR: modpost: "pm_suspend_target_state" [drivers/ata/libata.ko] undefined! -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 2/2] ata: libata: Defer rescan on suspended device 2023-04-27 5:06 ` [PATCH v3 2/2] ata: libata: Defer rescan on suspended device Kai-Heng Feng 2023-04-27 10:56 ` kernel test robot @ 2023-04-27 11:38 ` kernel test robot 1 sibling, 0 replies; 5+ messages in thread From: kernel test robot @ 2023-04-27 11:38 UTC (permalink / raw) To: Kai-Heng Feng, jejb, martin.petersen Cc: oe-kbuild-all, bblock, acelan.kao, Kai-Heng Feng, Damien Le Moal, linux-ide, linux-kernel Hi Kai-Heng, kernel test robot noticed the following build errors: [auto build test ERROR on rafael-pm/linux-next] [also build test ERROR on linus/master pavel-leds/for-next v6.3 next-20230426] [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#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Kai-Heng-Feng/ata-libata-Defer-rescan-on-suspended-device/20230427-130726 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20230427050603.612145-2-kai.heng.feng%40canonical.com patch subject: [PATCH v3 2/2] ata: libata: Defer rescan on suspended device config: mips-randconfig-r014-20230427 (https://download.01.org/0day-ci/archive/20230427/202304271942.yVqlIimT-lkp@intel.com/config) compiler: mipsel-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/0e5dc37a85d9e0c92e2ae38903928499b2b17d04 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Kai-Heng-Feng/ata-libata-Defer-rescan-on-suspended-device/20230427-130726 git checkout 0e5dc37a85d9e0c92e2ae38903928499b2b17d04 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202304271942.yVqlIimT-lkp@intel.com/ All errors (new ones prefixed by >>): mipsel-linux-ld: drivers/ata/libata-eh.o: in function `ata_eh_revalidate_and_attach': >> libata-eh.c:(.text.ata_eh_revalidate_and_attach+0x74): undefined reference to `pm_suspend_target_state' >> mipsel-linux-ld: libata-eh.c:(.text.ata_eh_revalidate_and_attach+0x1f8): undefined reference to `pm_suspend_target_state' -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state 2023-04-27 5:06 [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state Kai-Heng Feng 2023-04-27 5:06 ` [PATCH v3 2/2] ata: libata: Defer rescan on suspended device Kai-Heng Feng @ 2023-04-27 8:52 ` kernel test robot 1 sibling, 0 replies; 5+ messages in thread From: kernel test robot @ 2023-04-27 8:52 UTC (permalink / raw) To: Kai-Heng Feng, jejb, martin.petersen Cc: llvm, oe-kbuild-all, bblock, acelan.kao, Kai-Heng Feng, Rafael J. Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman, linux-pm, linux-kernel Hi Kai-Heng, kernel test robot noticed the following build errors: [auto build test ERROR on rafael-pm/linux-next] [also build test ERROR on linus/master pavel-leds/for-next v6.3 next-20230426] [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#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Kai-Heng-Feng/ata-libata-Defer-rescan-on-suspended-device/20230427-130726 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20230427050603.612145-1-kai.heng.feng%40canonical.com patch subject: [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state config: mips-randconfig-r002-20230427 (https://download.01.org/0day-ci/archive/20230427/202304271651.DsSWc2rx-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 437b7602e4a998220871de78afcb020b9c14a661) 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 # install mips cross compiling tool for clang build # apt-get install binutils-mipsel-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/03ca901d88f622ddd3bfd75b9f1b62d99881e430 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Kai-Heng-Feng/ata-libata-Defer-rescan-on-suspended-device/20230427-130726 git checkout 03ca901d88f622ddd3bfd75b9f1b62d99881e430 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202304271651.DsSWc2rx-lkp@intel.com/ All errors (new ones prefixed by >>): >> ld.lld: error: undefined symbol: pm_suspend_target_state >>> referenced by wakeup.c >>> drivers/base/power/wakeup.o:(device_wakeup_enable) in archive vmlinux.a >>> referenced by wakeup.c >>> drivers/base/power/wakeup.o:(device_wakeup_enable) in archive vmlinux.a -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-04-27 11:39 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-04-27 5:06 [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state Kai-Heng Feng 2023-04-27 5:06 ` [PATCH v3 2/2] ata: libata: Defer rescan on suspended device Kai-Heng Feng 2023-04-27 10:56 ` kernel test robot 2023-04-27 11:38 ` kernel test robot 2023-04-27 8:52 ` [PATCH v3 1/2] PM: suspend: Define pm_suspend_target_state kernel test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox