Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eswin: harmonize device-tree #5

Open
wants to merge 37 commits into
base: dev/kernel/hifive-premier-p550
Choose a base branch
from

Conversation

xypron
Copy link

@xypron xypron commented Aug 26, 2024

We should use a device-tree name that is upstreamable.

  • use eswin/eic7700-hifive-premier-p550.dtb as device-tree name
  • use "SiFive HiFive Premier P550" as model property
  • use "sifive,hifive-premier-p550", "eswin,eic7700" as compatible strings

linmineswincomputing and others added 30 commits July 31, 2024 13:51
dts, dtsi and include files for HiFive Premier P550 boards
based on EIC7700 SoC.

Signed-off-by: linmin <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: linmin <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: huangyifeng <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
- Added wfe and iomb functions for riscv
- Added memory port to system port and system port to memory port
  conversion macros to access uncached memory through system port
- Modified pte_pfn and pfn_pte functions
  To access uncache memory, we need to remap physical address to system
  port address. System port pfn address will be stored in pte if uncached
  bit is set.

Signed-off-by: linmin <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Add arch_dma_set_uncached and arch_dma_clear_uncached

Signed-off-by: linmin <[email protected]>
Signed-off-by: Pritesh Patel <[email protected]>
Signed-off-by: linmin <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Clearing interrupt bits from interrupt handler because interrupt mode of
smmu is oneshot but plic only support high level mode

Signed-off-by: linmin <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: linmin <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
The EIC7700 has non-coherent DMAs but predate the standard RISC-V
Zicbom extension, so instead we need to use this cache controller
for non-standard cache management operations

Reference:
torvalds/linux@0d5701d

Signed-off-by: Emil Renner Berthing <[email protected]>
Signed-off-by: Conor Dooley <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Enabled all available cache ways to be used as cache.
This change is required for CPU performance improvement.

Out of reset, only way 0 is enabled and the disabled ways
are addressable in L2-LIM(Loosely Integrated Memory).

Signed-off-by: Pritesh Patel <[email protected]>
- Removed cfgr clock as aon dma has separate cfg clk register bit
  while dma0 havn't. Since dma cfg clk is default on we do not
  need to control it
- Add arst and prst reset control
- Power on tbu and configure sid from hw init

Signed-off-by: xuxiang <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: liangshuang <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: huangyifeng <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: ningyu <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: luyulin <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: Yang Wei <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: fanglifei <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: xuxiang <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: ningyu <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: luyulin <[email protected]>
Signed-off-by: Pritesh Patel <[email protected]>
Add custom ES8328 audio codec driver for hifive premier p550 board
Add eswin i2s driver

Signed-off-by: denglei <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: xuxiang <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: Pritesh Patel <[email protected]>
Signed-off-by: luyulin <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
Signed-off-by: luyulin <[email protected]>
Signed-off-by: Darshan Prajapati <[email protected]>
Signed-off-by: Pinkesh Vaghela <[email protected]>
HENVCFG register is not present in EIC7700 SOC. So disabled writing
this register

Signed-off-by: Pritesh Patel <[email protected]>
Signed-off-by: Yang Wei <[email protected]>
Signed-off-by: Pritesh Patel <[email protected]>
Signed-off-by: huangyifeng <[email protected]>
Signed-off-by: Pritesh Patel <[email protected]>
The SiFive Performance P550 core features an out-of-order
microarchitecture which exposes the same PMU events as Bullet,
plus events for UTLB hits and PTE cache misses/hits.

Signed-off-by: Eric Lin <[email protected]>
Co-developed-by: Samuel Holland <[email protected]>
Signed-off-by: Samuel Holland <[email protected]>
Signed-off-by: Icenowy Zheng <[email protected]>
avpatel and others added 7 commits August 23, 2024 13:33
We add SBI debug console extension related defines/enum to the
asm/sbi.h header.

Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Andrew Jones <[email protected]>
Signed-off-by: Anup Patel <[email protected]>
Let us provide SBI debug console helper routines which can be
shared by serial/earlycon-riscv-sbi.c and hvc/hvc_riscv_sbi.c.

Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Andrew Jones <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Palmer Dabbelt <[email protected]>
We extend the existing RISC-V SBI earlycon support to use the new
RISC-V SBI debug console extension.

Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Andrew Jones <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Palmer Dabbelt <[email protected]>
Removed 1.5GHz to 1.8GHz cpu freq from opp-table as the max
supported freq for CPU is  1.4GHz

Signed-off-by: Pinkesh Vaghela <[email protected]>
Updated kernel command line
  - Removed stale command lines
  - Moved serial console configs to extlinux conf file

