Skip to content

Commit 1dfa2e7

Browse files
committed
Merge tag 'char-misc-5.13-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are some small misc driver fixes for 5.13-rc6 that fix some reported problems: - Tiny phy driver fixes for reported issues - rtsx regression for when the device suspended - mhi driver fix for a use-after-free All of these have been in linux-next for a few days with no reported issues" * tag 'char-misc-5.13-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: misc: rtsx: separate aspm mode into MODE_REG and MODE_CFG bus: mhi: pci-generic: Fix hibernation bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove() bus: mhi: pci_generic: T99W175: update channel name from AT to DUN phy: Sparx5 Eth SerDes: check return value after calling platform_get_resource() phy: ralink: phy-mt7621-pci: drop 'of_match_ptr' to fix -Wunused-const-variable phy: ti: Fix an error code in wiz_probe() phy: phy-mtk-tphy: Fix some resource leaks in mtk_phy_init() phy: cadence: Sierra: Fix error return code in cdns_sierra_phy_probe() phy: usb: Fix misuse of IS_ENABLED
2 parents 141415d + 3df4fce commit 1dfa2e7

File tree

17 files changed

+93
-20
lines changed

17 files changed

+93
-20
lines changed

drivers/bus/mhi/pci_generic.c

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ static const struct mhi_channel_config mhi_foxconn_sdx55_channels[] = {
311311
MHI_CHANNEL_CONFIG_DL(5, "DIAG", 32, 1),
312312
MHI_CHANNEL_CONFIG_UL(12, "MBIM", 32, 0),
313313
MHI_CHANNEL_CONFIG_DL(13, "MBIM", 32, 0),
314-
MHI_CHANNEL_CONFIG_UL(32, "AT", 32, 0),
315-
MHI_CHANNEL_CONFIG_DL(33, "AT", 32, 0),
314+
MHI_CHANNEL_CONFIG_UL(32, "DUN", 32, 0),
315+
MHI_CHANNEL_CONFIG_DL(33, "DUN", 32, 0),
316316
MHI_CHANNEL_CONFIG_HW_UL(100, "IP_HW0_MBIM", 128, 2),
317317
MHI_CHANNEL_CONFIG_HW_DL(101, "IP_HW0_MBIM", 128, 3),
318318
};
@@ -708,7 +708,7 @@ static void mhi_pci_remove(struct pci_dev *pdev)
708708
struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
709709
struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
710710

711-
del_timer(&mhi_pdev->health_check_timer);
711+
del_timer_sync(&mhi_pdev->health_check_timer);
712712
cancel_work_sync(&mhi_pdev->recovery_work);
713713

714714
if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
@@ -935,9 +935,43 @@ static int __maybe_unused mhi_pci_resume(struct device *dev)
935935
return ret;
936936
}
937937

938+
static int __maybe_unused mhi_pci_freeze(struct device *dev)
939+
{
940+
struct mhi_pci_device *mhi_pdev = dev_get_drvdata(dev);
941+
struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
942+
943+
/* We want to stop all operations, hibernation does not guarantee that
944+
* device will be in the same state as before freezing, especially if
945+
* the intermediate restore kernel reinitializes MHI device with new
946+
* context.
947+
*/
948+
if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
949+
mhi_power_down(mhi_cntrl, false);
950+
mhi_unprepare_after_power_down(mhi_cntrl);
951+
}
952+
953+
return 0;
954+
}
955+
956+
static int __maybe_unused mhi_pci_restore(struct device *dev)
957+
{
958+
struct mhi_pci_device *mhi_pdev = dev_get_drvdata(dev);
959+
960+
/* Reinitialize the device */
961+
queue_work(system_long_wq, &mhi_pdev->recovery_work);
962+
963+
return 0;
964+
}
965+
938966
static const struct dev_pm_ops mhi_pci_pm_ops = {
939967
SET_RUNTIME_PM_OPS(mhi_pci_runtime_suspend, mhi_pci_runtime_resume, NULL)
940-
SET_SYSTEM_SLEEP_PM_OPS(mhi_pci_suspend, mhi_pci_resume)
968+
#ifdef CONFIG_PM_SLEEP
969+
.suspend = mhi_pci_suspend,
970+
.resume = mhi_pci_resume,
971+
.freeze = mhi_pci_freeze,
972+
.thaw = mhi_pci_restore,
973+
.restore = mhi_pci_restore,
974+
#endif
941975
};
942976

