From nobody Tue Dec 2 00:44:26 2025 Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EB052D7DEC for ; Tue, 25 Nov 2025 08:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.224 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764057951; cv=none; b=j6XlxDiBxC8+fRrGjT6HB6HqHoJEvO+i3FoyzSErnAAxs0QHyUiXkz+WC0qUhr/oMS6WnfyiG+UIXRV+iTBFmoA3sxx1eKoltq1HXh9Nc+Z5X5IA6Ha5gmFzP9UyA1FUf3G6L1wGInLEfi5FDct/xastX3Gla95M8TWgWiHSYp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764057951; c=relaxed/simple; bh=EnYX2UbL4GddxkZu9waYCL7vrgbYwTKSekAJgSe9nr8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D60D9D3EC59cNzoKlf8//CWPsZxlshm8zpAlXRvSFaPGbBf01Ey5V1X8VGRMNE2SIyYZuX1j7XSUanHUQ3l9aOY5ChxNTmCO3u6NS8Gp/xTMabjYIXWMPJs1QEAg7EM6Mr5tagkmgYmjMIKdRO1Dsv4yEyqIi5xD7yV6VMkJj7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=DoBGe1S1; arc=none smtp.client-ip=113.46.200.224 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="DoBGe1S1" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=FIhvSaeXNVcgqaB/0/kSz3ZRqQlMg/6LhK/Kbe7gdXA=; b=DoBGe1S1EeQpw8EMjWENPNfAJYc4TlyAaXdEboG+ccEeiPuSFWR30xsQ7Yyc9niq5iykCpf3v hzSG88BluTdFACffiKDvfr1+kXSKAYyDGfIZtEt+wBDdSyTGGLBG7wbo4PvzHLhjvZT1mRbZHx0 wSFjxCcisZQDFOyN6btCvi0= Received: from mail.maildlp.com (unknown [172.19.88.234]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4dFwF95BPzz1cyrt; Tue, 25 Nov 2025 16:03:57 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 6912D1402C4; Tue, 25 Nov 2025 16:05:45 +0800 (CST) Received: from kwepemn100008.china.huawei.com (7.202.194.111) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 25 Nov 2025 16:05:44 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemn100008.china.huawei.com (7.202.194.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Tue, 25 Nov 2025 16:05:44 +0800 From: Yushan Wang To: , , , , , CC: , , Subject: [RFC PATCH 3/3] Documentation: soc cache: Add documentation to HiSilicon SoC cache Date: Tue, 25 Nov 2025 16:05:42 +0800 Message-ID: <20251125080542.3721829-4-wangyushan12@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20251125080542.3721829-1-wangyushan12@huawei.com> References: <20251125080542.3721829-1-wangyushan12@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemn100008.china.huawei.com (7.202.194.111) Content-Type: text/plain; charset="utf-8" Add necessary documentation to HiSilicon SoC cache for reference. Signed-off-by: Yushan Wang --- Documentation/driver-api/hisi-soc-cache.rst | 62 +++++++++++++++++++++ Documentation/driver-api/index.rst | 1 + 2 files changed, 63 insertions(+) create mode 100644 Documentation/driver-api/hisi-soc-cache.rst diff --git a/Documentation/driver-api/hisi-soc-cache.rst b/Documentation/dr= iver-api/hisi-soc-cache.rst new file mode 100644 index 000000000000..a0da7ff20e44 --- /dev/null +++ b/Documentation/driver-api/hisi-soc-cache.rst @@ -0,0 +1,62 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +HiSilicon SoC Cache Driver +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +Introduction +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +HiSilicon SoC cache provides the capabilities of preventing given range of +memory from being evicted from L3 cache. The driver exports the lockdown A= PI to +userspace, allowing allocation of memory that is guranteed to be placed in= L3 +cache, thus decreasing average memory access latency. + +Usage +=3D=3D=3D=3D=3D + +Kernel built with CONFIG_HISI_SOC_CACHE on will have the device file at +`/dev/hisi_l3c`, cache operations can be performed through it. + +mmap(): +------- + +This interface can be used to allocate memory that is guranteed to not be +evicted out of HiSilicon L3 cache. Newly allocated memory will be prefetch= ed to +L3 cache automatically. + +Users should set `PROT_READ` or `PROT_WRITE` to enable read/write to the m= emory +region. Once mmap call succeeds, read and write can be applied to the memo= ry +region indicated by the returned pointer. + +Calling `munmap()` to the pointer can be used to unlock the memory regions. + +Restrictions of the cache lockdown are listed below: + - Only limited number of memory regions are supported, the exact number = is + reported by firmware. + - Sum of the sizes of locked memory regions should be less than 70% of t= he + total size of cache instance. + - Lock/unlock can only be performed during allocation/deallocation, lock= ing + existing memory is not supported yet. + +ioctl(): +-------- + +This interface provides useful information of HiSilicon L3 cache. + +HISI_L3C_LOCK_INFO + - struct hisi_l3c_lock_info (read) + + Gets detailed information of L3 cache lock restrictions. + +This ioctl call returns the detailed information of HiSilicon L3 cache lock +restriction. Information will be presented in the form of:: + + struct hisi_l3c_lock_info { + unsigned int lock_region_num; + size_t lock_size; + bool address_alignment; + size_t max_lock_size; + size_t min_lock_size; + }; + +User may perform a query before issueing cache lock to check for available +resource. diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/= index.rst index 3e2a270bd828..a4be1fc67230 100644 --- a/Documentation/driver-api/index.rst +++ b/Documentation/driver-api/index.rst @@ -94,6 +94,7 @@ Subsystem-specific APIs aperture generic-counter gpio/index + hisi-soc-cache hsi hte/index i2c --=20 2.33.0