Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
54fc95a
LoongArch: Use arch specific phys_to_dma
AaronDot Feb 14, 2025
106738e
LoongArch: Change SHMLBA from SZ_64K to PAGE_SIZE
AaronDot Feb 14, 2025
c975136
LoongArch: Add writecombine support for DMW-based ioremap()
AaronDot Feb 14, 2025
484892e
LoongArch: Remove superfluous flush_dcache_page() definition
AaronDot Feb 14, 2025
0e7f5c1
LoongArch: Use accessors to page table entries instead of direct dere…
AaronDot Feb 14, 2025
b2fa48c
LoongArch: Improve hardware page table walker
AaronDot Feb 14, 2025
7c89043
LoongArch: Set initial pte entry with PAGE_GLOBAL for kernel space
AaronDot Feb 14, 2025
1c06100
LoongArch: Add AVEC irqchip support
AaronDot Feb 14, 2025
dd50566
LoongArch: Add CPU HWMon platform driver
AaronDot Feb 14, 2025
f340849
LoongArch: Fix i2c related issues
AaronDot Feb 14, 2025
f996548
LoongArch: Adjust the calculation of the number of packages
AaronDot Feb 14, 2025
402112e
irqchip/loongarch-avec: Add multi-nodes topology support
AaronDot Feb 15, 2025
c9f490b
irqchip/loongson-eiointc: Fix external irq route error
AaronDot Feb 14, 2025
6de7532
PCI: Prevent LS7A Bus Master clearing on kexec
AaronDot Feb 15, 2025
045c990
pci/quirks: LS7A2000: Fix pm transition of devices under pcie port
AaronDot Feb 14, 2025
4985495
PCI/ACPI: Increase Loongson max PCI hosts to 8
AaronDot Feb 15, 2025
de4ab3e
drm/loongson: Compile loongson drm driver as module
AaronDot Feb 14, 2025
dc2b4d1
cpufreq: loongson3-acpi: Initialize scaling_cur_freq correctly
AaronDot Feb 14, 2025
2755f1e
net: stmmac: dwmac-loongson: Add loongson_dwmac_fix_reset() callback
AaronDot Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Documentation/arch/loongarch/irq-chip-model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,38 @@ to CPUINTC directly::
| Devices |
+---------+

Advanced Extended IRQ model
===========================

In this model, IPI (Inter-Processor Interrupt) and CPU Local Timer interrupt go
to CPUINTC directly, CPU UARTS interrupts go to LIOINTC, PCH-MSI interrupts go
to AVECINTC, and then go to CPUINTC directly, while all other devices interrupts
go to PCH-PIC/PCH-LPC and gathered by EIOINTC, and then go to CPUINTC directly::

+-----+ +-----------------------+ +-------+
| IPI | --> | CPUINTC | <-- | Timer |
+-----+ +-----------------------+ +-------+
^ ^ ^
| | |
+---------+ +----------+ +---------+ +-------+
| EIOINTC | | AVECINTC | | LIOINTC | <-- | UARTs |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (typo): Typo: "UARTS" should be "UART"

Suggested change
| EIOINTC | | AVECINTC | | LIOINTC | <-- | UARTs |
| EIOINTC | | AVECINTC | | LIOINTC | <-- | UART |

+---------+ +----------+ +---------+ +-------+
^ ^
| |
+---------+ +---------+
| PCH-PIC | | PCH-MSI |
+---------+ +---------+
^ ^ ^
| | |
+---------+ +---------+ +---------+
| Devices | | PCH-LPC | | Devices |
+---------+ +---------+ +---------+
^
|
+---------+
| Devices |
+---------+

ACPI-related definitions
========================

Expand Down
32 changes: 32 additions & 0 deletions Documentation/translations/zh_CN/arch/loongarch/irq-chip-model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,38 @@ PCH-LPC/PCH-MSI,然后被EIOINTC统一收集,再直接到达CPUINTC::
| Devices |
+---------+

高级扩展IRQ模型
===============

在这种模型里面,IPI(Inter-Processor Interrupt)和CPU本地时钟中断直接发送到CPUINTC,
CPU串口(UARTs)中断发送到LIOINTC,PCH-MSI中断发送到AVECINTC,而后通过AVECINTC直接
送达CPUINTC,而其他所有设备的中断则分别发送到所连接的PCH-PIC/PCH-LPC,然后由EIOINTC
统一收集,再直接到达CPUINTC::

