Giter Club home page Giter Club logo

sifive-l2pf-driver's Introduction

This is an example driver code for l2 prefetcher of StarFive jh7110 SoC (sifive U74 core inside) and is tested on the StarFive VisionFive2 SBC.

To use the driver, you should

  1. Add device description to dts file.
$ cd linux
$ vim arch/riscv/boot/dts/starfive/jh7110.dtsi
soc: soc {
				......
                cachectrl: cache-controller@2010000 {
				......
                };

+               l2pf0: l2pf0@2032000 {
+                       compatible = "sifive,l2pf";
+                       reg = <0x0 0x2032000 0x0 0x2000>;
+               };
+
+               l2pf1: l2pf1@2034000 {
+                       compatible = "sifive,l2pf";
+                       reg = <0x0 0x2034000 0x0 0x2000>;
+               };
+
+               l2pf2: l2pf2@2036000 {
+                       compatible = "sifive,l2pf";
+                       reg = <0x0 0x2036000 0x0 0x2000>;
+               };
+
+               l2pf3: l2pf3@2038000 {
+                       compatible = "sifive,l2pf";
+                       reg = <0x0 0x2038000 0x0 0x2000>;
+               };
  1. Add the CPUHP_L2PREFETCH_PREPARE flag to cpuhotplug.h.
$ vim include/linux/cpuhotplug.h
        CPUHP_TOPOLOGY_PREPARE,
+       CPUHP_L2PREFETCH_PREPARE,
        CPUHP_NET_IUCV_PREPARE,
  1. Copy the sifive_l2_prefetcher.c in this repo to the driver directory.
$ cp sifive_l2_prefetcher.c $(YOUR_LINUX_DIR)/drivers/soc/sifive/
  1. Add the sifive_l2_prefetcher.o to the Makefile.
$ vim $(YOUR_LINUX_DIR)/drivers/soc/sifive/Makefile
	# SPDX-License-Identifier: GPL-2.0

	obj-$(CONFIG_SIFIVE_L2)	+= sifive_l2_cache.o
+	obj-$(CONFIG_SIFIVE_L2)	+= sifive_l2_prefetcher.o
  1. Compile the kernel and replace the vmlinuz file.

  2. Do read/write tests of the parameters of the l2 prefetcher.

# cat /sys/devices/system/cpu/cpu0/l2_prefetch/prefetch_enable 
1
# echo "0" > /sys/devices/system/cpu/cpu0/l2_prefetch/prefetch_enable 
# cat /sys/devices/system/cpu/cpu0/l2_prefetch/prefetch_enable 
0
# cat /sys/devices/system/cpu/cpu1/l2_prefetch/prefetch_enable 
1

There are some references you can refer to if you have any troubles.

Kernel compile: https://gitee.com/tinylab/riscv-linux/blob/master/articles/20230227-vf2-kernel-compile.md ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.