943977
static struct pci_driver mhi_pci_driver = {

drivers/misc/cardreader/rtl8411.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ static void rtl8411_init_common_params(struct rtsx_pcr *pcr)
468468
pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
469469
pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
470470
pcr->aspm_en = ASPM_L1_EN;
471+
pcr->aspm_mode = ASPM_MODE_CFG;
471472
pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14);
472473
pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10);
473474
pcr->ic_version = rtl8411_get_ic_version(pcr);

drivers/misc/cardreader/rts5209.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ void rts5209_init_params(struct rtsx_pcr *pcr)
255255
pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
256256
pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
257257
pcr->aspm_en = ASPM_L1_EN;
258+
pcr->aspm_mode = ASPM_MODE_CFG;
258259
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 16);
259260
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
260261

drivers/misc/cardreader/rts5227.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ void rts5227_init_params(struct rtsx_pcr *pcr)
358358
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
359359
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
360360
pcr->aspm_en = ASPM_L1_EN;
361+
pcr->aspm_mode = ASPM_MODE_CFG;
361362
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15);
362363
pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 7, 7);
363364

@@ -483,6 +484,7 @@ void rts522a_init_params(struct rtsx_pcr *pcr)
483484

484485
rts5227_init_params(pcr);
485486
pcr->ops = &rts522a_pcr_ops;
487+
pcr->aspm_mode = ASPM_MODE_REG;
486488
pcr->tx_initial_phase = SET_CLOCK_PHASE(20, 20, 11);
487489
pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3;
488490

drivers/misc/cardreader/rts5228.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ void rts5228_init_params(struct rtsx_pcr *pcr)
718718
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
719719
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
720720
pcr->aspm_en = ASPM_L1_EN;
721+
pcr->aspm_mode = ASPM_MODE_REG;
721722
pcr->tx_initial_phase = SET_CLOCK_PHASE(28, 27, 11);
722723
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
723724

drivers/misc/cardreader/rts5229.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ void rts5229_init_params(struct rtsx_pcr *pcr)
246246
pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
247247
pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
248248
pcr->aspm_en = ASPM_L1_EN;
249+
pcr->aspm_mode = ASPM_MODE_CFG;
249250
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15);
250251
pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 6, 6);
251252

drivers/misc/cardreader/rts5249.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ void rts5249_init_params(struct rtsx_pcr *pcr)
566566
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
567567
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
568568
pcr->aspm_en = ASPM_L1_EN;
569+
pcr->aspm_mode = ASPM_MODE_CFG;
569570
pcr->tx_initial_phase = SET_CLOCK_PHASE(1, 29, 16);
570571
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
571572

@@ -729,6 +730,7 @@ static const struct pcr_ops rts524a_pcr_ops = {
729730
void rts524a_init_params(struct rtsx_pcr *pcr)
730731
{
731732
rts5249_init_params(pcr);
733+
pcr->aspm_mode = ASPM_MODE_REG;
732734
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 29, 11);
733735
pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF;
734736
pcr->option.ltr_l1off_snooze_sspwrgate =
@@ -845,6 +847,7 @@ static const struct pcr_ops rts525a_pcr_ops = {
845847
void rts525a_init_params(struct rtsx_pcr *pcr)
846848
{
847849
rts5249_init_params(pcr);
850+
pcr->aspm_mode = ASPM_MODE_REG;
848851
pcr->tx_initial_phase = SET_CLOCK_PHASE(25, 29, 11);
849852
pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF;
850853
pcr->option.ltr_l1off_snooze_sspwrgate =

drivers/misc/cardreader/rts5260.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ void rts5260_init_params(struct rtsx_pcr *pcr)
628628
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
629629
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
630630
pcr->aspm_en = ASPM_L1_EN;
631+
pcr->aspm_mode = ASPM_MODE_REG;
631632
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 29, 11);
632633
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
633634

drivers/misc/cardreader/rts5261.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ void rts5261_init_params(struct rtsx_pcr *pcr)
783783
pcr->sd30_drive_sel_1v8 = 0x00;
784784
pcr->sd30_drive_sel_3v3 = 0x00;
785785
pcr->aspm_en = ASPM_L1_EN;
786+
pcr->aspm_mode = ASPM_MODE_REG;
786787
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 11);
787788
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
788789

drivers/misc/cardreader/rtsx_pcr.c

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,18 @@ static void rtsx_comm_set_aspm(struct rtsx_pcr *pcr, bool enable)
8585
if (pcr->aspm_enabled == enable)
8686
return;
8787

88-
if (pcr->aspm_en & 0x02)
89-
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |
90-
FORCE_ASPM_CTL1, enable ? 0 : FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1);
91-
else
92-
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |
93-
FORCE_ASPM_CTL1, FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1);
88+
if (pcr->aspm_mode == ASPM_MODE_CFG) {
89+
pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL,
90+
PCI_EXP_LNKCTL_ASPMC,
91+
enable ? pcr->aspm_en : 0);
92+
} else if (pcr->aspm_mode == ASPM_MODE_REG) {
93+
if (pcr->aspm_en & 0x02)
94+
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |
95+
FORCE_ASPM_CTL1, enable ? 0 : FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1);
96+
else
97+
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |
98+
FORCE_ASPM_CTL1, FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1);
99+
}
94100