+-----+ +-----------------------+ +-------+
| IPI | --> | CPUINTC | <-- | Timer |
+-----+ +-----------------------+ +-------+
^ ^ ^
| | |
+---------+ +----------+ +---------+ +-------+
| EIOINTC | | AVECINTC | | LIOINTC | <-- | UARTs |
+---------+ +----------+ +---------+ +-------+
^ ^
| |
+---------+ +---------+
| PCH-PIC | | PCH-MSI |
+---------+ +---------+
^ ^ ^
| | |
+---------+ +---------+ +---------+
| Devices | | PCH-LPC | | Devices |
+---------+ +---------+ +---------+
^
|
+---------+
| Devices |
+---------+

ACPI相关的定义
==============

Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -12390,6 +12390,7 @@ F: Documentation/arch/loongarch/
F: Documentation/translations/zh_CN/arch/loongarch/
F: arch/loongarch/
F: drivers/*/*loongarch*
F: drivers/*/*loongson*

LOONGSON GPIO DRIVER
M: Yinbo Zhu <zhuyinbo@loongson.cn>
Expand Down
2 changes: 2 additions & 0 deletions arch/loongarch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ config LOONGARCH
select GENERIC_ENTRY
select GENERIC_GETTIMEOFDAY
select GENERIC_IOREMAP if !ARCH_IOREMAP
select GENERIC_IRQ_MATRIX_ALLOCATOR
select GENERIC_IRQ_MULTI_HANDLER
select GENERIC_IRQ_PROBE
select GENERIC_IRQ_SHOW
Expand Down Expand Up @@ -147,6 +148,7 @@ config LOONGARCH
select HAVE_SETUP_PER_CPU_AREA if NUMA
select HAVE_STACK_VALIDATION if HAVE_OBJTOOL
select HAVE_STACKPROTECTOR
select ARCH_HAS_PHYS_TO_DMA
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_TIF_NOHZ
select HAVE_VIRT_CPU_ACCOUNTING_GEN if !SMP
Expand Down
4 changes: 3 additions & 1 deletion arch/loongarch/configs/loongson3_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ CONFIG_DRM_AST=y
CONFIG_DRM_MGAG200=m
CONFIG_DRM_QXL=m
CONFIG_DRM_VIRTIO_GPU=m
CONFIG_DRM_LOONGSON=y
CONFIG_DRM_LOONGSON=m
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要一并在deepin_loongarch_desktop_defconfig 中也修改

CONFIG_DRM_BOCHS=m
CONFIG_DRM_CIRRUS_QEMU=m
CONFIG_FB=y
Expand Down Expand Up @@ -1674,6 +1674,8 @@ CONFIG_HID_ALPS=m
CONFIG_HID_PID=y
CONFIG_USB_HIDDEV=y
CONFIG_I2C_HID=m
CONFIG_I2C_HID_ACPI=m
CONFIG_I2C_HID_OF=m
CONFIG_USB_LED_TRIG=y
CONFIG_USB=y
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
Expand Down
4 changes: 4 additions & 0 deletions arch/loongarch/include/asm/addrspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ extern unsigned long vm_map_base;
#define UNCACHE_BASE CSR_DMW0_BASE
#endif

#ifndef WRITECOMBINE_BASE
#define WRITECOMBINE_BASE CSR_DMW2_BASE
#endif

#define DMW_PABITS 48
#define TO_PHYS_MASK ((1ULL << DMW_PABITS) - 1)

Expand Down
2 changes: 2 additions & 0 deletions arch/loongarch/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
#define __LL "ll.w "
#define __SC "sc.w "
#define __AMADD "amadd.w "
#define __AMOR "amor.w "
#define __AMAND_DB "amand_db.w "
#define __AMOR_DB "amor_db.w "
#define __AMXOR_DB "amxor_db.w "
#elif __SIZEOF_LONG__ == 8
#define __LL "ll.d "
#define __SC "sc.d "
#define __AMADD "amadd.d "
#define __AMOR "amor.d "
#define __AMAND_DB "amand_db.d "
#define __AMOR_DB "amor_db.d "
#define __AMXOR_DB "amxor_db.d "
Expand Down
3 changes: 0 additions & 3 deletions arch/loongarch/include/asm/cacheflush.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ void local_flush_icache_range(unsigned long start, unsigned long end);
#define flush_icache_range local_flush_icache_range
#define flush_icache_user_range local_flush_icache_range

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0