Signed-off-by: Pritesh Patel <[email protected]>
We should use a device-tree name that is upstreamable.

* use eswin/eic7700-hifive-premier-p550.dtb as device-tree name
* use "SiFive HiFive Premier P550" as model property
* use  "sifive,hifive-premier-p550", "eswin,eic7700" as compatible strings

Signed-off-by: Heinrich Schuchardt <[email protected]>
@xypron
Copy link
Author

xypron commented Aug 26, 2024

This is the corresponding U-Boot pull request: eswincomputing/u-boot#23

@xypron
Copy link
Author

xypron commented Aug 26, 2024

Cf. eswincomputing/linux-stable#6

@DarshanEI DarshanEI force-pushed the dev/kernel/hifive-premier-p550 branch from 5d4ebc3 to edceb09 Compare September 12, 2024 07:13
Pritesh201192 pushed a commit that referenced this pull request Jan 9, 2025
syzbot reports that a recent fix causes nesting issues between the (now)
raw timeoutlock and the eventfd locking:

=============================
[ BUG: Invalid wait context ]
6.13.0-rc4-00080-g9828a4c0901f riscvarchive#29 Not tainted
-----------------------------
kworker/u32:0/68094 is trying to lock:
ffff000014d7a520 (&ctx->wqh#2){..-.}-{3:3}, at: eventfd_signal_mask+0x64/0x180
other info that might help us debug this:
context-{5:5}
6 locks held by kworker/u32:0/68094:
 #0: ffff0000c1d98148 ((wq_completion)iou_exit){+.+.}-{0:0}, at: process_one_work+0x4e8/0xfc0
 #1: ffff80008d927c78 ((work_completion)(&ctx->exit_work)){+.+.}-{0:0}, at: process_one_work+0x53c/0xfc0
 #2: ffff0000c59bc3d8 (&ctx->completion_lock){+.+.}-{3:3}, at: io_kill_timeouts+0x40/0x180
 #3: ffff0000c59bc358 (&ctx->timeout_lock){-.-.}-{2:2}, at: io_kill_timeouts+0x48/0x180
 #4: ffff800085127aa0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x8/0x38
 #5: ffff800085127aa0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x8/0x38
stack backtrace:
CPU: 7 UID: 0 PID: 68094 Comm: kworker/u32:0 Not tainted 6.13.0-rc4-00080-g9828a4c0901f riscvarchive#29
Hardware name: linux,dummy-virt (DT)
Workqueue: iou_exit io_ring_exit_work
Call trace:
 show_stack+0x1c/0x30 (C)
 __dump_stack+0x24/0x30
 dump_stack_lvl+0x60/0x80
 dump_stack+0x14/0x20
 __lock_acquire+0x19f8/0x60c8
 lock_acquire+0x1a4/0x540
 _raw_spin_lock_irqsave+0x90/0xd0
 eventfd_signal_mask+0x64/0x180
 io_eventfd_signal+0x64/0x108
 io_req_local_work_add+0x294/0x430
 __io_req_task_work_add+0x1c0/0x270
 io_kill_timeout+0x1f0/0x288
 io_kill_timeouts+0xd4/0x180
 io_uring_try_cancel_requests+0x2e8/0x388
 io_ring_exit_work+0x150/0x550
 process_one_work+0x5e8/0xfc0
 worker_thread+0x7ec/0xc80
 kthread+0x24c/0x300
 ret_from_fork+0x10/0x20

because after the preempt-rt fix for the timeout lock nesting inside
the io-wq lock, we now have the eventfd spinlock nesting inside the
raw timeout spinlock.

Rather than play whack-a-mole with other nesting on the timeout lock,
split the deletion and killing of timeouts so queueing the task_work
for the timeout cancelations can get done outside of the timeout lock.

Reported-by: [email protected]
Fixes: 020b40f ("io_uring: make ctx->timeout_lock a raw spinlock")
Signed-off-by: Jens Axboe <[email protected]>
Pritesh201192 pushed a commit that referenced this pull request Jan 9, 2025
…le_direct_reclaim()

The task sometimes continues looping in throttle_direct_reclaim() because
allow_direct_reclaim(pgdat) keeps returning false.  

 #0 [ffff80002cb6f8d0] __switch_to at ffff8000080095ac
 #1 [ffff80002cb6f900] __schedule at ffff800008abbd1c
 #2 [ffff80002cb6f990] schedule at ffff800008abc50c
 #3 [ffff80002cb6f9b0] throttle_direct_reclaim at ffff800008273550
 #4 [ffff80002cb6fa20] try_to_free_pages at ffff800008277b68
 #5 [ffff80002cb6fae0] __alloc_pages_nodemask at ffff8000082c4660
 #6 [ffff80002cb6fc50] alloc_pages_vma at ffff8000082e4a98
 #7 [ffff80002cb6fca0] do_anonymous_page at ffff80000829f5a8
 #8 [ffff80002cb6fce0] __handle_mm_fault at ffff8000082a5974
 #9 [ffff80002cb6fd90] handle_mm_fault at ffff8000082a5bd4

At this point, the pgdat contains the following two zones:

        NODE: 4  ZONE: 0  ADDR: ffff00817fffe540  NAME: "DMA32"
          SIZE: 20480  MIN/LOW/HIGH: 11/28/45
          VM_STAT:
                NR_FREE_PAGES: 359
        NR_ZONE_INACTIVE_ANON: 18813
          NR_ZONE_ACTIVE_ANON: 0
        NR_ZONE_INACTIVE_FILE: 50
          NR_ZONE_ACTIVE_FILE: 0
          NR_ZONE_UNEVICTABLE: 0
        NR_ZONE_WRITE_PENDING: 0
                     NR_MLOCK: 0
                    NR_BOUNCE: 0
                   NR_ZSPAGES: 0
            NR_FREE_CMA_PAGES: 0

        NODE: 4  ZONE: 1  ADDR: ffff00817fffec00  NAME: "Normal"
          SIZE: 8454144  PRESENT: 98304  MIN/LOW/HIGH: 68/166/264
          VM_STAT:
                NR_FREE_PAGES: 146
        NR_ZONE_INACTIVE_ANON: 94668
          NR_ZONE_ACTIVE_ANON: 3
        NR_ZONE_INACTIVE_FILE: 735
          NR_ZONE_ACTIVE_FILE: 78
          NR_ZONE_UNEVICTABLE: 0
        NR_ZONE_WRITE_PENDING: 0
                     NR_MLOCK: 0
                    NR_BOUNCE: 0
                   NR_ZSPAGES: 0
            NR_FREE_CMA_PAGES: 0

In allow_direct_reclaim(), while processing ZONE_DMA32, the sum of
inactive/active file-backed pages calculated in zone_reclaimable_pages()
based on the result of zone_page_state_snapshot() is zero.  

Additionally, since this system lacks swap, the calculation of inactive/
active anonymous pages is skipped.

        crash> p nr_swap_pages
        nr_swap_pages = $1937 = {
          counter = 0
        }

As a result, ZONE_DMA32 is deemed unreclaimable and skipped, moving on to
the processing of the next zone, ZONE_NORMAL, despite ZONE_DMA32 having
free pages significantly exceeding the high watermark.

The problem is that the pgdat->kswapd_failures hasn't been incremented.

        crash> px ((struct pglist_data *) 0xffff00817fffe540)->kswapd_failures
        $1935 = 0x0

This is because the node deemed balanced.  The node balancing logic in
balance_pgdat() evaluates all zones collectively.  If one or more zones
(e.g., ZONE_DMA32) have enough free pages to meet their watermarks, the
entire node is deemed balanced.  This causes balance_pgdat() to exit early
before incrementing the kswapd_failures, as it considers the overall
memory state acceptable, even though some zones (like ZONE_NORMAL) remain
under significant pressure.


The patch ensures that zone_reclaimable_pages() includes free pages
(NR_FREE_PAGES) in its calculation when no other reclaimable pages are
available (e.g., file-backed or anonymous pages).  This change prevents
zones like ZONE_DMA32, which have sufficient free pages, from being
mistakenly deemed unreclaimable.  By doing so, the patch ensures proper
node balancing, avoids masking pressure on other zones like ZONE_NORMAL,
and prevents infinite loops in throttle_direct_reclaim() caused by
allow_direct_reclaim(pgdat) repeatedly returning false.


The kernel hangs due to a task stuck in throttle_direct_reclaim(), caused
by a node being incorrectly deemed balanced despite pressure in certain
zones, such as ZONE_NORMAL.  This issue arises from
zone_reclaimable_pages() returning 0 for zones without reclaimable file-
backed or anonymous pages, causing zones like ZONE_DMA32 with sufficient
free pages to be skipped.

The lack of swap or reclaimable pages results in ZONE_DMA32 being ignored
during reclaim, masking pressure in other zones.  Consequently,
pgdat->kswapd_failures remains 0 in balance_pgdat(), preventing fallback
mechanisms in allow_direct_reclaim() from being triggered, leading to an
infinite loop in throttle_direct_reclaim().

This patch modifies zone_reclaimable_pages() to account for free pages
(NR_FREE_PAGES) when no other reclaimable pages exist.  This ensures zones
with sufficient free pages are not skipped, enabling proper balancing and
reclaim behavior.

[[email protected]: coding-style cleanups]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 5a1c84b ("mm: remove reclaim and compaction retry approximations")
Signed-off-by: Seiji Nishikawa <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Pritesh201192 pushed a commit that referenced this pull request Jan 9, 2025
…nt message

Address a bug in the kernel that triggers a "sleeping function called from
invalid context" warning when /sys/kernel/debug/kmemleak is printed under
specific conditions:
- CONFIG_PREEMPT_RT=y
- Set SELinux as the LSM for the system
- Set kptr_restrict to 1
- kmemleak buffer contains at least one item

BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 136, name: cat
preempt_count: 1, expected: 0
RCU nest depth: 2, expected: 2
6 locks held by cat/136:
 #0: ffff32e64bcbf950 (&p->lock){+.+.}-{3:3}, at: seq_read_iter+0xb8/0xe30
 #1: ffffafe6aaa9dea0 (scan_mutex){+.+.}-{3:3}, at: kmemleak_seq_start+0x34/0x128
 #3: ffff32e6546b1cd0 (&object->lock){....}-{2:2}, at: kmemleak_seq_show+0x3c/0x1e0
 #4: ffffafe6aa8d8560 (rcu_read_lock){....}-{1:2}, at: has_ns_capability_noaudit+0x8/0x1b0
 #5: ffffafe6aabbc0f8 (notif_lock){+.+.}-{2:2}, at: avc_compute_av+0xc4/0x3d0
irq event stamp: 136660
hardirqs last  enabled at (136659): [<ffffafe6a80fd7a0>] _raw_spin_unlock_irqrestore+0xa8/0xd8
hardirqs last disabled at (136660): [<ffffafe6a80fd85c>] _raw_spin_lock_irqsave+0x8c/0xb0
softirqs last  enabled at (0): [<ffffafe6a5d50b28>] copy_process+0x11d8/0x3df8
softirqs last disabled at (0): [<0000000000000000>] 0x0
Preemption disabled at:
[<ffffafe6a6598a4c>] kmemleak_seq_show+0x3c/0x1e0
CPU: 1 UID: 0 PID: 136 Comm: cat Tainted: G            E      6.11.0-rt7+ riscvarchive#34
Tainted: [E]=UNSIGNED_MODULE
Hardware name: linux,dummy-virt (DT)
Call trace:
 dump_backtrace+0xa0/0x128
 show_stack+0x1c/0x30
 dump_stack_lvl+0xe8/0x198
 dump_stack+0x18/0x20
 rt_spin_lock+0x8c/0x1a8
 avc_perm_nonode+0xa0/0x150
 cred_has_capability.isra.0+0x118/0x218
 selinux_capable+0x50/0x80
 security_capable+0x7c/0xd0
 has_ns_capability_noaudit+0x94/0x1b0
 has_capability_noaudit+0x20/0x30
 restricted_pointer+0x21c/0x4b0
 pointer+0x298/0x760
 vsnprintf+0x330/0xf70
 seq_printf+0x178/0x218
 print_unreferenced+0x1a4/0x2d0
 kmemleak_seq_show+0xd0/0x1e0
 seq_read_iter+0x354/0xe30
 seq_read+0x250/0x378
 full_proxy_read+0xd8/0x148
 vfs_read+0x190/0x918
 ksys_read+0xf0/0x1e0
 __arm64_sys_read+0x70/0xa8
 invoke_syscall.constprop.0+0xd4/0x1d8
 el0_svc+0x50/0x158
 el0t_64_sync+0x17c/0x180

%pS and %pK, in the same back trace line, are redundant, and %pS can void
%pK service in certain contexts.

%pS alone already provides the necessary information, and if it cannot
resolve the symbol, it falls back to printing the raw address voiding
the original intent behind the %pK.

Additionally, %pK requires a privilege check CAP_SYSLOG enforced through
the LSM, which can trigger a "sleeping function called from invalid
context" warning under RT_PREEMPT kernels when the check occurs in an
atomic context. This issue may also affect other LSMs.

This change avoids the unnecessary privilege check and resolves the
sleeping function warning without any loss of information.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 3a6f33d ("mm/kmemleak: use %pK to display kernel pointers in backtrace")
Signed-off-by: Alessandro Carminati <[email protected]>
Acked-by: Sebastian Andrzej Siewior <[email protected]>
Acked-by: Catalin Marinas <[email protected]>
Cc: Clément Léger <[email protected]>
Cc: Alessandro Carminati <[email protected]>
Cc: Eric Chanudet <[email protected]>
Cc: Gabriele Paoloni <[email protected]>
Cc: Juri Lelli <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.