Skip to content

Commit 627d858

Browse files
committed
Merge tag 'loongarch-fixes-6.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch fixes from Huacai Chen: "Some trivial bug fixes for v6.4-rc7" * tag 'loongarch-fixes-6.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: Fix debugfs_create_dir() error checking LoongArch: Avoid uninitialized alignment_mask LoongArch: Fix perf event id calculation LoongArch: Fix the write_fcsr() macro LoongArch: Let pmd_present() return true when splitting pmd
2 parents 0e30695 + 41efbb6 commit 627d858

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

arch/loongarch/include/asm/loongarch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ __BUILD_CSR_OP(tlbidx)
14961496
#define write_fcsr(dest, val) \
14971497
do { \
14981498
__asm__ __volatile__( \
1499-
" movgr2fcsr %0, "__stringify(dest)" \n" \
1499+
" movgr2fcsr "__stringify(dest)", %0 \n" \
15001500
: : "r" (val)); \
15011501
} while (0)
15021502

arch/loongarch/include/asm/pgtable-bits.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
#define _PAGE_PFN_SHIFT 12
2323
#define _PAGE_SWP_EXCLUSIVE_SHIFT 23
2424
#define _PAGE_PFN_END_SHIFT 48
25+
#define _PAGE_PRESENT_INVALID_SHIFT 60
2526
#define _PAGE_NO_READ_SHIFT 61
2627
#define _PAGE_NO_EXEC_SHIFT 62
2728
#define _PAGE_RPLV_SHIFT 63
2829

2930
/* Used by software */
3031
#define _PAGE_PRESENT (_ULCAST_(1) << _PAGE_PRESENT_SHIFT)
32+
#define _PAGE_PRESENT_INVALID (_ULCAST_(1) << _PAGE_PRESENT_INVALID_SHIFT)
3133
#define _PAGE_WRITE (_ULCAST_(1) << _PAGE_WRITE_SHIFT)
3234
#define _PAGE_ACCESSED (_ULCAST_(1) << _PAGE_ACCESSED_SHIFT)
3335
#define _PAGE_MODIFIED (_ULCAST_(1) << _PAGE_MODIFIED_SHIFT)

arch/loongarch/include/asm/pgtable.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static inline int pmd_bad(pmd_t pmd)
213213
static inline int pmd_present(pmd_t pmd)
214214
{
215215
if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
216-
return !!(pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE));
216+
return !!(pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PRESENT_INVALID));
217217

218218
return pmd_val(pmd) != (unsigned long)invalid_pte_table;
219219
}
@@ -558,6 +558,7 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
558558

559559
static inline pmd_t pmd_mkinvalid(pmd_t pmd)
560560
{
561+
pmd_val(pmd) |= _PAGE_PRESENT_INVALID;
561562
pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID | _PAGE_DIRTY | _PAGE_PROTNONE);
562563

563564
return pmd;

arch/loongarch/kernel/hw_breakpoint.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,
396396

397397
if (hw->ctrl.type != LOONGARCH_BREAKPOINT_EXECUTE)
398398
alignment_mask = 0x7;
399+
else
400+
alignment_mask = 0x3;
399401
offset = hw->address & alignment_mask;
400402

401403
hw->address &= ~alignment_mask;

arch/loongarch/kernel/perf_event.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static void loongarch_pmu_enable_event(struct hw_perf_event *evt, int idx)
271271
WARN_ON(idx < 0 || idx >= loongarch_pmu.num_counters);
272272

273273
/* Make sure interrupt enabled. */
274-
cpuc->saved_ctrl[idx] = M_PERFCTL_EVENT(evt->event_base & 0xff) |
274+
cpuc->saved_ctrl[idx] = M_PERFCTL_EVENT(evt->event_base) |
275275
(evt->config_base & M_PERFCTL_CONFIG_MASK) | CSR_PERFCTRL_IE;
276276

277277
cpu = (event->cpu >= 0) ? event->cpu : smp_processor_id();
@@ -594,7 +594,7 @@ static struct pmu pmu = {
594594

595595
static unsigned int loongarch_pmu_perf_event_encode(const struct loongarch_perf_event *pev)
596596
{
597-
return (pev->event_id & 0xff);
597+
return M_PERFCTL_EVENT(pev->event_id);
598598
}
599599

600600
static const struct loongarch_perf_event *loongarch_pmu_map_general_event(int idx)
@@ -849,7 +849,7 @@ static void resume_local_counters(void)
849849

850850
static const struct loongarch_perf_event *loongarch_pmu_map_raw_event(u64 config)
851851
{
852-
raw_event.event_id = config & 0xff;
852+
raw_event.event_id = M_PERFCTL_EVENT(config);
853853

854854
return &raw_event;
855855
}

arch/loongarch/kernel/unaligned.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static int __init debugfs_unaligned(void)
485485
struct dentry *d;
486486

487487
d = debugfs_create_dir("loongarch", NULL);
488-
if (!d)
488+
if (IS_ERR_OR_NULL(d))
489489
return -ENOMEM;
490490

491491
debugfs_create_u32("unaligned_instructions_user",

0 commit comments

Comments
 (0)