misc: rtsx: modify rtd3 flow
PATCH 1/1 misc: rtsx: modify rtd3 flow
move pm_runtime_get() to _runtime_resume
when System enter S3, do not have sd_request and do not call start_run to pm_runtime_get() cause is_runtime_suspended status not correct
set more register in power_down flow to make plugin or unplug card do not wake up system when system is at S3
--- drivers/misc/cardreader/rts5249.c | 31 ++++++++++++++++++++++++++++-- drivers/misc/cardreader/rtsx_pcr.c | 17 ++++++++-------- drivers/misc/cardreader/rtsx_pcr.h | 1 + 3 files changed, 38 insertions(+), 11 deletions(-)
drivers/misc/cardreader/rts5249.c +29 -2
@@ -74,7 +74,8 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr)pci_read_config_dword (pdev,PCR_SETTING_REG2 , ®);pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); - pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg); +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) + pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg);if (rtsx_check_mmc_support (reg)) pcr->extra_caps |=EXTRA_CAPS_NO_MMC ;
@@ -143,6 +144,27 @@ static int rts5249_init_from_hw(struct rtsx_pcr *pcr)return 0 ; } +static void rts52xa_force_power_down (struct rtsx_pcr *pcr,u8 pm_state) +{ +/* Set relink_time to 0 */ +rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +1 ,MASK_8_BIT_DEF ,0 ); +rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +2 ,MASK_8_BIT_DEF ,0 ); +rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +3 , +RELINK_TIME_MASK ,0 ); + +rtsx_pci_write_register (pcr,RTS524A_PM_CTRL3 , +D3_DELINK_MODE_EN ,D3_DELINK_MODE_EN ); + +if (!pcr->is_runtime_suspended) { +rtsx_pci_write_register (pcr,RTS524A_AUTOLOAD_CFG1 , +CD_RESUME_EN_MASK ,0 ); +rtsx_pci_write_register (pcr,RTS524A_PM_CTRL3 ,0x01 ,0x00 ); +rtsx_pci_write_register (pcr,RTS524A_PME_FORCE_CTL ,0x30 ,0x20 ); + } + +rtsx_pci_write_register (pcr,FPDCTL ,ALL_POWER_DOWN ,ALL_POWER_DOWN ); +} +static void rts52xa_save_content_from_efuse (struct rtsx_pcr *pcr) {u8 cnt, sv;
@@ -281,8 +303,11 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)rtsx_pci_send_cmd (pcr,CMD_TIMEOUT_DEF ); -if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) {rtsx_pci_write_register (pcr,REG_VREF ,PWD_SUSPND_EN ,PWD_SUSPND_EN ); +rtsx_pci_write_register (pcr,RTS524A_AUTOLOAD_CFG1 , +CD_RESUME_EN_MASK ,CD_RESUME_EN_MASK ); + }if (pcr->rtd3_en) {if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) {
@@ -724,6 +749,7 @@ static const struct pcr_ops rts524a_pcr_ops = { .card_power_on = rtsx_base_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rtsx_base_switch_output_voltage, + .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };
@@ -841,6 +867,7 @@ static const struct pcr_ops rts525a_pcr_ops = { .card_power_on = rts525a_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rts525a_switch_output_voltage, + .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };
drivers/misc/cardreader/rtsx_pcr.c +8 -9
@@ -152,12 +152,6 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr)if (pcr->remove_pci)return ; -if (pcr->rtd3_en) -if (pcr->is_runtime_suspended) { -pm_runtime_get (&(pcr->pci->dev)); - pcr->is_runtime_suspended = false; - } -if (pcr->state !=PDEV_STAT_RUN ) { pcr->state =PDEV_STAT_RUN ;if (pcr->ops->enable_auto_blink)
@@ -1597,6 +1591,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr +HOST_CMDS_BUF_LEN ; pcr->card_inserted =0 ; pcr->card_removed =0 ; + pcr->rtd3_en =0 ;INIT_DELAYED_WORK (&pcr->carddet_work, rtsx_pci_card_detect);INIT_DELAYED_WORK (&pcr->idle_work, rtsx_pci_idle_work);
@@ -1796,17 +1791,16 @@ static int rtsx_pci_runtime_suspend(struct device *device) pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__); + pcr->is_runtime_suspended = true; +cancel_delayed_work (&pcr->carddet_work);cancel_delayed_work (&pcr->rtd3_work);cancel_delayed_work (&pcr->idle_work);mutex_lock (&pcr->pcr_mutex);rtsx_pci_power_off (pcr,HOST_ENTER_S3 ); -mutex_unlock (&pcr->pcr_mutex); - pcr->is_runtime_suspended = true; -return 0 ; }
@@ -1820,6 +1814,11 @@ static int rtsx_pci_runtime_resume(struct device *device) pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__); +if (pcr->is_runtime_suspended) { +pm_runtime_get (&(pcr->pci->dev)); + pcr->is_runtime_suspended = false; + } +mutex_lock (&pcr->pcr_mutex);rtsx_pci_write_register (pcr,HOST_SLEEP_STATE ,0x03 ,0x00 );
drivers/misc/cardreader/rtsx_pcr.h +1 -0
@@ -25,6 +25,7 @@#define REG_EFUSE_POWEROFF 0x00#define RTS5250_CLK_CFG3 0xFF79#define RTS525A_CFG_MEM_PD 0xF0 +#define RTS524A_AUTOLOAD_CFG1 0xFF7C#define RTS524A_PM_CTRL3 0xFF7E#define RTS525A_BIOS_CFG 0xFF2D#define RTS525A_LOAD_BIOS_FLAG 0x01
Signature · 1 line
2.25.1
Quoted 133 lines · Ricky WU
move
pm_runtime_get()to_runtime_resume
when System enter S3, do not havesd_requestand do not callstart_runtopm_runtime_get()causeis_runtime_suspendedstatus not correctset more register in
power_downflow to make plugin or unplug card do not wake up system when system is at S3Signed-off-by Ricky Wu <[email protected]>--- drivers/misc/cardreader/rts5249.c | 31 ++++++++++++++++++++++++++++-- drivers/misc/cardreader/rtsx_pcr.c | 17 ++++++++-------- drivers/misc/cardreader/rtsx_pcr.h | 1 + 3 files changed, 38 insertions(+), 11 deletions(-)drivers/misc/cardreader/rts5249.c +29
-2@@ -74,7 +74,8 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr)pci_read_config_dword (pdev,PCR_SETTING_REG2 , ®);pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); - pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg); +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) + pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg);if (rtsx_check_mmc_support (reg)) pcr->extra_caps |=EXTRA_CAPS_NO_MMC ;@@ -143,6 +144,27 @@ static int rts5249_init_from_hw(struct rtsx_pcr *pcr)return 0 ; } +static void rts52xa_force_power_down (struct rtsx_pcr *pcr,u8 pm_state) +{ +/* Set relink_time to 0 */ +rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +1 ,MASK_8_BIT_DEF ,0 ); +rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +2 ,MASK_8_BIT_DEF ,0 ); +rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +3 , +RELINK_TIME_MASK ,0 ); + +rtsx_pci_write_register (pcr,RTS524A_PM_CTRL3 , +D3_DELINK_MODE_EN ,D3_DELINK_MODE_EN ); + +if (!pcr->is_runtime_suspended) { +rtsx_pci_write_register (pcr,RTS524A_AUTOLOAD_CFG1 , +CD_RESUME_EN_MASK ,0 ); +rtsx_pci_write_register (pcr,RTS524A_PM_CTRL3 ,0x01 ,0x00 ); +rtsx_pci_write_register (pcr,RTS524A_PME_FORCE_CTL ,0x30 ,0x20 ); + } + +rtsx_pci_write_register (pcr,FPDCTL ,ALL_POWER_DOWN ,ALL_POWER_DOWN ); +} +static void rts52xa_save_content_from_efuse (struct rtsx_pcr *pcr) {u8 cnt, sv;@@ -281,8 +303,11 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)rtsx_pci_send_cmd (pcr,CMD_TIMEOUT_DEF ); -if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) {rtsx_pci_write_register (pcr,REG_VREF ,PWD_SUSPND_EN ,PWD_SUSPND_EN ); +rtsx_pci_write_register (pcr,RTS524A_AUTOLOAD_CFG1 , +CD_RESUME_EN_MASK ,CD_RESUME_EN_MASK ); + }if (pcr->rtd3_en) {if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) {@@ -724,6 +749,7 @@ static const struct pcr_ops rts524a_pcr_ops = { .card_power_on = rtsx_base_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rtsx_base_switch_output_voltage, + .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };@@ -841,6 +867,7 @@ static const struct pcr_ops rts525a_pcr_ops = { .card_power_on = rts525a_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rts525a_switch_output_voltage, + .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };drivers/misc/cardreader/rtsx_pcr.c +3
-9@@ -152,12 +152,6 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr)if (pcr->remove_pci)return ; -if (pcr->rtd3_en) -if (pcr->is_runtime_suspended) { -pm_runtime_get (&(pcr->pci->dev)); - pcr->is_runtime_suspended = false; - } -if (pcr->state !=PDEV_STAT_RUN ) { pcr->state =PDEV_STAT_RUN ;if (pcr->ops->enable_auto_blink)@@ -1597,6 +1591,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr +HOST_CMDS_BUF_LEN ; pcr->card_inserted =0 ; pcr->card_removed =0 ; + pcr->rtd3_en =0 ;INIT_DELAYED_WORK (&pcr->carddet_work, rtsx_pci_card_detect);INIT_DELAYED_WORK (&pcr->idle_work, rtsx_pci_idle_work);@@ -1796,17 +1791,16 @@ static int rtsx_pci_runtime_suspend(struct device *device) pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__); + pcr->is_runtime_suspended = true; +cancel_delayed_work (&pcr->carddet_work);cancel_delayed_work (&pcr->rtd3_work);cancel_delayed_work (&pcr->idle_work);mutex_lock (&pcr->pcr_mutex);rtsx_pci_power_off (pcr,HOST_ENTER_S3 ); -mutex_unlock (&pcr->pcr_mutex); - pcr->is_runtime_suspended = true; -return 0 ; }
drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_runtime_resume(struct device *device) · line 1820
Quoted 7 lines
drivers/misc/cardreader/rtsx_pcr.c +4
-0@@ -1820,6 +1814,11 @@ static int rtsx_pci_runtime_resume(struct device *device) pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__); +if (pcr->is_runtime_suspended) { +pm_runtime_get (&(pcr->pci->dev)); + pcr->is_runtime_suspended = false; + }
If the runtime resume routine is called for system wide suspend, the runtime suspend isn't allowed during the period.
So I don't quite understand what this patch is for.
Kai-Heng
Quoted 18 lines
drivers/misc/cardreader/rtsx_pcr.c +1
-0+mutex_lock (&pcr->pcr_mutex);rtsx_pci_write_register (pcr,HOST_SLEEP_STATE ,0x03 ,0x00 );drivers/misc/cardreader/rtsx_pcr.h +1
-1@@ -25,6 +25,7 @@#define REG_EFUSE_POWEROFF 0x00#define RTS5250_CLK_CFG3 0xFF79#define RTS525A_CFG_MEM_PD 0xF0 +#define RTS524A_AUTOLOAD_CFG1 0xFF7C#define RTS524A_PM_CTRL3 0xFF7E#define RTS525A_BIOS_CFG 0xFF2D#define RTS525A_LOAD_BIOS_FLAG 0x01 --2.25.1
Quoted 161 lines
-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Thursday, January 13, 2022 7:33 PM
To: Ricky WU <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: modify rtd3 flowdrivers/misc/cardreader/rts5249.c static void rtsx_base_fetch_vendor_settings(struct
Quoted 21 lines · Ricky WU
move
pm_runtime_get()to_runtime_resumewhen System enter S3, do not havesd_requestand do not callstart_runtopm_runtime_get()causeis_runtime_suspendedstatus not correctset more register in
power_downflow to make plugin or unplug card do not wake up system when system is at S3Signed-off-by Ricky Wu <[email protected]>--- drivers/misc/cardreader/rts5249.c | 31 ++++++++++++++++++++++++++++-- drivers/misc/cardreader/rtsx_pcr.c | 17 ++++++++-------- drivers/misc/cardreader/rtsx_pcr.h | 1 + 3 files changed, 38 insertions(+), 11 deletions(-)drivers/misc/cardreader/rts5249.c +0
-0@@ -74,7 +74,8 @@ static void rtsx_base_fetch_vendor_settings(struct
rtsx_pcr*pcr)Quoted 7 lines
drivers/misc/cardreader/rts5249.c +2
-1pci_read_config_dword (pdev,PCR_SETTING_REG2 , ®);pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); - pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg); +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) + pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg);drivers/misc/cardreader/rts5249.c static void rtsx_base_fetch_vendor_settings(struct
Quoted 10 lines
drivers/misc/cardreader/rts5249.c +5
-0if (rtsx_check_mmc_support (reg)) pcr->extra_caps |= EXTRA_CAPS_NO_MMC; @@ -143,6 +144,27 @@ static int rts5249_init_from_hw(struct rtsx_pcr *pcr) return 0; } +static void rts52xa_force_power_down (struct rtsx_pcr *pcr,u8 +pm_state) { +/* Set relink_time to 0 */ + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1,
MASK_8_BIT_DEF, 0);Quoted 1 line
+ rtsx_pci_write_register(pcr,
AUTOLOAD_CFG_BASE+ 2,
MASK_8_BIT_DEF, 0);drivers/misc/cardreader/rts5249.c static int rts5249_init_from_hw(struct rtsx_pcr *pcr)
Quoted 5 lines
drivers/misc/cardreader/rts5249.c +5
-0+rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +3 , +RELINK_TIME_MASK ,0 ); + + rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, + D3_DELINK_MODE_EN,
D3_DELINK_MODE_EN);drivers/misc/cardreader/rts5249.c static int rts5249_init_from_hw(struct rtsx_pcr *pcr)
Quoted 5 lines
drivers/misc/cardreader/rts5249.c +5
-0+ +if (!pcr->is_runtime_suspended) { +rtsx_pci_write_register (pcr,RTS524A_AUTOLOAD_CFG1 , +CD_RESUME_EN_MASK ,0 ); + rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, 0x01,
0x00);Quoted 1 line
+ rtsx_pci_write_register(pcr,
RTS524A_PME_FORCE_CTL,
0x30,0x20);Quoted 8 lines
drivers/misc/cardreader/rts5249.c +5
-0+ } + +rtsx_pci_write_register (pcr,FPDCTL ,ALL_POWER_DOWN , +ALL_POWER_DOWN ); } +static void rts52xa_save_content_from_efuse (struct rtsx_pcr *pcr) {u8 cnt, sv;drivers/misc/cardreader/rts5249.c static int rts5249_extra_init_hw(struct rtsx_pcr · line 309
Quoted 8 lines
drivers/misc/cardreader/rts5249.c +2
-1@@ -281,8 +303,11 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)rtsx_pci_send_cmd (pcr,CMD_TIMEOUT_DEF ); -if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) + { rtsx_pci_write_register(pcr, REG_VREF,
PWD_SUSPND_EN,drivers/misc/cardreader/rts5249.c static int rts5249_extra_init_hw(struct rtsx_pcr · line 312
Quoted 3 lines
drivers/misc/cardreader/rts5249.c +2
-0PWD_SUSPND_EN); + rtsx_pci_write_register(pcr, RTS524A_AUTOLOAD_CFG1, + CD_RESUME_EN_MASK,
CD_RESUME_EN_MASK);Quoted 5 lines
drivers/misc/cardreader/rts5249.c +1
-0+ } if (pcr->rtd3_en) { if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr,
PID_525A)) { @@ -724,6 +749,7 @@ static const structpcr_ops
rts524a_pcr_ops= {Quoted 21 lines
.card_power_on =
rtsx_base_card_power_on, .card_power_off =rtsx_base_card_power_off, .switch_output_voltage =rtsx_base_switch_output_voltage,drivers/misc/cardreader/rts5249.c +2
-0+ .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };@@ -841,6 +867,7 @@ static const struct pcr_ops rts525a_pcr_ops = { .card_power_on = rts525a_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rts525a_switch_output_voltage, + .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };drivers/misc/cardreader/rtsx_pcr.c +0
-0@@ -152,12 +152,6 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr)if (pcr->remove_pci)return ;drivers/misc/cardreader/rtsx_pcr.c void rtsx_pci_start_run(struct rtsx_pcr *pcr) · line 157
Quoted 10 lines
drivers/misc/cardreader/rtsx_pcr.c +0
-6-if (pcr->rtd3_en) -if (pcr->is_runtime_suspended) { -pm_runtime_get (&(pcr->pci->dev)); - pcr->is_runtime_suspended = false; - } -if (pcr->state !=PDEV_STAT_RUN ) { pcr->state =PDEV_STAT_RUN ; if (pcr->ops->enable_auto_blink) @@ -1597,6 +1591,7@@
Quoted 2 lines
static int rtsx_pci_probe(struct
pci_dev*pcidev,pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr +
HOST_CMDS_BUF_LEN;Quoted 4 lines
pcr->card_inserted = 0; pcr->card_removed = 0; + pcr->rtd3_en = 0; INIT_DELAYED_WORK(&pcr->carddet_work,
rtsx_pci_card_detect);drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_runtime_suspend(struct
Quoted 3 lines
INIT_DELAYED_WORK(&pcr->idle_work, rtsx_pci_idle_work);drivers/misc/cardreader/rtsx_pcr.c +0
-0@@ -1796,17 +1791,16 @@ static int rtsx_pci_runtime_suspend(structdevice *device)
drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_runtime_resume(struct device
Quoted 20 lines
drivers/misc/cardreader/rtsx_pcr.c +2
-3pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__); + pcr->is_runtime_suspended = true; +cancel_delayed_work (&pcr->carddet_work);cancel_delayed_work (&pcr->rtd3_work);cancel_delayed_work (&pcr->idle_work);mutex_lock (&pcr->pcr_mutex);rtsx_pci_power_off (pcr,HOST_ENTER_S3 ); -mutex_unlock (&pcr->pcr_mutex); - pcr->is_runtime_suspended = true; -return 0 ; }@@ -1820,6 +1814,11 @@ static int rtsx_pci_runtime_resume(struct device*device)
Quoted 3 lines
drivers/misc/cardreader/rtsx_pcr.c +0
-0pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__);
Quoted 9 lines
drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_runtime_resume(struct device *device) · line 1820
Quoted 4 lines
drivers/misc/cardreader/rtsx_pcr.c +4
-0+if (pcr->is_runtime_suspended) { +pm_runtime_get (&(pcr->pci->dev)); + pcr->is_runtime_suspended = false; + }If the runtime resume routine is called for system wide suspend, the runtime suspend isn't allowed during the period.
So I don't quite understand what this patch is for.
We don’t want to entry D3 frequently
So we need to call pm_runtime_get() at start And call pm_runtime_put() in delay-work (rtd3_work)
But we found If we keep this if statement in start_run if (pcr->is_runtime_suspended) {
pm_runtime_get(&(pcr->pci->dev)); pcr->is_runtime_suspended = false;
}pcr->is_runtime_suspended this status are not correct when enter S3 because enter S3 not call start_run()
Quoted 22 lines
Kai-Heng
Quoted 18 lines
drivers/misc/cardreader/rtsx_pcr.c +1
-0+mutex_lock (&pcr->pcr_mutex);rtsx_pci_write_register (pcr,HOST_SLEEP_STATE ,0x03 ,0x00 );drivers/misc/cardreader/rtsx_pcr.h +1
-1@@ -25,6 +25,7 @@#define REG_EFUSE_POWEROFF 0x00#define RTS5250_CLK_CFG3 0xFF79#define RTS525A_CFG_MEM_PD 0xF0 +#define RTS524A_AUTOLOAD_CFG1 0xFF7C#define RTS524A_PM_CTRL3 0xFF7E#define RTS525A_BIOS_CFG 0xFF2D#define RTS525A_LOAD_BIOS_FLAG 0x01 --Quoted 1 line
2.25.1
------Please consider the environment before printing this e-mail.
Quoted 167 lines · Ricky WU
Quoted 167 lines
-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Thursday, January 13, 2022 7:33 PM
To: Ricky WU <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: modify rtd3 flowdrivers/misc/cardreader/rts5249.c static void rtsx_base_fetch_vendor_settings(struct
Quoted 21 lines · Ricky WU
move
pm_runtime_get()to_runtime_resumewhen System enter S3, do not havesd_requestand do not callstart_runtopm_runtime_get()causeis_runtime_suspendedstatus not correctset more register in
power_downflow to make plugin or unplug card do not wake up system when system is at S3Signed-off-by Ricky Wu <[email protected]>--- drivers/misc/cardreader/rts5249.c | 31 ++++++++++++++++++++++++++++-- drivers/misc/cardreader/rtsx_pcr.c | 17 ++++++++-------- drivers/misc/cardreader/rtsx_pcr.h | 1 + 3 files changed, 38 insertions(+), 11 deletions(-)drivers/misc/cardreader/rts5249.c +0
-0@@ -74,7 +74,8 @@ static void rtsx_base_fetch_vendor_settings(struct
rtsx_pcr*pcr)Quoted 7 lines
drivers/misc/cardreader/rts5249.c +2
-1pci_read_config_dword (pdev,PCR_SETTING_REG2 , ®);pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); - pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg); +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) + pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg);drivers/misc/cardreader/rts5249.c static void rtsx_base_fetch_vendor_settings(struct
Quoted 10 lines
drivers/misc/cardreader/rts5249.c +5
-0if (rtsx_check_mmc_support (reg)) pcr->extra_caps |= EXTRA_CAPS_NO_MMC; @@ -143,6 +144,27 @@ static int rts5249_init_from_hw(struct rtsx_pcr *pcr) return 0; } +static void rts52xa_force_power_down (struct rtsx_pcr *pcr,u8 +pm_state) { +/* Set relink_time to 0 */ + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1,
MASK_8_BIT_DEF, 0);Quoted 1 line
+ rtsx_pci_write_register(pcr,
AUTOLOAD_CFG_BASE+ 2,
MASK_8_BIT_DEF, 0);drivers/misc/cardreader/rts5249.c static int rts5249_init_from_hw(struct rtsx_pcr *pcr)
Quoted 5 lines
drivers/misc/cardreader/rts5249.c +5
-0+rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +3 , +RELINK_TIME_MASK ,0 ); + + rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, + D3_DELINK_MODE_EN,
D3_DELINK_MODE_EN);drivers/misc/cardreader/rts5249.c static int rts5249_init_from_hw(struct rtsx_pcr *pcr)
Quoted 5 lines
drivers/misc/cardreader/rts5249.c +5
-0+ +if (!pcr->is_runtime_suspended) { +rtsx_pci_write_register (pcr,RTS524A_AUTOLOAD_CFG1 , +CD_RESUME_EN_MASK ,0 ); + rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, 0x01,
0x00);Quoted 1 line
+ rtsx_pci_write_register(pcr,
RTS524A_PME_FORCE_CTL,
0x30,0x20);Quoted 8 lines
drivers/misc/cardreader/rts5249.c +5
-0+ } + +rtsx_pci_write_register (pcr,FPDCTL ,ALL_POWER_DOWN , +ALL_POWER_DOWN ); } +static void rts52xa_save_content_from_efuse (struct rtsx_pcr *pcr) {u8 cnt, sv;drivers/misc/cardreader/rts5249.c static int rts5249_extra_init_hw(struct rtsx_pcr · line 309
Quoted 8 lines
drivers/misc/cardreader/rts5249.c +2
-1@@ -281,8 +303,11 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)rtsx_pci_send_cmd (pcr,CMD_TIMEOUT_DEF ); -if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) + { rtsx_pci_write_register(pcr, REG_VREF,
PWD_SUSPND_EN,drivers/misc/cardreader/rts5249.c static int rts5249_extra_init_hw(struct rtsx_pcr · line 312
Quoted 3 lines
drivers/misc/cardreader/rts5249.c +2
-0PWD_SUSPND_EN); + rtsx_pci_write_register(pcr, RTS524A_AUTOLOAD_CFG1, + CD_RESUME_EN_MASK,
CD_RESUME_EN_MASK);Quoted 5 lines
drivers/misc/cardreader/rts5249.c +1
-0+ } if (pcr->rtd3_en) { if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr,
PID_525A)) { @@ -724,6 +749,7 @@ static const structpcr_ops
rts524a_pcr_ops= {Quoted 21 lines
.card_power_on =
rtsx_base_card_power_on, .card_power_off =rtsx_base_card_power_off, .switch_output_voltage =rtsx_base_switch_output_voltage,drivers/misc/cardreader/rts5249.c +2
-0+ .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };@@ -841,6 +867,7 @@ static const struct pcr_ops rts525a_pcr_ops = { .card_power_on = rts525a_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rts525a_switch_output_voltage, + .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };drivers/misc/cardreader/rtsx_pcr.c +0
-0@@ -152,12 +152,6 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr)if (pcr->remove_pci)return ;drivers/misc/cardreader/rtsx_pcr.c void rtsx_pci_start_run(struct rtsx_pcr *pcr) · line 157
Quoted 10 lines
drivers/misc/cardreader/rtsx_pcr.c +0
-6-if (pcr->rtd3_en) -if (pcr->is_runtime_suspended) { -pm_runtime_get (&(pcr->pci->dev)); - pcr->is_runtime_suspended = false; - } -if (pcr->state !=PDEV_STAT_RUN ) { pcr->state =PDEV_STAT_RUN ; if (pcr->ops->enable_auto_blink) @@ -1597,6 +1591,7@@
Quoted 2 lines
static int rtsx_pci_probe(struct
pci_dev*pcidev,pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr +
HOST_CMDS_BUF_LEN;Quoted 4 lines
pcr->card_inserted = 0; pcr->card_removed = 0; + pcr->rtd3_en = 0; INIT_DELAYED_WORK(&pcr->carddet_work,
rtsx_pci_card_detect);drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_runtime_suspend(struct
Quoted 3 lines
INIT_DELAYED_WORK(&pcr->idle_work, rtsx_pci_idle_work);drivers/misc/cardreader/rtsx_pcr.c +0
-0@@ -1796,17 +1791,16 @@ static int rtsx_pci_runtime_suspend(structdevice *device)
drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_runtime_resume(struct device
Quoted 20 lines
drivers/misc/cardreader/rtsx_pcr.c +2
-3pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__); + pcr->is_runtime_suspended = true; +cancel_delayed_work (&pcr->carddet_work);cancel_delayed_work (&pcr->rtd3_work);cancel_delayed_work (&pcr->idle_work);mutex_lock (&pcr->pcr_mutex);rtsx_pci_power_off (pcr,HOST_ENTER_S3 ); -mutex_unlock (&pcr->pcr_mutex); - pcr->is_runtime_suspended = true; -return 0 ; }@@ -1820,6 +1814,11 @@ static int rtsx_pci_runtime_resume(struct device*device)
Quoted 7 lines
drivers/misc/cardreader/rtsx_pcr.c +4
-0pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__); +if (pcr->is_runtime_suspended) { +pm_runtime_get (&(pcr->pci->dev)); + pcr->is_runtime_suspended = false; + }
Quoted 8 lines
Quoted 4 lines
If the runtime resume routine is called for system wide suspend, the runtime suspend isn't allowed during the period.
So I don't quite understand what this patch is for.We don’t want to entry D3 frequently
So we need to callpm_runtime_get()at start And callpm_runtime_put()in delay-work (rtd3_work)
Maybe use 'cancel_delayed_work(&pcr->rtd3_work)' like what rtsx_pci_runtime_suspend() does?
And for this case maybe cancel_delayed_work_sync() is more preferred.
Quoted 8 lines
But we found If we keep this if statement in
start_runif (pcr->is_runtime_suspended) {
pm_runtime_get(&(pcr->pci->dev));pcr->is_runtime_suspended= false;
}pcr->is_runtime_suspendedthis status are not correct when enter S3 because enter S3 not callstart_run()
Maybe because the driver is trying to trick the runtime PM core on its real power status?
I.e. the driver is maintaining its own PM state machine. Fully cooperating the driver with PM core should solve the issue.
Kai-Heng
Quoted 23 lines
Quoted 23 lines
Kai-Heng
Quoted 18 lines
drivers/misc/cardreader/rtsx_pcr.c +1
-0+mutex_lock (&pcr->pcr_mutex);rtsx_pci_write_register (pcr,HOST_SLEEP_STATE ,0x03 ,0x00 );drivers/misc/cardreader/rtsx_pcr.h +1
-1@@ -25,6 +25,7 @@#define REG_EFUSE_POWEROFF 0x00#define RTS5250_CLK_CFG3 0xFF79#define RTS525A_CFG_MEM_PD 0xF0 +#define RTS524A_AUTOLOAD_CFG1 0xFF7C#define RTS524A_PM_CTRL3 0xFF7E#define RTS525A_BIOS_CFG 0xFF2D#define RTS525A_LOAD_BIOS_FLAG 0x01 --Quoted 1 line
2.25.1
------Please consider the environment before printing this e-mail.
Quoted 197 lines
-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Friday, January 14, 2022 3:29 PM
To: Ricky WU <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: modify rtd3 flowQuoted 11 lines · Ricky WU
Quoted 11 lines
-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Thursday, January 13, 2022 7:33 PM
To: Ricky WU <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: modify rtd3 flowOn Thu, Jan 13, 2022 at 6:50 PM Ricky WU <[email protected]>
Quoted 24 lines · wrote:
Quoted 24 lines
Quoted 22 lines
move
pm_runtime_get()to_runtime_resumewhen System enter S3, do not havesd_requestand do not callstart_runtopm_runtime_get()causeis_runtime_suspendedstatus not correctset more register in
power_downflow to make plugin or unplug card do not wake up system when system is at S3Signed-off-by Ricky Wu <[email protected]>--- drivers/misc/cardreader/rts5249.c | 31 ++++++++++++++++++++++++++++-- drivers/misc/cardreader/rtsx_pcr.c ++++++++++++++++++++++++++++| 17 ++++++++-------- drivers/misc/cardreader/rtsx_pcr.h | 1 + 3 files changed, 38 insertions(+), 11 deletions(-)drivers/misc/cardreader/rts5249.c +0
-0@@ -74,7 +74,8 @@ static voidQuoted 1 line
rtsx_base_fetch_vendor_settings(struct
rtsx_pcr*pcr)Quoted 5 lines
Quoted 5 lines
drivers/misc/cardreader/rts5249.c
Quoted 5 lines
pci_read_config_dword(pdev, PCR_SETTING_REG2, ®); pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);drivers/misc/cardreader/rts5249.c +1
-1- pcr->rtd3_en =rtsx_reg_to_rtd3_uhsii (reg); + if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr,
PID_525A))Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
+
pcr->rtd3_en=rtsx_reg_to_rtd3_uhsii(reg);if (rtsx_check_mmc_support(reg)) pcr->extra_caps |= EXTRA_CAPS_NO_MMC; @@-143,6
Quoted 16 lines
Quoted 16 lines
drivers/misc/cardreader/rts5249.c
Quoted 8 lines
+144,27 @@ static int
rts5249_init_from_hw(struct rtsx_pcr *pcr)return 0;}
drivers/misc/cardreader/rts5249.c +4
-0+static void rts52xa_force_power_down (struct rtsx_pcr *pcr,u8 +pm_state) { +/* Set relink_time to 0 */ + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1,
MASK_8_BIT_DEF, 0);Quoted 1 line
+ rtsx_pci_write_register(pcr,
AUTOLOAD_CFG_BASE+ 2,
MASK_8_BIT_DEF, 0);Quoted 5 lines
drivers/misc/cardreader/rts5249.c +5
-0+rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +3 , +RELINK_TIME_MASK ,0 ); + + rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, + D3_DELINK_MODE_EN,Quoted 4 lines
Quoted 4 lines
D3_DELINK_MODE_EN);Quoted 3 lines
drivers/misc/cardreader/rts5249.c +3
-0+ +if (!pcr->is_runtime_suspended) { + rtsx_pci_write_register(pcr,
RTS524A_AUTOLOAD_CFG1,Quoted 18 lines
Quoted 18 lines
drivers/misc/cardreader/rts5249.c
Quoted 3 lines
drivers/misc/cardreader/rts5249.c +3
-0+ CD_RESUME_EN_MASK, 0); + rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, + 0x01,
0x00);Quoted 2 lines
+ rtsx_pci_write_register(pcr,
+RTS524A_PME_FORCE_CTL,
0x30,0x20);Quoted 11 lines
drivers/misc/cardreader/rts5249.c +5
-0+ } + +rtsx_pci_write_register (pcr,FPDCTL ,ALL_POWER_DOWN , +ALL_POWER_DOWN ); } +static void rts52xa_save_content_from_efuse (struct rtsx_pcr *pcr) {u8 cnt, sv;@@ -281,8 +303,11 @@ static int rts5249_extra_init_hw(struct
rtsx_pcr
*pcr)Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
rtsx_pci_send_cmd(pcr, CMD_TIMEOUT_DEF);- if (
CHK_PCI_PID(pcr, PID_524A)|| CHK_PCI_PID(pcr,
PID_525A))Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
+ if (
CHK_PCI_PID(pcr, PID_524A)|| CHK_PCI_PID(pcr,
+PID_525A)) {
rtsx_pci_write_register(pcr,REG_VREF,
PWD_SUSPND_EN,Quoted 2 lines
PWD_SUSPND_EN);
+ rtsx_pci_write_register(pcr,
RTS524A_AUTOLOAD_CFG1,Quoted 88 lines
Quoted 87 lines
Quoted 1 line
+
CD_RESUME_EN_MASK,
CD_RESUME_EN_MASK);Quoted 5 lines
+ }
if (pcr->rtd3_en) { if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr,
PID_525A)) { @@ -724,6 +749,7 @@ static const structpcr_ops
rts524a_pcr_ops= {Quoted 22 lines
.card_power_on =
rtsx_base_card_power_on, .card_power_off =rtsx_base_card_power_off, .switch_output_voltage =rtsx_base_switch_output_voltage,drivers/misc/cardreader/rts5249.c +2
-0+ .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };@@ -841,6 +867,7 @@ static const struct pcr_ops rts525a_pcr_ops = { .card_power_on = rts525a_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rts525a_switch_output_voltage, + .force_power_down = rts52xa_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };drivers/misc/cardreader/rtsx_pcr.c +0
-0@@ -152,12 +152,6 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr)if (pcr->remove_pci)return ;drivers/misc/cardreader/rtsx_pcr.c void rtsx_pci_start_run(struct rtsx_pcr *pcr)
Quoted 10 lines
drivers/misc/cardreader/rtsx_pcr.c +1
-6-if (pcr->rtd3_en) -if (pcr->is_runtime_suspended) { -pm_runtime_get (&(pcr->pci->dev)); - pcr->is_runtime_suspended = false; - } -if (pcr->state !=PDEV_STAT_RUN ) { pcr->state =PDEV_STAT_RUN ; if (pcr->ops->enable_auto_blink) @@ -1597,6 +1591 ,7 @@
Quoted 2 lines
static int rtsx_pci_probe(struct
pci_dev*pcidev,pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr +
HOST_CMDS_BUF_LEN;Quoted 4 lines
pcr->card_inserted = 0; pcr->card_removed = 0; + pcr->rtd3_en = 0; INIT_DELAYED_WORK(&pcr->carddet_work,
rtsx_pci_card_detect);drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_runtime_suspend(struct
Quoted 3 lines
INIT_DELAYED_WORK(&pcr->idle_work, rtsx_pci_idle_work);drivers/misc/cardreader/rtsx_pcr.c +0
-0@@ -1796,17 +1791,16 @@ static int rtsx_pci_runtime_suspend(structdevice *device)
Quoted 20 lines
drivers/misc/cardreader/rtsx_pcr.c +2
-3pcr = handle->pcr;dev_dbg (&(pcidev->dev),"--> %s\n" , __func__); + pcr->is_runtime_suspended = true; +cancel_delayed_work (&pcr->carddet_work);cancel_delayed_work (&pcr->rtd3_work);cancel_delayed_work (&pcr->idle_work);mutex_lock (&pcr->pcr_mutex);rtsx_pci_power_off (pcr,HOST_ENTER_S3 ); -mutex_unlock (&pcr->pcr_mutex); - pcr->is_runtime_suspended = true; -return 0 ; }@@ -1820,6 +1814,11 @@ static int rtsx_pci_runtime_resume(structQuoted 1 line
device
*device)
drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_runtime_resume(struct device *device) · line 1820
Quoted 7 lines
pcr = handle->pcr; dev_dbg(&(pcidev->dev), "--> %s\n", __func__);drivers/misc/cardreader/rtsx_pcr.c +4
-0+if (pcr->is_runtime_suspended) { +pm_runtime_get (&(pcr->pci->dev)); + pcr->is_runtime_suspended = false; + }If the runtime resume routine is called for system wide suspend, the runtime suspend isn't allowed during the period.
So I don't quite understand what this patch is for.
Quoted 8 lines
Quoted 3 lines
We don’t want to entry D3 frequently
So we need to callpm_runtime_get()at start And callpm_runtime_put()in delay-work (rtd3_work)Maybe use '
cancel_delayed_work(&pcr->rtd3_work)' like whatrtsx_pci_runtime_suspend()does?
And for this case maybecancel_delayed_work_sync()is more preferred.
I think you misunderstand what I means
This delay_work() is for not enter D3 <-> D0 frequently
That delay is we need, we don’t want to power_on and power_off frequently on our device
This patch want to solve pcr->is_runtime_suspended this value
because we need to set more register at power_down flow when Device support D3 and System going to S3
Quoted 9 lines
Quoted 8 lines
But we found If we keep this if statement in
start_runif (pcr->is_runtime_suspended) {
pm_runtime_get(&(pcr->pci->dev));pcr->is_runtime_suspended= false;
}pcr->is_runtime_suspendedthis status are not correct when enter S3 because enter S3 not callstart_run()
Quoted 5 lines
Maybe because the driver is trying to trick the runtime PM core on its real power status?
I.e. the driver is maintaining its own PM state machine. Fully cooperating the driver with PM core should solve the issue.
System not call start_run() because do not have any sd_request at that time,
so we need to update value(pcr->is_runtime_suspended) at rtsx_pci_runtime_resume
but if we only update value here not to call pm_runtime_get(), the if-statement always be FALSE at start_run() that is why we move this if-statement from start_run() to rtsx_pci_runtime_resume()
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 19 lines
+
mutex_lock(&pcr->pcr_mutex); rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03,
0x00); diff --gita/drivers/misc/cardreader/rtsx_pcr.hb/drivers/misc/cardreader/rtsx_pcr.h
indexdaf057c4eea6..b93975268e6d100644drivers/misc/cardreader/rtsx_pcr.h +1
-1@@ -25,6 +25,7 @@#define REG_EFUSE_POWEROFF 0x00#define RTS5250_CLK_CFG3 0xFF79#define RTS525A_CFG_MEM_PD 0xF0 +#define RTS524A_AUTOLOAD_CFG1 0xFF7C#define RTS524A_PM_CTRL3 0xFF7E#define RTS525A_BIOS_CFG 0xFF2D#define RTS525A_LOAD_BIOS_FLAG 0x01 --Quoted 1 line
2.25.1
------Please consider the environment before printing this e-mail.
On Fri, Jan 14, 2022 at 4:51 PM Ricky WU <[email protected]> wrote:
[snip]
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
We don’t want to entry D3 frequently
So we need to callpm_runtime_get()at start And callpm_runtime_put()in delay-work (rtd3_work)
Quoted 7 lines
Quoted 4 lines
Maybe use '
cancel_delayed_work(&pcr->rtd3_work)' like whatrtsx_pci_runtime_suspend()does?
And for this case maybecancel_delayed_work_sync()is more preferred.I think you misunderstand what I means
Thisdelay_work()is for not enter D3 <-> D0 frequently
This is doable with current pm_runtime_*() helpers.
Quoted 1 line
That delay is we need, we don’t want to
power_onandpower_offfrequently on our device
Is this to avoid the pm_runtime_resume() call before system suspend? IOW, to avoid D3 -> D0 -> D3 for S3?
Quoted 3 lines
This patch want to solve
pcr->is_runtime_suspendedthis value
because we need to set more register atpower_downflow when Device support D3 and System going to S3
So is it possible to introduce a new parameter for force_power_down() and get rid of is_runtime_suspended completely?
Quoted 16 lines
Quoted 10 lines
Quoted 9 lines
But we found If we keep this if statement in
start_runif (pcr->is_runtime_suspended) {
pm_runtime_get(&(pcr->pci->dev));pcr->is_runtime_suspended= false;
}pcr->is_runtime_suspendedthis status are not correct when enter S3 because enter S3 not callstart_run()Quoted 5 lines
Maybe because the driver is trying to trick the runtime PM core on its real power status?
I.e. the driver is maintaining its own PM state machine. Fully cooperating the driver with PM core should solve the issue.
Quoted 3 lines
System not call
start_run()because do not have anysd_requestat that time,
so we need to updatevalue(pcr->is_runtime_suspended)atrtsx_pci_runtime_resume
but if we only update value here not to callpm_runtime_get(), the if-statement always be FALSE atstart_run()
Sounds like the RPM refcount goes to zero so it was runtime suspended again. The correct usage should be merging rtsx_pci_start_run() with rtsx_pci_runtime_resume(), then guard each op of mmc_host_ops with pm_runtime_get_sync() at the beginning and pm_runtime_idle() at and end of each ops.
Increase the RPM refcount in runtime resume routine to prevent the driver from suspending doesn't really make sense to me.
Kai-Heng
Quoted 23 lines
that is why we move this if-statement from
start_run()tortsx_pci_runtime_resume()Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 19 lines
+
mutex_lock(&pcr->pcr_mutex); rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03,
0x00); diff --gita/drivers/misc/cardreader/rtsx_pcr.hb/drivers/misc/cardreader/rtsx_pcr.h
indexdaf057c4eea6..b93975268e6d100644drivers/misc/cardreader/rtsx_pcr.h +1
-1@@ -25,6 +25,7 @@#define REG_EFUSE_POWEROFF 0x00#define RTS5250_CLK_CFG3 0xFF79#define RTS525A_CFG_MEM_PD 0xF0 +#define RTS524A_AUTOLOAD_CFG1 0xFF7C#define RTS524A_PM_CTRL3 0xFF7E#define RTS525A_BIOS_CFG 0xFF2D#define RTS525A_LOAD_BIOS_FLAG 0x01 --Quoted 1 line
2.25.1
------Please consider the environment before printing this e-mail.
Quoted 24 lines
-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Friday, January 14, 2022 8:09 PM
To: Ricky WU <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: modify rtd3 flowOn Fri, Jan 14, 2022 at 4:51 PM Ricky WU <[email protected]> wrote:
[snip]Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
We don’t want to entry D3 frequently So we need to call
pm_runtime_get()at start And callpm_runtime_put()in delay-work (rtd3_work)Quoted 7 lines
Quoted 4 lines
Maybe use '
cancel_delayed_work(&pcr->rtd3_work)' like whatrtsx_pci_runtime_suspend()does?
And for this case maybecancel_delayed_work_sync()is more preferred.I think you misunderstand what I means This
delay_work()is for not enter D3 <-> D0 frequently
Quoted 8 lines
This is doable with current pm_runtime_*() helpers.
Quoted 2 lines
That delay is we need, we don’t want to
power_onandpower_offfrequently on our deviceIs this to avoid the
pm_runtime_resume()call before system suspend? IOW, to avoid D3 -> D0 -> D3 for S3?
No, this only for make sure our device D0 -> D3 at least 10 sec, this only about device status not affect System suspend (S3)
You can see the current code rtsx_pci_idle_work(struct work_struct *work)
System suspend (S3) flow is different it will call rtsx_pci_suspend()
Quoted 8 lines
Quoted 4 lines
This patch want to solve
pcr->is_runtime_suspendedthis value because we need to set more register atpower_downflow when Device support D3 and System going to S3So is it possible to introduce a new parameter for
force_power_down()and get rid ofis_runtime_suspendedcompletely?
This just distinguish 524a, 525a go to the new power down flow Add more register setting for RTD3 enable
Quoted 27 lines
Quoted 16 lines
Quoted 10 lines
Quoted 9 lines
But we found If we keep this if statement in
start_runif (pcr->is_runtime_suspended) {
pm_runtime_get(&(pcr->pci->dev));pcr->is_runtime_suspended= false; }pcr->is_runtime_suspendedthis status are not correct when enterpcr->S3
because enter S3 not callstart_run()Quoted 5 lines
Maybe because the driver is trying to trick the runtime PM core on its real power status?
I.e. the driver is maintaining its own PM state machine. Fully cooperating the driver with PM core should solve the issue.Quoted 4 lines
System not call
start_run()because do not have anysd_requestat that time, so we need to updatevalue(pcr->is_runtime_suspended)atrtsx_pci_runtime_resumebut if we only update value here not to callpm_runtime_get(), the if-statement always be FALSE atstart_run()Sounds like the RPM refcount goes to zero so it was runtime suspended again. The correct usage should be merging
rtsx_pci_start_run()withrtsx_pci_runtime_resume(), then guard each op ofmmc_host_opswithpm_runtime_get_sync()at the beginning andpm_runtime_idle()at and end of each ops.
Quoted 4 lines
Increase the RPM refcount in runtime resume routine to prevent the driver from suspending doesn't really make sense to me.
Kai-Heng
We want to control the interval time between D0->D3
This is for good user experience and more stable for our device.
And this completely unaffected System suspend, because System want to enter S3 need to make sure Device back to D0 and then go to S3 and put Device to D3 if Device support D3
Quoted 25 lines
Quoted 25 lines
that is why we move this if-statement from
start_run()tortsx_pci_runtime_resume()Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 19 lines
+
mutex_lock(&pcr->pcr_mutex); rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03,
0x00); diff --gita/drivers/misc/cardreader/rtsx_pcr.hb/drivers/misc/cardreader/rtsx_pcr.h
indexdaf057c4eea6..b93975268e6d100644drivers/misc/cardreader/rtsx_pcr.h +1
-1@@ -25,6 +25,7 @@#define REG_EFUSE_POWEROFF 0x00#define RTS5250_CLK_CFG3 0xFF79#define RTS525A_CFG_MEM_PD 0xF0 +#define RTS524A_AUTOLOAD_CFG1 0xFF7C#define RTS524A_PM_CTRL3 0xFF7E#define RTS525A_BIOS_CFG 0xFF2D#define RTS525A_LOAD_BIOS_FLAG 0x01 --Quoted 1 line
2.25.1
------Please consider the environment before printing this e-mail.
Quoted 82 lines · Ricky WU
Quoted 25 lines
-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Friday, January 14, 2022 8:09 PM
To: Ricky WU <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: modify rtd3 flowOn Fri, Jan 14, 2022 at 4:51 PM Ricky WU <[email protected]> wrote:
[snip]Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
We don’t want to entry D3 frequently So we need to call
pm_runtime_get()at start And callpm_runtime_put()in delay-work (rtd3_work)Quoted 7 lines
Quoted 4 lines
Maybe use '
cancel_delayed_work(&pcr->rtd3_work)' like whatrtsx_pci_runtime_suspend()does?
And for this case maybecancel_delayed_work_sync()is more preferred.I think you misunderstand what I means This
delay_work()is for not enter D3 <-> D0 frequentlyQuoted 8 lines
This is doable with current pm_runtime_*() helpers.
Quoted 2 lines
That delay is we need, we don’t want to
power_onandpower_offfrequently on our deviceIs this to avoid the
pm_runtime_resume()call before system suspend? IOW, to avoid D3 -> D0 -> D3 for S3?No, this only for make sure our device D0 -> D3 at least 10 sec, this only about device status not affect System suspend (S3)
You can see the current codertsx_pci_idle_work(struct work_struct *work)System suspend (S3) flow is different it will call
rtsx_pci_suspend()Quoted 8 lines
Quoted 4 lines
This patch want to solve
pcr->is_runtime_suspendedthis value because we need to set more register atpower_downflow when Device support D3 and System going to S3So is it possible to introduce a new parameter for
force_power_down()and get rid ofis_runtime_suspendedcompletely?This just distinguish 524a, 525a go to the new power down flow Add more register setting for RTD3 enable
Quoted 30 lines
Quoted 16 lines
Quoted 10 lines
Quoted 9 lines
But we found If we keep this if statement in
start_runif (pcr->is_runtime_suspended) {
pm_runtime_get(&(pcr->pci->dev));pcr->is_runtime_suspended= false; }pcr->is_runtime_suspendedthis status are not correct when enterpcr->S3
because enter S3 not callstart_run()Quoted 5 lines
Maybe because the driver is trying to trick the runtime PM core on its real power status?
I.e. the driver is maintaining its own PM state machine. Fully cooperating the driver with PM core should solve the issue.Quoted 4 lines
System not call
start_run()because do not have anysd_requestat that time, so we need to updatevalue(pcr->is_runtime_suspended)atrtsx_pci_runtime_resumebut if we only update value here not to callpm_runtime_get(), the if-statement always be FALSE atstart_run()Sounds like the RPM refcount goes to zero so it was runtime suspended again. The correct usage should be merging
rtsx_pci_start_run()withrtsx_pci_runtime_resume(), then guard each op ofmmc_host_opswithpm_runtime_get_sync()at the beginning andpm_runtime_idle()at and end of each ops.Increase the RPM refcount in runtime resume routine to prevent the driver from suspending doesn't really make sense to me.
Quoted 7 lines
Quoted 1 line
Kai-Heng
We want to control the interval time between
D0->D3
This is for good user experience and more stable for our device.
And this completely unaffected System suspend, because System want to enter S3 need to make sure Device back to D0 and then go to S3 and put Device to D3 if Device support D3
Everything can become easier to incorporate the state machine to pm_runtime_*() helpers directly.
Let me work on a patch to achieve it.
Kai-Heng
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
that is why we move this if-statement from
start_run()tortsx_pci_runtime_resume()Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 19 lines
+
mutex_lock(&pcr->pcr_mutex); rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03,
0x00); diff --gita/drivers/misc/cardreader/rtsx_pcr.hb/drivers/misc/cardreader/rtsx_pcr.h
indexdaf057c4eea6..b93975268e6d100644drivers/misc/cardreader/rtsx_pcr.h +1
-1@@ -25,6 +25,7 @@#define REG_EFUSE_POWEROFF 0x00#define RTS5250_CLK_CFG3 0xFF79#define RTS525A_CFG_MEM_PD 0xF0 +#define RTS524A_AUTOLOAD_CFG1 0xFF7C#define RTS524A_PM_CTRL3 0xFF7E#define RTS525A_BIOS_CFG 0xFF2D#define RTS525A_LOAD_BIOS_FLAG 0x01 --Quoted 1 line
2.25.1
------Please consider the environment before printing this e-mail.