#define flush_cache_all() do { } while (0)
#define flush_cache_mm(mm) do { } while (0)
#define flush_cache_dup_mm(mm) do { } while (0)
Expand All @@ -47,7 +45,6 @@ void local_flush_icache_range(unsigned long start, unsigned long end);
#define flush_cache_vmap(start, end) do { } while (0)
#define flush_cache_vunmap(start, end) do { } while (0)
#define flush_icache_user_page(vma, page, addr, len) do { } while (0)
#define flush_dcache_page(page) do { } while (0)
#define flush_dcache_mmap_lock(mapping) do { } while (0)
#define flush_dcache_mmap_unlock(mapping) do { } while (0)

Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/include/asm/cpu-features.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@
#define cpu_has_guestid cpu_opt(LOONGARCH_CPU_GUESTID)
#define cpu_has_hypervisor cpu_opt(LOONGARCH_CPU_HYPERVISOR)
#define cpu_has_ptw cpu_opt(LOONGARCH_CPU_PTW)
#define cpu_has_avecint cpu_opt(LOONGARCH_CPU_AVECINT)

#endif /* __ASM_CPU_FEATURES_H */
2 changes: 2 additions & 0 deletions arch/loongarch/include/asm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ enum cpu_type_enum {
#define CPU_FEATURE_GUESTID 24 /* CPU has GuestID feature */
#define CPU_FEATURE_HYPERVISOR 25 /* CPU has hypervisor (running in VM) */
#define CPU_FEATURE_PTW 26 /* CPU has hardware page table walker */
#define CPU_FEATURE_AVECINT 27 /* CPU has avec interrupt */

#define LOONGARCH_CPU_CPUCFG BIT_ULL(CPU_FEATURE_CPUCFG)
#define LOONGARCH_CPU_LAM BIT_ULL(CPU_FEATURE_LAM)
Expand Down Expand Up @@ -127,5 +128,6 @@ enum cpu_type_enum {
#define LOONGARCH_CPU_GUESTID BIT_ULL(CPU_FEATURE_GUESTID)
#define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR)
#define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW)
#define LOONGARCH_CPU_AVECINT BIT_ULL(CPU_FEATURE_AVECINT)

#endif /* _ASM_CPU_H */
21 changes: 21 additions & 0 deletions arch/loongarch/include/asm/dma-direct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_LOONGARCH_DMA_DIRECT_H
#define _ASM_LOONGARCH_DMA_DIRECT_H

extern int node_id_offset;

static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
{
long nid = (paddr >> 44) & 0xf;

return ((nid << 44) ^ paddr) | (nid << node_id_offset);
}

static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
{
long nid = (daddr >> node_id_offset) & 0xf;

return ((nid << node_id_offset) ^ daddr) | (nid << 44);
}

#endif /* _ASM_LOONGARCH_DMA_DIRECT_H */
3 changes: 2 additions & 1 deletion arch/loongarch/include/asm/hardirq.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ extern void ack_bad_irq(unsigned int irq);
enum ipi_msg_type {
IPI_RESCHEDULE,
IPI_CALL_FUNCTION,
IPI_CLEAR_VECTOR,
};
#define NR_IPI 2
#define NR_IPI 3

typedef struct {
unsigned int ipi_irqs[NR_IPI];
Expand Down
4 changes: 2 additions & 2 deletions arch/loongarch/include/asm/hugetlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
unsigned long addr, pte_t *ptep)
{
pte_t clear;
pte_t pte = *ptep;
pte_t pte = ptep_get(ptep);

pte_val(clear) = (unsigned long)invalid_pte_table;
set_pte_at(mm, addr, ptep, clear);
Expand Down Expand Up @@ -75,7 +75,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
pte_t *ptep, pte_t pte,
int dirty)
{
int changed = !pte_same(*ptep, pte);
int changed = !pte_same(ptep_get(ptep), pte);

if (changed) {
set_pte_at(vma->vm_mm, addr, ptep, pte);
Expand Down
10 changes: 8 additions & 2 deletions arch/loongarch/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ extern void __init early_iounmap(void __iomem *addr, unsigned long size);
static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
unsigned long prot_val)
{
if (prot_val & _CACHE_CC)
switch (prot_val & _CACHE_MASK) {
case _CACHE_CC:
return (void __iomem *)(unsigned long)(CACHE_BASE + offset);
else
case _CACHE_SUC:
return (void __iomem *)(unsigned long)(UNCACHE_BASE + offset);
case _CACHE_WUC:
return (void __iomem *)(unsigned long)(WRITECOMBINE_BASE + offset);
default:
return NULL;
}
}

#define ioremap(offset, size) \
Expand Down
29 changes: 14 additions & 15 deletions arch/loongarch/include/asm/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ void spurious_interrupt(void);

#define NR_IRQS_LEGACY 16

/*
* 256 Vectors Mapping for AVECINTC:
*
* 0 - 15: Mapping classic IPs, e.g. IP0-12.
* 16 - 255: Mapping vectors for external IRQ.
*
*/
#define NR_VECTORS 256
#define NR_LEGACY_VECTORS 16
#define IRQ_MATRIX_BITS NR_VECTORS

#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
void arch_trigger_cpumask_backtrace(const struct cpumask *mask, int exclude_cpu);

Expand All @@ -65,7 +76,7 @@ extern struct acpi_vector_group msi_group[MAX_IO_PICS];
#define LOONGSON_LPC_LAST_IRQ (LOONGSON_LPC_IRQ_BASE + 15)

#define LOONGSON_CPU_IRQ_BASE 16
#define LOONGSON_CPU_LAST_IRQ (LOONGSON_CPU_IRQ_BASE + 14)
#define LOONGSON_CPU_LAST_IRQ (LOONGSON_CPU_IRQ_BASE + 15)

#define LOONGSON_PCH_IRQ_BASE 64
#define LOONGSON_PCH_ACPI_IRQ (LOONGSON_PCH_IRQ_BASE + 47)
Expand All @@ -88,20 +99,8 @@ struct acpi_madt_bio_pic;
struct acpi_madt_msi_pic;
struct acpi_madt_lpc_pic;

int liointc_acpi_init(struct irq_domain *parent,
struct acpi_madt_lio_pic *acpi_liointc);
int eiointc_acpi_init(struct irq_domain *parent,
struct acpi_madt_eio_pic *acpi_eiointc);

int htvec_acpi_init(struct irq_domain *parent,
struct acpi_madt_ht_pic *acpi_htvec);
int pch_lpc_acpi_init(struct irq_domain *parent,
struct acpi_madt_lpc_pic *acpi_pchlpc);
int pch_msi_acpi_init(struct irq_domain *parent,
struct acpi_madt_msi_pic *acpi_pchmsi);
int pch_pic_acpi_init(struct irq_domain *parent,
struct acpi_madt_bio_pic *acpi_pchpic);
int find_pch_pic(u32 gsi);
void complete_irq_moving(void);

struct fwnode_handle *get_pch_msi_handle(int pci_segment);

extern struct acpi_madt_lio_pic *acpi_liointc;
Expand Down
6 changes: 3 additions & 3 deletions arch/loongarch/include/asm/kfence.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ static inline bool kfence_protect_page(unsigned long addr, bool protect)
{
pte_t *pte = virt_to_kpte(addr);

if (WARN_ON(!pte) || pte_none(*pte))
if (WARN_ON(!pte) || pte_none(ptep_get(pte)))
return false;

if (protect)
set_pte(pte, __pte(pte_val(*pte) & ~(_PAGE_VALID | _PAGE_PRESENT)));
set_pte(pte, __pte(pte_val(ptep_get(pte)) & ~(_PAGE_VALID | _PAGE_PRESENT)));
else
set_pte(pte, __pte(pte_val(*pte) | (_PAGE_VALID | _PAGE_PRESENT)));
set_pte(pte, __pte(pte_val(ptep_get(pte)) | (_PAGE_VALID | _PAGE_PRESENT)));

preempt_disable();
local_flush_tlb_one(addr);
Expand Down
Loading
Loading