From 868840516d01c50485218e28359eb825f0a77794 Mon Sep 17 00:00:00 2001 From: Dai Xin Date: Thu, 15 Dec 2022 17:42:28 +0000 Subject: [PATCH] sw64: deliver a warm/cold reset to Root Complex with plugin JMicron 585 card Sunway inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I5GFPA -------------------------------- On SW64 platform, JMicron 585 SATA card directly connected to Root Complex may raise DMA failure when reboot, so we force a warm/cold reset to Root Complex to fix can not access JMicron 585 SATA card. Signed-off-by: Dai Xin Reviewed-by: He Sheng Signed-off-by: Gu Zitao --- arch/sw_64/include/asm/platform.h | 1 + arch/sw_64/kernel/reset.c | 21 +++++++++++++++++++++ drivers/platform/sw64/legacy_xuelang.c | 16 +--------------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/arch/sw_64/include/asm/platform.h b/arch/sw_64/include/asm/platform.h index 5cbf634fb34e..c52e7fd7a039 100644 --- a/arch/sw_64/include/asm/platform.h +++ b/arch/sw_64/include/asm/platform.h @@ -23,5 +23,6 @@ extern void (*pm_restart)(void); extern void (*pm_halt)(void); extern int i2c_set_adapter(void); extern void cpld_write(uint8_t slave_addr, uint8_t reg, uint8_t data); +extern void fix_jm585_reset(void); #endif /* _ASM_SW64_PLATFORM_H */ diff --git a/arch/sw_64/kernel/reset.c b/arch/sw_64/kernel/reset.c index 51ca362e9e63..7f91a97d9d12 100644 --- a/arch/sw_64/kernel/reset.c +++ b/arch/sw_64/kernel/reset.c @@ -15,7 +15,27 @@ #include #include +#include +void fix_jm585_reset(void) +{ + struct pci_dev *pdev; + struct pci_controller *hose; + int val; + + pdev = pci_get_device(PCI_VENDOR_ID_JMICRON, + 0x0585, NULL); + if (pdev) { + hose = (struct pci_controller *)pdev->sysdata; + val = read_rc_conf(hose->node, hose->index, + RC_PORT_LINK_CTL); + write_rc_conf(hose->node, hose->index, + RC_PORT_LINK_CTL, val | 0x8); + write_rc_conf(hose->node, hose->index, + RC_PORT_LINK_CTL, val); + } + +} static void default_halt(void) { local_irq_disable(); @@ -42,6 +62,7 @@ static void default_restart(void) /* No point in taking interrupts anymore. */ local_irq_disable(); + fix_jm585_reset(); #ifdef CONFIG_EFI if (efi_capsule_pending(NULL)) efi_reboot(REBOOT_WARM, NULL); diff --git a/drivers/platform/sw64/legacy_xuelang.c b/drivers/platform/sw64/legacy_xuelang.c index cf78d1088f11..803bea946730 100644 --- a/drivers/platform/sw64/legacy_xuelang.c +++ b/drivers/platform/sw64/legacy_xuelang.c @@ -42,22 +42,8 @@ void sw64_poweroff(void) void sw64_restart(void) { - struct pci_dev *pdev; - struct pci_controller *hose; - int val; - if (is_in_host()) { - pdev = pci_get_device(PCI_VENDOR_ID_JMICRON, - 0x0585, NULL); - if (pdev) { - hose = (struct pci_controller *)pdev->sysdata; - val = read_rc_conf(hose->node, hose->index, - RC_PORT_LINK_CTL); - write_rc_conf(hose->node, hose->index, - RC_PORT_LINK_CTL, val | 0x8); - write_rc_conf(hose->node, hose->index, - RC_PORT_LINK_CTL, val); - } + fix_jm585_reset(); cpld_write(0x64, 0x00, 0xc3); } else vt_mode_kill_arch(LINUX_REBOOT_CMD_RESTART); -- GitLab