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

Ubuntu packaging for the SiFive kernel for the HiFive Premier P550 board #6

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

Conversation

esmil
Copy link

@esmil esmil commented Sep 10, 2024

No description provided.

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 12 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]>
- use eswin/eic7700-hifive-premier-p550.dtb as device-tree name
- use "sifive,hifive-premier-p550", "eswin,eic7700" as compatible strings

Signed-off-by: Pritesh Patel <[email protected]>
Signed-off-by: Heinrich Schuchardt <[email protected]>
With these changes Docker and Ubuntu Firewall are functional.

Signed-off-by: Pritesh Patel <[email protected]>
Signed-off-by: Heinrich Schuchardt <[email protected]>
Enabled HDMI sound related configs

Signed-off-by: Pritesh Patel <[email protected]>
Memory size will be passed through kernel command line based on
the RAM detected by U-Boot

Signed-off-by: Pritesh Patel <[email protected]>
This fixes the following section mismatch error:

  WARNING: modpost: drivers/ata/ahci_eswin: section mismatch in reference: \
    ahci_probe+0x38 (section: .text) -> eswin_reset (section: .init.text)
  ERROR: modpost: Section mismatches detected.
  Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.

Fixes: 06d67c2 ("drivers: ata: Add ESWIN sata driver")
Signed-off-by: Emil Renner Berthing <[email protected]>
When compiling with gcc version 14.0.0 20231220 (experimental)
and W=1, I've noticed the following warning:

fs/btrfs/send.c: In function 'btrfs_ioctl_send':
fs/btrfs/send.c:8208:44: warning: 'kvcalloc' sizes specified with 'sizeof'
in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
 8208 |         sctx->clone_roots = kvcalloc(sizeof(*sctx->clone_roots),
      |                                            ^

Since 'n' and 'size' arguments of 'kvcalloc()' are multiplied to
calculate the final size, their actual order doesn't affect the result
and so this is not a bug. But it's still worth to fix it.

Signed-off-by: Dmitry Antipov <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
(cherry picked from commit 6ff09b6)
Signed-off-by: Emil Renner Berthing <[email protected]>
@DarshanEI DarshanEI force-pushed the dev/kernel/hifive-premier-p550 branch from 5d4ebc3 to edceb09 Compare September 12, 2024 07:13
@esmil esmil force-pushed the hifive-premier-p550-packaging branch from fa695ac to 6230148 Compare September 24, 2024 15:23
esmil and others added 4 commits September 24, 2024 17:34
Signed-off-by: Emil Renner Berthing <[email protected]>
On riscv, it appears that all kernel modules are generated with an
excesive amount of local symbols and assembly automatic generated
symbols increasing the size of stripped .ko modules multiple times
over similar ones on other architectures. When stripping .ko on riscv,
discard these local symbols too, which should make our module sizes
somewhat more reasonable.

BugLink: https://bugs.launchpad.net/bugs/1964335

Signed-off-by: Andy Whitcroft <[email protected]>
Signed-off-by: Dimitri John Ledkov <[email protected]>
Acked-by: Andrea Righi <[email protected]>
Signed-off-by: Emil Renner Berthing <[email protected]>
This also limits the annotations to the riscv64 architecture.

Signed-off-by: Emil Renner Berthing <[email protected]>
The ESWIN EIC7700 SoC has non-coherent peripheral DMAs and handles it in
a non-standard way, so unfortunately this kernel cannot be built to
support multiple SoCs.
Hence we disable support for other platforms and enable drivers for the
EIC7700.

Signed-off-by: Emil Renner Berthing <[email protected]>
@esmil esmil force-pushed the hifive-premier-p550-packaging branch from 6230148 to e32c678 Compare September 24, 2024 15:34
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]>
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.