Skip to content

Commit 3fb1481

Browse files
shankerwangmiaoMingcongBai
authored andcommitted
loongarch: fix HT_RX_INT_TRANS register
On machines with legacy firmware with BPI01000 version, the HT_RX_INT_TRANS register on the node 5, i.e. the node connected with the second LS7A bridge chip, is not initialized correctly, causing the failure of the delivery of interrupts from PCIe devices connected to the second LS7A bridge chip. This patch fixes this by correctly pointing the HT_RX_INT_TRANS register to the EXT_IOI_SEND_OFF register on the corresponding node.
1 parent be1007d commit 3fb1481

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

arch/loongarch/kernel/legacy_boot.c

+24
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ enum bpi_mem_type {
5959
#define LS7A_DMA_NODE_ID_OFFSET_SHF 8
6060
#define LS7A_DMA_NODE_ID_OFFSET_MASK GENMASK(12, 8)
6161

62+
/* Section 14.4.1, Page 100 of Loongson-3A5000 User Manual v1.03 */
63+
#define HT_CTRL_CFG_OFF 0xfdfb000000ull
64+
/* Section 14.5.34, Page 141 of Loongson-3A5000 User Manual v1.03 */
65+
#define HT_CTRL_HT_RX_INT_TRANS_LO_OFF 0x270
66+
#define HT_CTRL_HT_RX_INT_TRANS_HI_OFF 0x274
67+
#define HT_CTRL_HT_RX_INT_TRANS_INT_TRANS_ALLOW BIT(30)
68+
69+
/* Section 11.2.3, Page 61 of Loongson-3A5000 User Manual v1.03 */
70+
#define EXT_IOI_SEND_OFF 0x1140
71+
6272
struct loongarch_bpi_mem_map {
6373
struct loongarch_bpi_ext_hdr header; /*{"M", "E", "M"}*/
6474
u8 map_count;
@@ -615,6 +625,20 @@ static void __init init_acpi_arch_os_table_override (struct acpi_table_header *e
615625
writel(dma_cfg, dma_node_id_addr);
616626
}
617627
}
628+
629+
// Override HT_RX_INT_TRANS
630+
for(int i = 0; i < io_apic_count; i++){
631+
unsigned int node = eio_pics[i].node;
632+
void __iomem *ht_rx_int_trans_hi = (void __iomem *) TO_UNCACHE(nid_to_addrbase(node) + HT1LO_OFFSET + HT_CTRL_CFG_OFF + HT_CTRL_HT_RX_INT_TRANS_HI_OFF);
633+
void __iomem *ht_rx_int_trans_lo = (void __iomem *) TO_UNCACHE(nid_to_addrbase(node) + HT1LO_OFFSET + HT_CTRL_CFG_OFF + HT_CTRL_HT_RX_INT_TRANS_LO_OFF);
634+
u64 ext_ioi_addr = nid_to_addrbase(node) + LOONGSON_REG_BASE + EXT_IOI_SEND_OFF;
635+
u64 ht_rx_int_trans_cfg_orig = ((u64)readl(ht_rx_int_trans_hi) << 32) | readl(ht_rx_int_trans_lo);
636+
u32 ht_rx_int_trans_cfg_hi = HT_CTRL_HT_RX_INT_TRANS_INT_TRANS_ALLOW | (ext_ioi_addr >> 32);
637+
u32 ht_rx_int_trans_cfg_lo = ext_ioi_addr & GENMASK(31, 0);
638+
pr_info("BPI: HT controller on node %u RX_INT_TRANS is 0x%llx, will set to 0x%llx\n", node, ht_rx_int_trans_cfg_orig, ((u64)ht_rx_int_trans_cfg_hi << 32) | ht_rx_int_trans_cfg_lo);
639+
writel(ht_rx_int_trans_cfg_hi, ht_rx_int_trans_hi);
640+
writel(ht_rx_int_trans_cfg_lo, ht_rx_int_trans_lo);
641+
}
618642
}
619643

620644
void acpi_arch_os_table_override (struct acpi_table_header *existing_table, struct acpi_table_header **new_table){

0 commit comments

Comments
 (0)