95101
if (!enable && (pcr->aspm_en & 0x02))
96102
mdelay(10);
@@ -1394,7 +1400,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
13941400
return err;
13951401
}
13961402

1397-
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0x30, 0x30);
1403+
if (pcr->aspm_mode == ASPM_MODE_REG)
1404+
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0x30, 0x30);
13981405

13991406
/* No CD interrupt if probing driver with card inserted.
14001407
* So we need to initialize pcr->card_exist here.
@@ -1410,6 +1417,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
14101417
static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)
14111418
{
14121419
int err;
1420+
u16 cfg_val;
1421+
u8 val;
14131422

14141423
spin_lock_init(&pcr->lock);
14151424
mutex_init(&pcr->pcr_mutex);
@@ -1477,6 +1486,21 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)
14771486
if (!pcr->slots)
14781487
return -ENOMEM;
14791488

1489+
if (pcr->aspm_mode == ASPM_MODE_CFG) {
1490+
pcie_capability_read_word(pcr->pci, PCI_EXP_LNKCTL, &cfg_val);
1491+
if (cfg_val & PCI_EXP_LNKCTL_ASPM_L1)
1492+
pcr->aspm_enabled = true;
1493+
else
1494+
pcr->aspm_enabled = false;
1495+
1496+
} else if (pcr->aspm_mode == ASPM_MODE_REG) {
1497+
rtsx_pci_read_register(pcr, ASPM_FORCE_CTL, &val);
1498+
if (val & FORCE_ASPM_CTL0 && val & FORCE_ASPM_CTL1)
1499+
pcr->aspm_enabled = false;
1500+
else
1501+
pcr->aspm_enabled = true;
1502+
}
1503+
14801504
if (pcr->ops->fetch_vendor_settings)
14811505
pcr->ops->fetch_vendor_settings(pcr);
14821506

@@ -1506,7 +1530,6 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
15061530
struct pcr_handle *handle;
15071531
u32 base, len;
15081532
int ret, i, bar = 0;
1509-
u8 val;
15101533

15111534
dev_dbg(&(pcidev->dev),
15121535
": Realtek PCI-E Card Reader found at %s [%04x:%04x] (rev %x)\n",
@@ -1572,11 +1595,6 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
15721595
pcr->host_cmds_addr = pcr->rtsx_resv_buf_addr;
15731596
pcr->host_sg_tbl_ptr = pcr->rtsx_resv_buf + HOST_CMDS_BUF_LEN;
15741597
pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr + HOST_CMDS_BUF_LEN;
1575-
rtsx_pci_read_register(pcr, ASPM_FORCE_CTL, &val);
1576-
if (val & FORCE_ASPM_CTL0 && val & FORCE_ASPM_CTL1)
1577-
pcr->aspm_enabled = false;
1578-
else
1579-
pcr->aspm_enabled = true;
15801598
pcr->card_inserted = 0;
15811599
pcr->card_removed = 0;
15821600
INIT_DELAYED_WORK(&pcr->carddet_work, rtsx_pci_card_detect);

0 commit comments

Comments
 (0)