From 7a130c85312a99780d83060ba69c3f1b5a9f9848 Mon Sep 17 00:00:00 2001 From: Zhao Qunqin Date: Fri, 3 Jan 2025 19:23:54 +0800 Subject: [PATCH 1/4] LoongArch: Update the flush cache policy Upstream: no Otherwise, it may cause S3 wake-up failure in Loongson 3A6000 laptop. Signed-off-by: Zhao Qunqin Signed-off-by: Ming Wang --- arch/loongarch/mm/cache.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/mm/cache.c b/arch/loongarch/mm/cache.c index 6be04d36ca07..f6cda2b5d738 100644 --- a/arch/loongarch/mm/cache.c +++ b/arch/loongarch/mm/cache.c @@ -63,6 +63,28 @@ static void flush_cache_leaf(unsigned int leaf) } while (--nr_nodes > 0); } +static void flush_cache_last_level(unsigned int leaf) +{ + u64 addr; + int i, j, nr_nodes, way_size; + struct cache_desc *cdesc = current_cpu_data.cache_leaves + leaf; + + nr_nodes = loongson_sysconf.nr_nodes; + + addr = CSR_DMW1_BASE; + iocsr_write8(0x1, 0x280); + way_size = cdesc->sets * cdesc->linesz; + do { + for (i = 0; i < (cdesc->ways * 3); i++) { + for (j = 0; j < (cdesc->sets); j++) { + READ_ONCE(*(u32 *)addr); + addr += cdesc->linesz; + } + } + addr += 0x100000000000; + } while (--nr_nodes > 0); +} + asmlinkage __visible void __flush_cache_all(void) { int leaf; @@ -71,7 +93,7 @@ asmlinkage __visible void __flush_cache_all(void) leaf = cache_present - 1; if (cache_inclusive(cdesc + leaf)) { - flush_cache_leaf(leaf); + flush_cache_last_level(leaf); return; } -- Gitee From b8ddacbcd914bf7bcd254e58b45424ba5ec170fe Mon Sep 17 00:00:00 2001 From: Zhao Qunqin Date: Thu, 9 Jan 2025 17:37:13 +0800 Subject: [PATCH 2/4] hda/pci: Add AZX_DCAPS_NO_TCSEL flag for Loongson HDA devices Upstream: no Loongson's HDA devices do not support TCSEL functionality Signed-off-by: Zhao Qunqin Signed-off-by: Ming Wang --- sound/pci/hda/hda_intel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 950288f20522..c813abc1345b 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2813,9 +2813,9 @@ static const struct pci_device_id azx_ids[] = { AZX_DCAPS_NO_MSI | AZX_DCAPS_RIRB_PRE_DELAY | AZX_DCAPS_NO_64BIT }, /* Loongson HDAudio*/ { PCI_VDEVICE(LOONGSON, PCI_DEVICE_ID_LOONGSON_HDA), - .driver_data = AZX_DRIVER_LOONGSON }, + .driver_data = AZX_DRIVER_LOONGSON | AZX_DCAPS_NO_TCSEL}, { PCI_VDEVICE(LOONGSON, PCI_DEVICE_ID_LOONGSON_HDMI), - .driver_data = AZX_DRIVER_LOONGSON }, + .driver_data = AZX_DRIVER_LOONGSON | AZX_DCAPS_NO_TCSEL}, /* Hygon HDAudio */ { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_HDA), .driver_data = AZX_DRIVER_HYGON | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_NO_MSI }, -- Gitee From 8e2bfbfcf9bda90693365269aee6cb0837e1c8ba Mon Sep 17 00:00:00 2001 From: Huacai Chen Date: Sat, 25 Jan 2025 18:51:33 +0800 Subject: [PATCH 3/4] LoongArch: Correct the cacheinfo sharing information [ Upstream commit b62a03049f141061d0397bfa86b74f65985d9338] Conflict: none SMT cores and their sibling cores share the same L1 and L2 private caches (of course last level cache is also shared), so correct the cacheinfo sharing information to let shared_cpu_map correctly reflect this relationship. Below is the output of "lscpu" on Loongson-3A6000 (4 cores, 8 threads). 1. Before patch: L1d: 512 KiB (8 instances) L1i: 512 KiB (8 instances) L2: 2 MiB (8 instances) L3: 16 MiB (1 instance) 2. After patch: L1d: 256 KiB (4 instances) L1i: 256 KiB (4 instances) L2: 1 MiB (4 instances) L3: 16 MiB (1 instance) Reported-by: Chao Li Signed-off-by: Juxin Gao Signed-off-by: Huacai Chen Signed-off-by: Ming Wang --- arch/loongarch/kernel/cacheinfo.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/loongarch/kernel/cacheinfo.c b/arch/loongarch/kernel/cacheinfo.c index c7988f757281..8e231b0d2cd6 100644 --- a/arch/loongarch/kernel/cacheinfo.c +++ b/arch/loongarch/kernel/cacheinfo.c @@ -51,6 +51,12 @@ static void cache_cpumap_setup(unsigned int cpu) continue; sib_leaf = sib_cpu_ci->info_list + index; + /* SMT cores share all caches */ + if (cpus_are_siblings(i, cpu)) { + cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map); + cpumask_set_cpu(i, &this_leaf->shared_cpu_map); + } + /* Node's cores share shared caches */ if (cache_leaves_are_shared(this_leaf, sib_leaf)) { cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map); cpumask_set_cpu(i, &this_leaf->shared_cpu_map); -- Gitee From 672964a9676659c3b893f6f72f329d6a4a674a5f Mon Sep 17 00:00:00 2001 From: Zhao Qunqin Date: Mon, 20 Jan 2025 23:17:38 +0800 Subject: [PATCH 4/4] blutetooth/btusb: delay 1ms while suspending Upstream: no There are suspend, resume and suspend before hibernation, Loongson need to wait until the previous resume is completely over before the last suspending. Otherwise, it may cause S4 suspend failure in Loongson platform. Signed-off-by: Zhao Qunqin Signed-off-by: Ming Wang --- drivers/bluetooth/btusb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index c80b5aa7628a..0cec54f2b2ad 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -4686,6 +4686,9 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) if (data->suspend_count++) return 0; +#ifdef CONFIG_LOONGARCH + mdelay(1); +#endif spin_lock_irq(&data->txlock); if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) { set_bit(BTUSB_SUSPENDING, &data->flags); -- Gitee