scsi: use generic power management
Subsystems (12)
v4 cover scsi: use generic power management
Linux Kernel Mentee: Remove Legacy Power Management.
The purpose of this patch series is to upgrade power management in xxxxxxxx drivers. This has been done by upgrading .suspend() and .resume() callbacks.
The upgrade makes sure that the involvement of PCI Core does not change the order of operations executed in a driver. Thus, does not change its behavior.
In general, drivers with legacy PM, .suspend() and .resume() make use of PCI helper functions like pci_enable/disable_device_mem(), pci_set_power_state(), pci_save/restore_state(), pci_enable/disable_device(), etc. to complete their job.
The conversion requires the removal of those function calls, change the callbacks' definition accordingly and make use of dev_pm_ops structure.
All patches are compile-tested only.
Test tools:
- Compiler: gcc (GCC) 10.2.0
- allmodconfig build: make -j$(nproc) W=1 all
Vaibhav Gupta (29):
scsi: megaraid_sas: Drop PCI wakeup calls from .resume
scsi: megaraid_sas: use generic power management
scsi: megaraid_sas: update function description
scsi: aacraid: Drop pci_enable_wake() from .resume
scsi: aacraid: use generic power management
scsi: aic7xxx: use generic power management
scsi: aic79xx: use generic power management
scsi: arcmsr: Drop PCI wakeup calls from .resume
scsi: arcmsr: use generic power management
scsi: esas2r: Drop PCI Wakeup calls from .resume
scsi: esas2r: use generic power management
scsi: hisi_sas_v3_hw: Drop PCI Wakeup calls from .resume
scsi: hisi_sas_v3_hw: Don't use PCI helper functions
scsi: hisi_sas_v3_hw: Remove extra function calls for runtime pm
scsi: mpt3sas_scsih: Drop PCI Wakeup calls from .resume
scsi: mpt3sas_scsih: use generic power management
scsi: lpfc: use generic power management
scsi: pm_8001: Drop PCI Wakeup calls from .resume
scsi: pm_8001: use generic power management
scsi: hpsa: use generic power management
scsi: 3w-9xxx: Drop PCI Wakeup calls from .resume
scsi: 3w-9xxx: use generic power management
scsi: 3w-sas: Drop PCI Wakeup calls from .resume
scsi: 3w-sas: use generic power management
scsi: mvumi: Drop PCI Wakeup calls from .resume
scsi: mvumi: use generic power management
scsi: mvumi: update function description
scsi: pmcraid: Drop PCI Wakeup calls from .resume
scsi: pmcraid: use generic power management
drivers/scsi/3w-9xxx.c | 30 ++----- drivers/scsi/3w-sas.c | 32 ++----- drivers/scsi/aacraid/linit.c | 34 ++------ drivers/scsi/aic7xxx/aic79xx.h | 12 +-- drivers/scsi/aic7xxx/aic79xx_core.c | 8 +- drivers/scsi/aic7xxx/aic79xx_osm_pci.c | 43 +++------- drivers/scsi/aic7xxx/aic79xx_pci.c | 6 +- drivers/scsi/aic7xxx/aic7xxx.h | 10 +-- drivers/scsi/aic7xxx/aic7xxx_core.c | 6 +- drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | 46 +++------- drivers/scsi/aic7xxx/aic7xxx_pci.c | 4 +- drivers/scsi/arcmsr/arcmsr_hba.c | 29 ++----- drivers/scsi/esas2r/esas2r.h | 5 +- drivers/scsi/esas2r/esas2r_init.c | 48 +++-------- drivers/scsi/esas2r/esas2r_main.c | 3 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 41 ++------- drivers/scsi/hpsa.c | 12 +-- drivers/scsi/lpfc/lpfc_init.c | 100 +++++++--------------- drivers/scsi/megaraid/megaraid_sas_base.c | 54 +++--------- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 35 +++----- drivers/scsi/mvumi.c | 49 +++-------- drivers/scsi/pm8001/pm8001_init.c | 46 ++++------ drivers/scsi/pmcraid.c | 44 +++------- 23 files changed, 193 insertions(+), 504 deletions(-)
Signature · 1 line
2.28.0
PATCH v4 1/29 scsi: megaraid_sas: Drop PCI wakeup calls from .resume
The driver calls pci_enable_wake(...., false) in megasas_resume(), and there is no corresponding pci_enable_wake(...., true) in megasas_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from megasas_resume().
--- drivers/scsi/megaraid/megaraid_sas_base.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_base.c +0 -1
@@ -7668,7 +7668,6 @@ megasas_resume(struct pci_dev *pdev) host = instance->host;pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev);dev_info (&pdev->dev,"%s is called\n" , __func__);
Signature · 1 line
2.28.0
PATCH v4 2/29 scsi: megaraid_sas: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 51 ++++++----------------- 1 file changed, 13 insertions(+), 38 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +13 -38
@@ -7593,25 +7593,23 @@ static void megasas_shutdown_controller(struct megasas_instance *instance,megasas_return_cmd (instance, cmd); } -#ifdef CONFIG_PM /** * megasas_suspend - driver suspend entry point -* @pdev: PCI device structure -* @state: PCI power state to suspend routine +* @dev: Device structure */ -static int -megasas_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused +megasas_suspend (struct device *dev) {struct megasas_instance *instance; - instance =pci_get_drvdata (pdev); + instance =dev_get_drvdata (dev);if (!instance)return 0 ; instance->unload =1 ; -dev_info (&pdev->dev,"%s is called\n" , __func__); +dev_info (dev,"%s is called\n" , __func__);/* Shutdown SR-IOV heartbeat timer */ if (instance->requestorId && !instance->skip_heartbeat_timer_del)
@@ -7641,47 +7639,29 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)if (instance->msix_vectors)pci_free_irq_vectors (instance->pdev); -pci_save_state (pdev); -pci_disable_device (pdev); - -pci_set_power_state (pdev,pci_choose_state (pdev, state)); -return 0 ; }/** * megasas_resume- driver resume entry point -* @pdev: PCI device structure +* @dev: Device structure */ -static int -megasas_resume (struct pci_dev *pdev) +static int __maybe_unused +megasas_resume (struct device *dev) {int rval;struct Scsi_Host *host;struct megasas_instance *instance;u32 status_reg; - instance =pci_get_drvdata (pdev); + instance =dev_get_drvdata (dev);if (!instance)return 0 ; host = instance->host; -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - -dev_info (&pdev->dev,"%s is called\n" , __func__); -/* -* PCI prepping: enable device set bus mastering and dma mask -*/ - rval =pci_enable_device_mem (pdev); -if (rval) { -dev_err (&pdev->dev,"Enable device failed\n" ); -return rval; - } - -pci_set_master (pdev); +dev_info (dev,"%s is called\n" , __func__);/* * We expect the FW state to be READY
@@ -7807,14 +7787,8 @@ megasas_resume(struct pci_dev *pdev) fail_set_dma_mask: fail_ready_state: -pci_disable_device (pdev); -return -ENODEV ; } -#else -#define megasas_suspend NULL -#define megasas_resume NULL -#endif static inline int megasas_wait_for_adapter_operational (struct megasas_instance *instance)
@@ -8572,6 +8546,8 @@ static const struct file_operations megasas_mgmt_fops = { .llseek = noop_llseek, }; +static SIMPLE_DEV_PM_OPS(megasas_pm_ops, megasas_suspend, megasas_resume); +/* * PCI hotplug support registration structure */
@@ -8581,8 +8557,7 @@ static struct pci_driver megasas_pci_driver = { .id_table = megasas_pci_table, .probe = megasas_probe_one, .remove = megasas_detach_one, - .suspend = megasas_suspend, - .resume = megasas_resume, + .driver.pm = &megasas_pm_ops, .shutdown = megasas_shutdown, };
Signature · 1 line
2.28.0
PATCH v4 3/29 scsi: megaraid_sas: update function description
In reply to Vaibhav GuptaFunction parameter 'pdev 'is described as Generic Device Structure. It is a PCI device structure.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
@@ -7958,7 +7958,7 @@ static void megasas_detach_one(struct pci_dev *pdev)/** * megasas_shutdown - Shutdown entry point -* @pdev: Generic device structure +* @pdev: PCI device structure */ static void megasas_shutdown (struct pci_dev *pdev) {
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 4/29 scsi: aacraid: Drop pci_enable_wake() from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in aac_resume(), and there is no corresponding pci_enable_wake(...., true) in aac_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this is a bug and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from aac_resume().
--- drivers/scsi/aacraid/linit.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/aacraid/linit.c +0 -1
@@ -1938,7 +1938,6 @@ static int aac_resume(struct pci_dev *pdev)int r;pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev); r =pci_enable_device (pdev);
Signature · 1 line
2.28.0
PATCH v4 5/29 scsi: aacraid: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/aacraid/linit.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-)
drivers/scsi/aacraid/linit.c +7 -26
@@ -1910,11 +1910,9 @@ static int aac_acquire_resources(struct aac_dev *dev) } -#if (defined(CONFIG_PM )) -static int aac_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused aac_suspend (struct device *dev) { - -struct Scsi_Host *shost =pci_get_drvdata (pdev); +struct Scsi_Host *shost =dev_get_drvdata (dev);struct aac_dev *aac = (struct aac_dev *)shost->hostdata;scsi_host_block (shost);
@@ -1923,28 +1921,14 @@ static int aac_suspend(struct pci_dev *pdev, pm_message_t state)aac_release_resources (aac); -pci_set_drvdata (pdev, shost); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_set_power_state (pdev,pci_choose_state (pdev, state)); -return 0 ; } -static int aac_resume (struct pci_dev *pdev) +static int __maybe_unused aac_resume (struct device *dev) { -struct Scsi_Host *shost =pci_get_drvdata (pdev); +struct Scsi_Host *shost =dev_get_drvdata (dev);struct aac_dev *aac = (struct aac_dev *)shost->hostdata; -int r; - -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - r =pci_enable_device (pdev); - -if (r) - goto fail_device; -pci_set_master (pdev);if (aac_acquire_resources (aac)) goto fail_device;/*
@@ -1959,10 +1943,8 @@ static int aac_resume(struct pci_dev *pdev) fail_device:printk (KERN_INFO "%s%d: resume failed.\n" , aac->name, aac->id);scsi_host_put (shost); -pci_disable_device (pdev);return -ENODEV ; } -#endif static void aac_shutdown (struct pci_dev *dev) {
@@ -2107,15 +2089,14 @@ static struct pci_error_handlers aac_pci_err_handler = { .resume = aac_pci_resume, }; +static SIMPLE_DEV_PM_OPS(aac_pm_ops, aac_suspend, aac_resume); +static struct pci_driver aac_pci_driver = { .name =AAC_DRIVERNAME , .id_table = aac_pci_tbl, .probe = aac_probe_one, .remove = aac_remove_one, -#if (defined(CONFIG_PM)) - .suspend = aac_suspend, - .resume = aac_resume, -#endif + .driver.pm = &aac_pm_ops, .shutdown = aac_shutdown, .err_handler = &aac_pci_err_handler, };
Signature · 1 line
2.28.0
PATCH v4 6/29 scsi: aic7xxx: use generic power management
In reply to Vaibhav Guptause generic power management
Drivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/aic7xxx/aic7xxx.h | 10 ++---- drivers/scsi/aic7xxx/aic7xxx_core.c | 6 ++-- drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | 46 ++++++-------------------- drivers/scsi/aic7xxx/aic7xxx_pci.c | 4 +-- 4 files changed, 17 insertions(+), 49 deletions(-)
drivers/scsi/aic7xxx/aic7xxx.h +3 -7
@@ -1134,9 +1134,7 @@ const struct ahc_pci_identity *ahc_find_pci_device(ahc_dev_softc_t);int ahc_pci_config (struct ahc_softc *,const struct ahc_pci_identity *);int ahc_pci_test_register_access (struct ahc_softc *); -#ifdef CONFIG_PM -void ahc_pci_resume (struct ahc_softc *ahc); -#endif +void __maybe_unused ahc_pci_resume (struct ahc_softc *ahc);/*************************** EISA/VL Front End ********************************/ struct aic7770_identity *aic7770_find_device (uint32_t );
@@ -1160,10 +1158,8 @@ int ahc_chip_init(struct ahc_softc *ahc);int ahc_init (struct ahc_softc *ahc);void ahc_intr_enable (struct ahc_softc *ahc,int enable);void ahc_pause_and_flushwork (struct ahc_softc *ahc); -#ifdef CONFIG_PM -int ahc_suspend (struct ahc_softc *ahc); -int ahc_resume (struct ahc_softc *ahc); -#endif +int __maybe_unused ahc_suspend (struct ahc_softc *ahc); +int __maybe_unused ahc_resume (struct ahc_softc *ahc);void ahc_set_unit (struct ahc_softc *,int );void ahc_set_name (struct ahc_softc *,char *);void ahc_free (struct ahc_softc *ahc);
drivers/scsi/aic7xxx/aic7xxx_core.c +2 -4
@@ -5590,8 +5590,7 @@ ahc_pause_and_flushwork(struct ahc_softc *ahc) ahc->flags &= ~AHC_ALL_INTERRUPTS ; } -#ifdef CONFIG_PM -int +int __maybe_unused ahc_suspend (struct ahc_softc *ahc) {
@@ -5617,7 +5616,7 @@ ahc_suspend(struct ahc_softc *ahc)return (0 ); } -int +int __maybe_unused ahc_resume (struct ahc_softc *ahc) {
@@ -5626,7 +5625,6 @@ ahc_resume(struct ahc_softc *ahc)ahc_restart (ahc);return (0 ); } -#endif /************************** Busy Target Table *********************************/ /* * Return the untagged transaction id for a given target/channel lun.
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +11 -35
72 lines not on this page · raw message
drivers/scsi/aic7xxx/aic7xxx_pci.c +1 -3
@@ -2008,8 +2008,7 @@ ahc_pci_chip_init(struct ahc_softc *ahc)return (ahc_chip_init (ahc)); } -#ifdef CONFIG_PM -void +void __maybe_unused ahc_pci_resume (struct ahc_softc *ahc) {/*
@@ -2040,7 +2039,6 @@ ahc_pci_resume(struct ahc_softc *ahc)ahc_release_seeprom (&sd); } } -#endif static int ahc_aic785X_setup (struct ahc_softc *ahc)
Signature · 1 line
2.28.0
PATCH v4 7/29 scsi: aic79xx: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/aic7xxx/aic79xx.h | 12 +++---- drivers/scsi/aic7xxx/aic79xx_core.c | 8 ++--- drivers/scsi/aic7xxx/aic79xx_osm_pci.c | 43 +++++++------------------- drivers/scsi/aic7xxx/aic79xx_pci.c | 6 ++-- 4 files changed, 20 insertions(+), 49 deletions(-)
drivers/scsi/aic7xxx/aic79xx.h +4 -8
@@ -1330,10 +1330,8 @@ const struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);int ahd_pci_config (struct ahd_softc *,const struct ahd_pci_identity *);int ahd_pci_test_register_access (struct ahd_softc *); -#ifdef CONFIG_PM -void ahd_pci_suspend (struct ahd_softc *); -void ahd_pci_resume (struct ahd_softc *); -#endif +void __maybe_unused ahd_pci_suspend (struct ahd_softc *); +void __maybe_unused ahd_pci_resume (struct ahd_softc *);/************************** SCB and SCB queue management **********************/ void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd,
@@ -1344,10 +1342,8 @@ struct ahd_softc *ahd_alloc(void *platform_arg, char *name);int ahd_softc_init (struct ahd_softc *);void ahd_controller_info (struct ahd_softc *ahd,char *buf);int ahd_init (struct ahd_softc *ahd); -#ifdef CONFIG_PM -int ahd_suspend (struct ahd_softc *ahd); -void ahd_resume (struct ahd_softc *ahd); -#endif +int __maybe_unused ahd_suspend (struct ahd_softc *ahd); +void __maybe_unused ahd_resume (struct ahd_softc *ahd);int ahd_default_config (struct ahd_softc *ahd);int ahd_parse_vpddata (struct ahd_softc *ahd,struct vpd_config *vpd);
drivers/scsi/aic7xxx/aic79xx_core.c +2 -6
@@ -7866,11 +7866,9 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd) ahd->flags &= ~AHD_ALL_INTERRUPTS ; } -#ifdef CONFIG_PM -int +int __maybe_unused ahd_suspend (struct ahd_softc *ahd) { -ahd_pause_and_flushwork (ahd);if (LIST_FIRST (&ahd->pending_scbs) !=NULL ) {
@@ -7881,15 +7879,13 @@ ahd_suspend(struct ahd_softc *ahd)return (0 ); } -void +void __maybe_unused ahd_resume (struct ahd_softc *ahd) { -ahd_reset (ahd,/*reinit*/ TRUE);ahd_intr_enable (ahd, TRUE);ahd_restart (ahd); } -#endif /************************** Busy Target Table *********************************/ /*
drivers/scsi/aic7xxx/aic79xx_osm_pci.c +12 -31
75 lines not on this page · raw message
drivers/scsi/aic7xxx/aic79xx_pci.c +2 -4
@@ -377,8 +377,7 @@ ahd_pci_config(struct ahd_softc *ahd, const struct ahd_pci_identity *entry)return ahd_pci_map_int (ahd); } -#ifdef CONFIG_PM -void +void __maybe_unused ahd_pci_suspend (struct ahd_softc *ahd) {/*
@@ -394,7 +393,7 @@ ahd_pci_suspend(struct ahd_softc *ahd) } -void +void __maybe_unused ahd_pci_resume (struct ahd_softc *ahd) { ahd_pci_write_config(ahd->dev_softc, DEVCONFIG,
@@ -404,7 +403,6 @@ ahd_pci_resume(struct ahd_softc *ahd)ahd_pci_write_config (ahd->dev_softc,CSIZE_LATTIME , ahd->suspend_state.pci_state.csize_lattime,/*bytes*/ 1 ); } -#endif /* * Perform some simple tests that should catch situations where
Signature · 1 line
2.28.0
PATCH v4 8/29 scsi: arcmsr: Drop PCI wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in arcmsr_resume(), and there is no corresponding pci_enable_wake(...., true) in arcmsr_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from arcmsr_resume().
--- drivers/scsi/arcmsr/arcmsr_hba.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/arcmsr/arcmsr_hba.c +0 -1
@@ -1154,7 +1154,6 @@ static int arcmsr_resume(struct pci_dev *pdev) (struct AdapterControlBlock *)host->hostdata;pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev);if (pci_enable_device (pdev)) {pr_warn ("%s: pci_enable_device error\n" , __func__);
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 9/29 scsi: arcmsr: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/arcmsr/arcmsr_hba.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/scsi/arcmsr/arcmsr_hba.c +9 -19
@@ -113,8 +113,8 @@ static int arcmsr_bios_param(struct scsi_device *sdev,static int arcmsr_queue_command (struct Scsi_Host *h,struct scsi_cmnd *cmd);static int arcmsr_probe (struct pci_dev *pdev,const struct pci_device_id *id); -static int arcmsr_suspend (struct pci_dev *pdev,pm_message_t state); -static int arcmsr_resume (struct pci_dev *pdev); +static int __maybe_unused arcmsr_suspend (struct device *dev); +static int __maybe_unused arcmsr_resume (struct device *dev);static void arcmsr_remove (struct pci_dev *pdev);static void arcmsr_shutdown (struct pci_dev *pdev);static void arcmsr_iop_init (struct AdapterControlBlock *acb);
@@ -216,13 +216,14 @@ static struct pci_device_id arcmsr_device_id_table[] = { };MODULE_DEVICE_TABLE (pci, arcmsr_device_id_table); +static SIMPLE_DEV_PM_OPS(arcmsr_pm_ops, arcmsr_suspend, arcmsr_resume); +static struct pci_driver arcmsr_pci_driver = { .name ="arcmsr" , .id_table = arcmsr_device_id_table, .probe = arcmsr_probe, .remove = arcmsr_remove, - .suspend = arcmsr_suspend, - .resume = arcmsr_resume, + .driver.pm = &arcmsr_pm_ops, .shutdown = arcmsr_shutdown, };/*
@@ -1126,8 +1127,9 @@ static void arcmsr_free_irq(struct pci_dev *pdev,pci_free_irq_vectors (pdev); } -static int arcmsr_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused arcmsr_suspend (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct Scsi_Host *host =pci_get_drvdata (pdev);struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata;
@@ -1140,28 +1142,18 @@ static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)flush_work (&acb->arcmsr_do_message_isr_bh);arcmsr_stop_adapter_bgrb (acb);arcmsr_flush_adapter_cache (acb); -pci_set_drvdata (pdev, host); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_set_power_state (pdev,pci_choose_state (pdev, state));return 0 ; } -static int arcmsr_resume (struct pci_dev *pdev) +static int __maybe_unused arcmsr_resume (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct Scsi_Host *host =pci_get_drvdata (pdev);struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata; -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); -if (pci_enable_device (pdev)) { -pr_warn ("%s: pci_enable_device error\n" , __func__); -return -ENODEV ; - }if (arcmsr_set_dma_mask (acb)) goto controller_unregister; -pci_set_master (pdev);if (arcmsr_request_irq (pdev, acb) ==FAILED ) goto controller_stop;switch (acb->adapter_type) {
@@ -1206,9 +1198,7 @@ static int arcmsr_resume(struct pci_dev *pdev)if (acb->adapter_type ==ACB_ADAPTER_TYPE_F )arcmsr_free_io_queue (acb);arcmsr_unmap_pciregion (acb); -pci_release_regions (pdev);scsi_host_put (host); -pci_disable_device (pdev);return -ENODEV ; }
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 10/29 scsi: esas2r: Drop PCI Wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in esas2r_resume(), and there is no corresponding pci_enable_wake(...., true) in esas2r_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from esas2r_resume().
--- drivers/scsi/esas2r/esas2r_init.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/scsi/esas2r/esas2r_init.c +0 -4
@@ -676,10 +676,6 @@ int esas2r_resume(struct pci_dev *pdev)"pci_set_power_state(PCI_D0) " "called");pci_set_power_state (pdev,PCI_D0 ); -esas2r_log_dev (ESAS2R_LOG_INFO , &(pdev->dev), -"pci_enable_wake(PCI_D0, 0) " -"called" ); -pci_enable_wake (pdev,PCI_D0 ,0 );esas2r_log_dev (ESAS2R_LOG_INFO , &(pdev->dev),"pci_restore_state() called" );pci_restore_state (pdev);
Signature · 1 line
2.28.0
PATCH v4 11/29 scsi: esas2r: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/esas2r/esas2r.h | 5 ++-- drivers/scsi/esas2r/esas2r_init.c | 44 +++++++++---------------------- drivers/scsi/esas2r/esas2r_main.c | 3 +-- 3 files changed, 16 insertions(+), 36 deletions(-)
drivers/scsi/esas2r/esas2r.h +3 -2
@@ -996,8 +996,9 @@ void esas2r_adapter_tasklet(unsigned long context);irqreturn_t esas2r_interrupt (int irq,void *dev_id);irqreturn_t esas2r_msi_interrupt (int irq,void *dev_id);void esas2r_kickoff_timer (struct esas2r_adapter *a); -int esas2r_suspend (struct pci_dev *pcid,pm_message_t state); -int esas2r_resume (struct pci_dev *pcid); + +extern const struct dev_pm_ops esas2r_pm_ops; +void esas2r_fw_event_off (struct esas2r_adapter *a);void esas2r_fw_event_on (struct esas2r_adapter *a); bool esas2r_nvram_write(struct esas2r_adapter *a, struct esas2r_request *rq,
drivers/scsi/esas2r/esas2r_init.c +12 -32
72 lines not on this page · raw message
drivers/scsi/esas2r/esas2r_main.c +1 -2
@@ -346,8 +346,7 @@ static struct pci_driver .id_table = esas2r_pci_table, .probe = esas2r_probe, .remove = esas2r_remove, - .suspend = esas2r_suspend, - .resume = esas2r_resume, + .driver.pm = &esas2r_pm_ops, }; static int esas2r_probe(struct pci_dev *pcid,
Signature · 1 line
2.28.0
PATCH v4 12/29 scsi: hisi_sas_v3_hw: Drop PCI Wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in hisi_sas_v3_resume(), and there is no corresponding pci_enable_wake(...., true) in hisi_sas_v3_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from hisi_sas_v3_resume().
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +0 -1
@@ -3492,7 +3492,6 @@ static int _resume_v3_hw(struct device *device)dev_warn (dev,"resuming from operating state [D%d]\n" , device_state);pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev); rc =pci_enable_device (pdev);if (rc) {
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 13/29 scsi: hisi_sas_v3_hw: Don't use PCI helper functions
In reply to Vaibhav GuptaDrivers using new-framework/generic-framework should not handle standard power management operations. These operations were performed by legacy framework through PCI helper functions like pci_save/restore_state(), pci_set_power_state(), etc.
Drivers should not use them now.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -16
@@ -3440,7 +3440,6 @@ static int _suspend_v3_hw(struct device *device)struct hisi_hba *hisi_hba = sha->lldd_ha;struct device *dev = hisi_hba->dev;struct Scsi_Host *shost = hisi_hba->shost; -pci_power_t device_state;int rc;if (!pdev->pm_cap) {
@@ -3466,12 +3465,7 @@ static int _suspend_v3_hw(struct device *device)hisi_sas_init_mem (hisi_hba); - device_state =pci_choose_state (pdev,PMSG_SUSPEND ); -dev_warn (dev,"entering operating state [D%d]\n" , - device_state); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_set_power_state (pdev, device_state); +dev_warn (dev,"entering suspend state\n" );hisi_sas_release_tasks (hisi_hba);
@@ -3491,15 +3485,7 @@ static int _resume_v3_hw(struct device *device)dev_warn (dev,"resuming from operating state [D%d]\n" , device_state); -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - rc =pci_enable_device (pdev); -if (rc) { -dev_err (dev,"enable device failed during resume (%d)\n" , rc); -return rc; - } -pci_set_master (pdev);scsi_unblock_requests (shost);clear_bit (HISI_SAS_REJECT_CMD_BIT , &hisi_hba->flags);
@@ -3507,7 +3493,6 @@ static int _resume_v3_hw(struct device *device) rc =hw_init_v3_hw (hisi_hba);if (rc) {scsi_remove_host (shost); -pci_disable_device (pdev);return rc; } hisi_hba->hw->phys_init (hisi_hba);
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 14/29 scsi: hisi_sas_v3_hw: Remove extra function calls for runtime pm
In reply to Vaibhav GuptaBoth runtime_suspend_v3_hw() and runtime_resume_v3_hw() do nothing else but invoke suspend_v3_hw() and resume_v3_hw() respectively. This is the case of unnecessary function calls. To use those functions for runtime pm as well, simply use UNIVERSAL_DEV_PM_OPS.
make -j$(nproc) W=1, with CONFIG_PM disabled, throws '-Wunused-function' warning for runtime_suspend_v3_hw() and runtime_resume_v3_hw(). After dropping those function definitions, the warning was thrown for suspend_v3_hw() and resume_v3_hw(). Hence, mark them as '__maybe_unused'.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +6 -17
@@ -3502,7 +3502,7 @@ static int _resume_v3_hw(struct device *device)return 0 ; } -static int suspend_v3_hw (struct device *device) +static int __maybe_unused suspend_v3_hw (struct device *device) {struct pci_dev *pdev =to_pci_dev (device);struct sas_ha_struct *sha =pci_get_drvdata (pdev);
@@ -3518,7 +3518,7 @@ static int suspend_v3_hw(struct device *device)return rc; } -static int resume_v3_hw (struct device *device) +static int __maybe_unused resume_v3_hw (struct device *device) {struct pci_dev *pdev =to_pci_dev (device);struct sas_ha_struct *sha =pci_get_drvdata (pdev);
@@ -3541,21 +3541,10 @@ static const struct pci_error_handlers hisi_sas_err_handler = { .reset_done = hisi_sas_reset_done_v3_hw, }; -static int runtime_suspend_v3_hw (struct device *dev) -{ -return suspend_v3_hw (dev); -} - -static int runtime_resume_v3_hw (struct device *dev) -{ -return resume_v3_hw (dev); -} - -static const struct dev_pm_ops hisi_sas_v3_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(suspend_v3_hw, resume_v3_hw) -SET_RUNTIME_PM_OPS (runtime_suspend_v3_hw, - runtime_resume_v3_hw,NULL ) -}; +static UNIVERSAL_DEV_PM_OPS(hisi_sas_v3_pm_ops, + suspend_v3_hw, + resume_v3_hw, + NULL);static struct pci_driver sas_v3_pci_driver = { .name =DRV_NAME ,
Signature · 1 line
2.28.0
PATCH v4 15/29 scsi: mpt3sas_scsih: Drop PCI Wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in scsih_resume(), and there is no corresponding pci_enable_wake(...., true) in scsih_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from scsih_resume().
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +0 -1
@@ -11140,7 +11140,6 @@ scsih_resume(struct pci_dev *pdev) pdev, pci_name(pdev), device_state);pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev); ioc->pdev = pdev; r =mpt3sas_base_map_resources (ioc);
Signature · 1 line
2.28.0
PATCH v4 16/29 scsi: mpt3sas_scsih: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 34 +++++++++++----------------- 1 file changed, 13 insertions(+), 21 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +13 -21
@@ -11084,20 +11084,18 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)return rv; } -#ifdef CONFIG_PM /** * scsih_suspend - power management suspend main entry point -* @pdev: PCI device struct -* @state: PM state change to (usually PCI_D3) +* @dev: Device struct * * Return: 0 success, anything else error. */ -static int -scsih_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused +scsih_suspend (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct Scsi_Host *shost;struct MPT3SAS_ADAPTER *ioc; -pci_power_t device_state;int rc; rc =_scsih_get_shost_and_ioc (pdev, &shost, &ioc);
@@ -11108,25 +11106,23 @@ scsih_suspend(struct pci_dev *pdev, pm_message_t state)flush_scheduled_work ();scsi_block_requests (shost);_scsih_nvme_shutdown (ioc); - device_state =pci_choose_state (pdev, state); -ioc_info (ioc,"pdev=0x%p, slot=%s, entering operating state [D%d]\n" , - pdev,pci_name (pdev), device_state); +ioc_info (ioc,"pdev=0x%p, slot=%s, entering operating state\n" , + pdev,pci_name (pdev)); -pci_save_state (pdev);mpt3sas_base_free_resources (ioc); -pci_set_power_state (pdev, device_state);return 0 ; }/** * scsih_resume - power management resume main entry point -* @pdev: PCI device struct +* @dev: Device struct * * Return: 0 success, anything else error. */ -static int -scsih_resume (struct pci_dev *pdev) +static int __maybe_unused +scsih_resume (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct Scsi_Host *shost;struct MPT3SAS_ADAPTER *ioc;pci_power_t device_state = pdev->current_state;
@@ -11139,8 +11135,6 @@ scsih_resume(struct pci_dev *pdev)ioc_info (ioc,"pdev=0x%p, slot=%s, previous operating state [D%d]\n" , pdev,pci_name (pdev), device_state); -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); ioc->pdev = pdev; r =mpt3sas_base_map_resources (ioc);if (r)
@@ -11151,7 +11145,6 @@ scsih_resume(struct pci_dev *pdev)mpt3sas_base_start_watchdog (ioc);return 0 ; } -#endif /* CONFIG_PM */ /** * scsih_pci_error_detected - Called when a PCI error is detected.
@@ -11453,6 +11446,8 @@ static struct pci_error_handlers _mpt3sas_err_handler = { .resume = scsih_pci_resume, }; +static SIMPLE_DEV_PM_OPS(scsih_pm_ops, scsih_suspend, scsih_resume); +static struct pci_driver mpt3sas_driver = { .name =MPT3SAS_DRIVER_NAME , .id_table = mpt3sas_pci_table,
@@ -11460,10 +11455,7 @@ static struct pci_driver mpt3sas_driver = { .remove = scsih_remove, .shutdown = scsih_shutdown, .err_handler = &_mpt3sas_err_handler, -#ifdef CONFIG_PM - .suspend = scsih_suspend, - .resume = scsih_resume, -#endif + .driver.pm = &scsih_pm_ops, };/**
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 17/29 scsi: lpfc: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/lpfc/lpfc_init.c | 100 +++++++++++----------------------- 1 file changed, 33 insertions(+), 67 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +33 -67
@@ -12581,8 +12581,7 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev)/** * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt -* @pdev: pointer to PCI device -* @msg: power management message +* @dev_d: pointer to device * * This routine is to be called from the kernel's PCI subsystem to support * system Power Management (PM) to device with SLI-3 interface spec. When
@@ -12600,10 +12599,10 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev)* 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_suspend_one_s3 (struct pci_dev *pdev,pm_message_t msg) +static int __maybe_unused +lpfc_pci_suspend_one_s3 (struct device *dev_d) { -struct Scsi_Host *shost =pci_get_drvdata (pdev); +struct Scsi_Host *shost =dev_get_drvdata (dev_d);struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
@@ -12617,16 +12616,12 @@ lpfc_pci_suspend_one_s3(struct pci_dev *pdev, pm_message_t msg)/* Disable interrupt from device */ lpfc_sli_disable_intr (phba); -/* Save device state to PCI config space */ -pci_save_state (pdev); -pci_set_power_state (pdev, PCI_D3hot); -return 0 ; }/** * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt -* @pdev: pointer to PCI device +* @dev_d: pointer to device * * This routine is to be called from the kernel's PCI subsystem to support * system Power Management (PM) to device with SLI-3 interface spec. When PM
@@ -12643,10 +12638,10 @@ lpfc_pci_suspend_one_s3(struct pci_dev *pdev, pm_message_t msg)* 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_resume_one_s3 (struct pci_dev *pdev) +static int __maybe_unused +lpfc_pci_resume_one_s3 (struct device *dev_d) { -struct Scsi_Host *shost =pci_get_drvdata (pdev); +struct Scsi_Host *shost =dev_get_drvdata (dev_d);struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;uint32_t intr_mode;int error;
@@ -12654,19 +12649,6 @@ lpfc_pci_resume_one_s3(struct pci_dev *pdev)lpfc_printf_log (phba,KERN_INFO ,LOG_INIT ,"0452 PCI device Power Management resume.\n" ); -/* Restore device state from PCI config space */ -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - -/* -* As the new kernel behavior of pci_restore_state() API call clears -* device saved_state flag, need to save the restored state again. -*/ -pci_save_state (pdev); - -if (pdev->is_busmaster) -pci_set_master (pdev); -/* Startup the kernel thread for this host adapter. */ phba->worker_thread =kthread_run (lpfc_do_work, phba,"lpfc_worker_%d" , phba->brd_no);
@@ -13423,8 +13405,7 @@ lpfc_pci_remove_one_s4(struct pci_dev *pdev)/** * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt -* @pdev: pointer to PCI device -* @msg: power management message +* @dev_d: pointer to device * * This routine is called from the kernel's PCI subsystem to support system * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
@@ -13442,10 +13423,10 @@ lpfc_pci_remove_one_s4(struct pci_dev *pdev)* 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_suspend_one_s4 (struct pci_dev *pdev,pm_message_t msg) +static int __maybe_unused +lpfc_pci_suspend_one_s4 (struct device *dev_d) { -struct Scsi_Host *shost =pci_get_drvdata (pdev); +struct Scsi_Host *shost =dev_get_drvdata (dev_d);struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
@@ -13460,16 +13441,12 @@ lpfc_pci_suspend_one_s4(struct pci_dev *pdev, pm_message_t msg)lpfc_sli4_disable_intr (phba);lpfc_sli4_queue_destroy (phba); -/* Save device state to PCI config space */ -pci_save_state (pdev); -pci_set_power_state (pdev, PCI_D3hot); -return 0 ; }/** * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt -* @pdev: pointer to PCI device +* @dev_d: pointer to device * * This routine is called from the kernel's PCI subsystem to support system * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
@@ -13486,10 +13463,10 @@ lpfc_pci_suspend_one_s4(struct pci_dev *pdev, pm_message_t msg)* 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_resume_one_s4 (struct pci_dev *pdev) +static int __maybe_unused +lpfc_pci_resume_one_s4 (struct device *dev_d) { -struct Scsi_Host *shost =pci_get_drvdata (pdev); +struct Scsi_Host *shost =dev_get_drvdata (dev_d);struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;uint32_t intr_mode;int error;
@@ -13497,19 +13474,6 @@ lpfc_pci_resume_one_s4(struct pci_dev *pdev)lpfc_printf_log (phba,KERN_INFO ,LOG_INIT ,"0292 PCI device Power Management resume.\n" ); -/* Restore device state from PCI config space */ -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - -/* -* As the new kernel behavior of pci_restore_state() API call clears -* device saved_state flag, need to save the restored state again. -*/ -pci_save_state (pdev); - -if (pdev->is_busmaster) -pci_set_master (pdev); -/* Startup the kernel thread for this host adapter. */ phba->worker_thread =kthread_run (lpfc_do_work, phba,"lpfc_worker_%d" , phba->brd_no);
@@ -13825,8 +13789,7 @@ lpfc_pci_remove_one(struct pci_dev *pdev)/** * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management -* @pdev: pointer to PCI device -* @msg: power management message +* @dev: pointer to device * * This routine is to be registered to the kernel's PCI subsystem to support * system Power Management (PM). When PM invokes this method, it dispatches
@@ -13837,19 +13800,19 @@ lpfc_pci_remove_one(struct pci_dev *pdev)* 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_suspend_one (struct pci_dev *pdev,pm_message_t msg) +static int __maybe_unused +lpfc_pci_suspend_one (struct device *dev) { -struct Scsi_Host *shost =pci_get_drvdata (pdev); +struct Scsi_Host *shost =dev_get_drvdata (dev);struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;int rc = -ENODEV ;switch (phba->pci_dev_grp) {case LPFC_PCI_DEV_LP : - rc =lpfc_pci_suspend_one_s3 (pdev, msg); + rc =lpfc_pci_suspend_one_s3 (dev);break ;case LPFC_PCI_DEV_OC : - rc =lpfc_pci_suspend_one_s4 (pdev, msg); + rc =lpfc_pci_suspend_one_s4 (dev);break ;default : lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
@@ -13862,7 +13825,7 @@ lpfc_pci_suspend_one(struct pci_dev *pdev, pm_message_t msg)/** * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management -* @pdev: pointer to PCI device +* @dev: pointer to device * * This routine is to be registered to the kernel's PCI subsystem to support * system Power Management (PM). When PM invokes this method, it dispatches
@@ -13873,19 +13836,19 @@ lpfc_pci_suspend_one(struct pci_dev *pdev, pm_message_t msg)* 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_resume_one (struct pci_dev *pdev) +static int __maybe_unused +lpfc_pci_resume_one (struct device *dev) { -struct Scsi_Host *shost =pci_get_drvdata (pdev); +struct Scsi_Host *shost =dev_get_drvdata (dev);struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;int rc = -ENODEV ;switch (phba->pci_dev_grp) {case LPFC_PCI_DEV_LP : - rc =lpfc_pci_resume_one_s3 (pdev); + rc =lpfc_pci_resume_one_s3 (dev);break ;case LPFC_PCI_DEV_OC : - rc =lpfc_pci_resume_one_s4 (pdev); + rc =lpfc_pci_resume_one_s4 (dev);break ;default : lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
@@ -14065,14 +14028,17 @@ static const struct pci_error_handlers lpfc_err_handler = { .resume = lpfc_io_resume, }; +static SIMPLE_DEV_PM_OPS(lpfc_pci_pm_ops_one, + lpfc_pci_suspend_one, + lpfc_pci_resume_one); +static struct pci_driver lpfc_driver = { .name =LPFC_DRIVER_NAME , .id_table = lpfc_id_table, .probe = lpfc_pci_probe_one, .remove = lpfc_pci_remove_one, .shutdown = lpfc_pci_remove_one, - .suspend = lpfc_pci_suspend_one, - .resume = lpfc_pci_resume_one, + .driver.pm = &lpfc_pci_pm_ops_one, .err_handler = &lpfc_err_handler, };
Signature · 1 line
2.28.0
PATCH v4 18/29 scsi: pm_8001: Drop PCI Wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in pm8001_pci_resume(), and there is no corresponding pci_enable_wake(...., true) in pm8001_pci_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from pm8001_pci__resume().
--- drivers/scsi/pm8001/pm8001_init.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/pm8001/pm8001_init.c +0 -1
@@ -1327,7 +1327,6 @@ static int pm8001_pci_resume(struct pci_dev *pdev) "operating state [D%d]\n", pdev, pm8001_ha->name, device_state);pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev); rc =pci_enable_device (pdev);if (rc) {
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 19/29 scsi: pm_8001: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/pm8001/pm8001_init.c | 45 +++++++++++-------------------- 1 file changed, 16 insertions(+), 29 deletions(-)
drivers/scsi/pm8001/pm8001_init.c +16 -29
@@ -1257,23 +1257,21 @@ static void pm8001_pci_remove(struct pci_dev *pdev)/** * pm8001_pci_suspend - power management suspend main entry point -* @pdev: PCI device struct -* @state: PM state change to (usually PCI_D3) +* @dev: Device struct * * Returns 0 success, anything else error. */ -static int pm8001_pci_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused pm8001_pci_suspend (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct sas_ha_struct *sha =pci_get_drvdata (pdev); -struct pm8001_hba_info *pm8001_ha; +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;int i, j; -u32 device_state; - pm8001_ha = sha->lldd_ha;sas_suspend_ha (sha);flush_workqueue (pm8001_wq);scsi_block_requests (pm8001_ha->shost);if (!pdev->pm_cap) { -dev_err (&pdev->dev," PCI PM not supported\n" ); +dev_err (dev," PCI PM not supported\n" );return -ENODEV ; }PM8001_CHIP_DISP ->interrupt_disable (pm8001_ha,0xFF );
@@ -1296,24 +1294,21 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)for (j =0 ; j <PM8001_MAX_MSIX_VEC ; j++)tasklet_kill (&pm8001_ha->tasklet[j]);#endif - device_state =pci_choose_state (pdev, state);pm8001_printk ("pdev=0x%p, slot=%s, entering " -"operating state [D%d]\n" , pdev, - pm8001_ha->name, device_state); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_set_power_state (pdev, device_state); +"suspended state\n" , pdev, + pm8001_ha->name);return 0 ; }/** * pm8001_pci_resume - power management resume main entry point -* @pdev: PCI device struct +* @dev: Device struct * * Returns 0 success, anything else error. */ -static int pm8001_pci_resume (struct pci_dev *pdev) +static int __maybe_unused pm8001_pci_resume (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct sas_ha_struct *sha =pci_get_drvdata (pdev);struct pm8001_hba_info *pm8001_ha;int rc;
@@ -1326,16 +1321,6 @@ static int pm8001_pci_resume(struct pci_dev *pdev)pm8001_printk ("pdev=0x%p, slot=%s, resuming from previous " "operating state [D%d]\n" , pdev, pm8001_ha->name, device_state); -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - rc =pci_enable_device (pdev); -if (rc) { -pm8001_printk ("slot=%s Enable device failed during resume\n" , - pm8001_ha->name); - goto err_out_enable; - } - -pci_set_master (pdev); rc =pci_go_44 (pdev);if (rc) goto err_out_disable;
@@ -1396,8 +1381,7 @@ static int pm8001_pci_resume(struct pci_dev *pdev) err_out_disable:scsi_remove_host (pm8001_ha->shost); -pci_disable_device (pdev); -err_out_enable: +return rc; }
@@ -1480,13 +1464,16 @@ static struct pci_device_id pm8001_pci_table[] = { {}/* terminate list */ }; +static SIMPLE_DEV_PM_OPS(pm8001_pci_pm_ops, + pm8001_pci_suspend, + pm8001_pci_resume); +static struct pci_driver pm8001_pci_driver = { .name =DRV_NAME , .id_table = pm8001_pci_table, .probe = pm8001_pci_probe, .remove = pm8001_pci_remove, - .suspend = pm8001_pci_suspend, - .resume = pm8001_pci_resume, + .driver.pm = &pm8001_pci_pm_ops, };/**
Signature · 1 line
2.28.0
PATCH v4 20/29 scsi: hpsa: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/hpsa.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/scsi/hpsa.c +7 -5
@@ -9090,25 +9090,27 @@ static void hpsa_remove_one(struct pci_dev *pdev)hpda_free_ctlr_info (h);/* init_one 1 */ } -static int hpsa_suspend (__attribute__((unused))struct pci_dev *pdev, - __attribute__((unused))pm_message_t state) +static int __maybe_unused hpsa_suspend ( + __attribute__((unused))struct device *dev) {return -ENOSYS ; } -static int hpsa_resume (__attribute__((unused))struct pci_dev *pdev) +static int __maybe_unused hpsa_resume + (__attribute__((unused))struct device *dev) {return -ENOSYS ; } +static SIMPLE_DEV_PM_OPS(hpsa_pm_ops, hpsa_suspend, hpsa_resume); +static struct pci_driver hpsa_pci_driver = { .name =HPSA , .probe = hpsa_init_one, .remove = hpsa_remove_one, .id_table = hpsa_pci_device_id,/* id_table */ .shutdown = hpsa_shutdown, - .suspend = hpsa_suspend, - .resume = hpsa_resume, + .driver.pm = &hpsa_pm_ops, };/* Fill in bucket_map[], given nsgs (the max number of
Signature · 1 line
2.28.0
RE: [PATCH v4 20/29] scsi: hpsa: use generic power management
-----Original Message-----
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
I thought that I had given my Acked-by on 10/27, but it must have been lost.
Thanks for your attention to hpsa,
Don
--- drivers/scsi/hpsa.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/scsi/hpsa.c +7 -5
@@ -9090,25 +9090,27 @@ static void hpsa_remove_one(struct pci_dev *pdev)hpda_free_ctlr_info (h);/* init_one 1 */ } -static int hpsa_suspend (__attribute__((unused))struct pci_dev *pdev, - __attribute__((unused))pm_message_t state) +static int __maybe_unused hpsa_suspend ( + __attribute__((unused))struct device *dev) {return -ENOSYS ; } -static int hpsa_resume (__attribute__((unused))struct pci_dev *pdev) +static int __maybe_unused hpsa_resume + (__attribute__((unused))struct device *dev) {return -ENOSYS ; } +static SIMPLE_DEV_PM_OPS(hpsa_pm_ops, hpsa_suspend, hpsa_resume); +static struct pci_driver hpsa_pci_driver = { .name =HPSA , .probe = hpsa_init_one, .remove = hpsa_remove_one, .id_table = hpsa_pci_device_id,/* id_table */ .shutdown = hpsa_shutdown, - .suspend = hpsa_suspend, - .resume = hpsa_resume, + .driver.pm = &hpsa_pm_ops, };/* Fill in bucket_map[], given nsgs (the max number of
--
2.28.0
PATCH v4 21/29 scsi: 3w-9xxx: Drop PCI Wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in twa_resume(), and there is no corresponding pci_enable_wake(...., true) in twa_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from twa_resume().
--- drivers/scsi/3w-9xxx.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/3w-9xxx.c +0 -1
@@ -2230,7 +2230,6 @@ static int twa_resume(struct pci_dev *pdev)printk (KERN_WARNING "3w-9xxx: Resuming host %d.\n" , tw_dev->host->host_no);pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev); retval =pci_enable_device (pdev);
Signature · 1 line
2.28.0
PATCH v4 22/29 scsi: 3w-9xxx: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/3w-9xxx.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-)
drivers/scsi/3w-9xxx.c +7 -22
@@ -2191,10 +2191,10 @@ static void twa_remove(struct pci_dev *pdev) twa_device_extension_count--; }/* End twa_remove() */ -#ifdef CONFIG_PM /* This function is called on PCI suspend */ -static int twa_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused twa_suspend (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct Scsi_Host *host =pci_get_drvdata (pdev);TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
@@ -2214,31 +2214,19 @@ static int twa_suspend(struct pci_dev *pdev, pm_message_t state) }TW_CLEAR_ALL_INTERRUPTS (tw_dev); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_set_power_state (pdev,pci_choose_state (pdev, state)); -return 0 ; }/* End twa_suspend() */ /* This function is called on PCI resume */ -static int twa_resume (struct pci_dev *pdev) +static int __maybe_unused twa_resume (struct device *dev) {int retval =0 ; +struct pci_dev *pdev =to_pci_dev (dev);struct Scsi_Host *host =pci_get_drvdata (pdev);TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;printk (KERN_WARNING "3w-9xxx: Resuming host %d.\n" , tw_dev->host->host_no); -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - retval =pci_enable_device (pdev); -if (retval) { -TW_PRINTK (tw_dev->host,TW_DRIVER ,0x39 ,"Enable device failed during resume" ); -return retval; - } - -pci_set_master (pdev);pci_try_set_mwi (pdev); retval =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));
@@ -2276,11 +2264,9 @@ static int twa_resume(struct pci_dev *pdev) out_disable_device:scsi_remove_host (host); -pci_disable_device (pdev);return retval; }/* End twa_resume() */ -#endif /* PCI Devices supported by this driver */ static struct pci_device_id twa_pci_tbl[] = {
@@ -2296,16 +2282,15 @@ static struct pci_device_id twa_pci_tbl[] = { };MODULE_DEVICE_TABLE (pci, twa_pci_tbl); +static SIMPLE_DEV_PM_OPS(twa_pm_ops, twa_suspend, twa_resume); +/* pci_driver initializer */ static struct pci_driver twa_driver = { .name ="3w-9xxx" , .id_table = twa_pci_tbl, .probe = twa_probe, .remove = twa_remove, -#ifdef CONFIG_PM - .suspend = twa_suspend, - .resume = twa_resume, -#endif + .driver.pm = &twa_pm_ops, .shutdown = twa_shutdown };
Signature · 1 line
2.28.0
PATCH v4 23/29 scsi: 3w-sas: Drop PCI Wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in twl_resume(), and there is no corresponding pci_enable_wake(...., true) in twl_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from twl_resume().
--- drivers/scsi/3w-sas.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/3w-sas.c +0 -1
@@ -1795,7 +1795,6 @@ static int twl_resume(struct pci_dev *pdev)printk (KERN_WARNING "3w-sas: Resuming host %d.\n" , tw_dev->host->host_no);pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev); retval =pci_enable_device (pdev);
Signature · 1 line
2.28.0
PATCH v4 24/29 scsi: 3w-sas: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/3w-sas.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)
drivers/scsi/3w-sas.c +7 -24
@@ -1756,11 +1756,10 @@ static void twl_remove(struct pci_dev *pdev) twl_device_extension_count--; }/* End twl_remove() */ -#ifdef CONFIG_PM /* This function is called on PCI suspend */ -static int twl_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused twl_suspend (struct device *dev) { -struct Scsi_Host *host =pci_get_drvdata (pdev); +struct Scsi_Host *host =dev_get_drvdata (dev);TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;printk (KERN_WARNING "3w-sas: Suspending host %d.\n" , tw_dev->host->host_no);
@@ -1779,31 +1778,18 @@ static int twl_suspend(struct pci_dev *pdev, pm_message_t state)/* Clear doorbell interrupt */ TWL_CLEAR_DB_INTERRUPT (tw_dev); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_set_power_state (pdev,pci_choose_state (pdev, state)); -return 0 ; }/* End twl_suspend() */ /* This function is called on PCI resume */ -static int twl_resume (struct pci_dev *pdev) +static int __maybe_unused twl_resume (struct device *dev) {int retval =0 ; +struct pci_dev *pdev =to_pci_dev (dev);struct Scsi_Host *host =pci_get_drvdata (pdev);TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;printk (KERN_WARNING "3w-sas: Resuming host %d.\n" , tw_dev->host->host_no); -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - - retval =pci_enable_device (pdev); -if (retval) { -TW_PRINTK (tw_dev->host,TW_DRIVER ,0x24 ,"Enable device failed during resume" ); -return retval; - } - -pci_set_master (pdev);pci_try_set_mwi (pdev); retval =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));
@@ -1841,11 +1827,9 @@ static int twl_resume(struct pci_dev *pdev) out_disable_device:scsi_remove_host (host); -pci_disable_device (pdev);return retval; }/* End twl_resume() */ -#endif /* PCI Devices supported by this driver */ static struct pci_device_id twl_pci_tbl[] = {
@@ -1854,16 +1838,15 @@ static struct pci_device_id twl_pci_tbl[] = { };MODULE_DEVICE_TABLE (pci, twl_pci_tbl); +static SIMPLE_DEV_PM_OPS(twl_pm_ops, twl_suspend, twl_resume); +/* pci_driver initializer */ static struct pci_driver twl_driver = { .name ="3w-sas" , .id_table = twl_pci_tbl, .probe = twl_probe, .remove = twl_remove, -#ifdef CONFIG_PM - .suspend = twl_suspend, - .resume = twl_resume, -#endif + .driver.pm = &twl_pm_ops, .shutdown = twl_shutdown };
Signature · 1 line
2.28.0
PATCH v4 25/29 scsi: mvumi: Drop PCI Wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in mvumi_resume(), and there is no corresponding pci_enable_wake(...., true) in mvumi_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from mvumi_resume().
--- drivers/scsi/mvumi.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/mvumi.c +0 -1
@@ -2595,7 +2595,6 @@ static int __maybe_unused mvumi_resume(struct pci_dev *pdev) mhba =pci_get_drvdata (pdev);pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev); ret =pci_enable_device (pdev);
Signature · 1 line
2.28.0
PATCH v4 26/29 scsi: mvumi: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/mvumi.c | 46 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-)
drivers/scsi/mvumi.c +9 -37
@@ -2568,46 +2568,26 @@ static void mvumi_shutdown(struct pci_dev *pdev)mvumi_flush_cache (mhba); } -static int __maybe_unused mvumi_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused mvumi_suspend (struct device *dev) { -struct mvumi_hba *mhba =NULL ; +struct pci_dev *pdev =to_pci_dev (dev); +struct mvumi_hba *mhba =pci_get_drvdata (pdev); - mhba =pci_get_drvdata (pdev);mvumi_flush_cache (mhba); -pci_set_drvdata (pdev, mhba); mhba->instancet->disable_intr (mhba); -free_irq (mhba->pdev->irq, mhba);mvumi_unmap_pci_addr (pdev, mhba->base_addr); -pci_release_regions (pdev); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_set_power_state (pdev,pci_choose_state (pdev, state));return 0 ; } -static int __maybe_unused mvumi_resume (struct pci_dev *pdev) +static int __maybe_unused mvumi_resume (struct device *dev) {int ret; -struct mvumi_hba *mhba =NULL ; - - mhba =pci_get_drvdata (pdev); - -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - - ret =pci_enable_device (pdev); -if (ret) { -dev_err (&pdev->dev,"enable device failed\n" ); -return ret; - } +struct pci_dev *pdev =to_pci_dev (dev); +struct mvumi_hba *mhba =pci_get_drvdata (pdev); - ret =mvumi_pci_set_master (pdev); ret =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (ret) - goto fail; - ret =pci_request_regions (mhba->pdev,MV_DRIVER_NAME );if (ret) goto fail; ret =mvumi_map_pci_addr (mhba->pdev, mhba->base_addr);
@@ -2627,12 +2607,6 @@ static int __maybe_unused mvumi_resume(struct pci_dev *pdev) goto unmap_pci_addr; } - ret =request_irq (mhba->pdev->irq, mvumi_isr_handler,IRQF_SHARED , -"mvumi" , mhba); -if (ret) { -dev_err (&pdev->dev,"failed to register IRQ\n" ); - goto unmap_pci_addr; - } mhba->instancet->enable_intr (mhba);return 0 ;
@@ -2642,11 +2616,12 @@ static int __maybe_unused mvumi_resume(struct pci_dev *pdev) release_regions:pci_release_regions (pdev); fail: -pci_disable_device (pdev);return ret; } +static SIMPLE_DEV_PM_OPS(mvumi_pm_ops, mvumi_suspend, mvumi_resume); +static struct pci_driver mvumi_pci_driver = { .name =MV_DRIVER_NAME ,
@@ -2654,10 +2629,7 @@ static struct pci_driver mvumi_pci_driver = { .probe = mvumi_probe_one, .remove = mvumi_detach_one, .shutdown = mvumi_shutdown, -#ifdef CONFIG_PM - .suspend = mvumi_suspend, - .resume = mvumi_resume, -#endif + .driver.pm = &mvumi_pm_ops, };module_pci_driver (mvumi_pci_driver);
Signature · 1 line
2.28.0
PATCH v4 27/29 scsi: mvumi: update function description
In reply to Vaibhav GuptaThere is no "device" parameter in mvumi_shutdown(). Instead there is "pdev" which is not described.
--- drivers/scsi/mvumi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/mvumi.c +1 -1
@@ -2559,7 +2559,7 @@ static void mvumi_detach_one(struct pci_dev *pdev)/** * mvumi_shutdown - Shutdown entry point -* @device: Generic device structure +* @pdev: PCI device structure */ static void mvumi_shutdown (struct pci_dev *pdev) {
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 28/29 scsi: pmcraid: Drop PCI Wakeup calls from .resume
In reply to Vaibhav GuptaThe driver calls pci_enable_wake(...., false) in pmcraid_resume(), and there is no corresponding pci_enable_wake(...., true) in pmcraid_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all.
Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from pmcraid_resume().
--- drivers/scsi/pmcraid.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/pmcraid.c +0 -1
@@ -5271,7 +5271,6 @@ static int pmcraid_resume(struct pci_dev *pdev)int rc;pci_set_power_state (pdev,PCI_D0 ); -pci_enable_wake (pdev,PCI_D0 ,0 );pci_restore_state (pdev); rc =pci_enable_device (pdev);
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v4 29/29 scsi: pmcraid: use generic power management
In reply to Vaibhav GuptaDrivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them.
Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings.
--- drivers/scsi/pmcraid.c | 43 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-)
drivers/scsi/pmcraid.c +10 -33
@@ -5234,53 +5234,37 @@ static void pmcraid_remove(struct pci_dev *pdev)return ; } -#ifdef CONFIG_PM /** * pmcraid_suspend - driver suspend entry point for power management -* @pdev: PCI device structure -* @state: PCI power state to suspend routine +* @dev: Device structure * * Return Value - 0 always */ -static int pmcraid_suspend (struct pci_dev *pdev,pm_message_t state) +static int __maybe_unused pmcraid_suspend (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct pmcraid_instance *pinstance =pci_get_drvdata (pdev);pmcraid_shutdown (pdev);pmcraid_disable_interrupts (pinstance, ~0 );pmcraid_kill_tasklets (pinstance); -pci_set_drvdata (pinstance->pdev, pinstance);pmcraid_unregister_interrupt_handler (pinstance); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_set_power_state (pdev,pci_choose_state (pdev, state));return 0 ; }/** * pmcraid_resume - driver resume entry point PCI power management -* @pdev: PCI device structure +* @dev: Device structure * * Return Value - 0 in case of success. Error code in case of any failure */ -static int pmcraid_resume (struct pci_dev *pdev) +static int __maybe_unused pmcraid_resume (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev);struct pmcraid_instance *pinstance =pci_get_drvdata (pdev);struct Scsi_Host *host = pinstance->host; -int rc; - -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - - rc =pci_enable_device (pdev); - -if (rc) { -dev_err (&pdev->dev,"resume: Enable device failed\n" ); -return rc; - } - -pci_set_master (pdev); +int rc =0 ;if (sizeof (dma_addr_t) ==4 ||dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )))
@@ -5333,18 +5317,10 @@ static int pmcraid_resume(struct pci_dev *pdev)scsi_host_put (host); disable_device: -pci_disable_device (pdev);return rc; } -#else - -#define pmcraid_suspend NULL -#define pmcraid_resume NULL - -#endif /* CONFIG_PM */ -/** * pmcraid_complete_ioa_reset - Called by either timer or tasklet during * completion of the ioa reset
@@ -5832,6 +5808,8 @@ static int pmcraid_probe(struct pci_dev *pdev,return -ENODEV ; } +static SIMPLE_DEV_PM_OPS(pmcraid_pm_ops, pmcraid_suspend, pmcraid_resume); +/* * PCI driver structure of pmcraid driver */
@@ -5840,8 +5818,7 @@ static struct pci_driver pmcraid_driver = { .id_table = pmcraid_pci_table, .probe = pmcraid_probe, .remove = pmcraid_remove, - .suspend = pmcraid_suspend, - .resume = pmcraid_resume, + .driver.pm = &pmcraid_pm_ops, .shutdown = pmcraid_shutdown };
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Martin K. Petersen
AppliedQuoted 9 lines · Vaibhav Gupta
Linux Kernel Mentee: Remove Legacy Power Management.
The purpose of this patch series is to upgrade power management in xxxxxxxx drivers. This has been done by upgrading .suspend() and .resume() callbacks.
The upgrade makes sure that the involvement of PCI Core does not change the order of operations executed in a driver. Thus, does not change its behavior.
[...]
Applied to 5.11/scsi-queue, thanks!
[01/29] scsi: megaraid_sas: Drop PCI wakeup calls from .resume
https://git.kernel.org/mkp/scsi/c/8ed9d987c6d9 [02/29] scsi: megaraid_sas: Use generic power management https://git.kernel.org/mkp/scsi/c/977001df0368 [03/29] scsi: megaraid_sas: Update function description https://git.kernel.org/mkp/scsi/c/498854102c1c [04/29] scsi: aacraid: Drop pci_enable_wake() from .resume https://git.kernel.org/mkp/scsi/c/7dd222218076 [05/29] scsi: aacraid: Use generic power management https://git.kernel.org/mkp/scsi/c/7e380b5c27ea [06/29] scsi: aic7xxx: Use generic power management https://git.kernel.org/mkp/scsi/c/6897b9a177df [07/29] scsi: aic79xx: Use generic power management https://git.kernel.org/mkp/scsi/c/ec199a8df698 [08/29] scsi: arcmsr: Drop PCI wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/b7b862d75b49 [09/29] scsi: arcmsr: Use generic power management https://git.kernel.org/mkp/scsi/c/756ebbe73fc4 [10/29] scsi: esas2r: Drop PCI Wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/996360c141a6 [11/29] scsi: esas2r: Use generic power management https://git.kernel.org/mkp/scsi/c/5f2d8c365050 [12/29] scsi: hisi_sas_v3_hw: Drop PCI Wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/17b5e4d14837 [13/29] scsi: hisi_sas_v3_hw: Don't use PCI helper functions https://git.kernel.org/mkp/scsi/c/027e508aea45 [14/29] scsi: hisi_sas_v3_hw: Remove extra function calls for runtime pm https://git.kernel.org/mkp/scsi/c/71c8f15e1dbc [15/29] scsi: mpt3sas_scsih: Drop PCI Wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/eaf148359d00 [16/29] scsi: mpt3sas_scsih: Use generic power management https://git.kernel.org/mkp/scsi/c/17287305a526 [17/29] scsi: lpfc: Use generic power management https://git.kernel.org/mkp/scsi/c/ef6fa16b5d4a [18/29] scsi: pm_8001: Drop PCI Wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/66aea31a2d26 [19/29] scsi: pm_8001: Use generic power management https://git.kernel.org/mkp/scsi/c/47c37c4dbf93 [20/29] scsi: hpsa: Use generic power management https://git.kernel.org/mkp/scsi/c/e5b79ebfb854 [21/29] scsi: 3w-9xxx: Drop PCI Wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/3a09951ae366 [22/29] scsi: 3w-9xxx: Use generic power management https://git.kernel.org/mkp/scsi/c/d53ae6bbeb71 [23/29] scsi: 3w-sas: Drop PCI Wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/7ea03ab79e00 [24/29] scsi: 3w-sas: Use generic power management https://git.kernel.org/mkp/scsi/c/99769d8d9109 [25/29] scsi: mvumi: Drop PCI Wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/bd7463cdbe1a [26/29] scsi: mvumi: Use generic power management https://git.kernel.org/mkp/scsi/c/0572edbc32c5 [27/29] scsi: mvumi: Update function description https://git.kernel.org/mkp/scsi/c/53fdec73c14f [28/29] scsi: pmcraid: Drop PCI Wakeup calls from .resume https://git.kernel.org/mkp/scsi/c/0aea8a8f3a77 [29/29] scsi: pmcraid: Use generic power management https://git.kernel.org/mkp/scsi/c/ac85cca31637
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering