Add support for LOONGARCH

Signed-off-by: Xue Liu <liuxue@loongson.cn>
This commit is contained in:
Xue Liu 2023-09-01 15:51:54 +08:00
parent 664d38b886
commit bfb113eba3
4 changed files with 119 additions and 2 deletions

View File

@ -0,0 +1,41 @@
From 2d686707df37b8752f31684db16b689637ba141d Mon Sep 17 00:00:00 2001
From: Xue Liu <liuxue@loongson.cn>
Date: Thu, 1 Dec 2022 18:37:21 +0800
Subject: [PATCH 1/3] barrier: LOONGARCH memory barriers
Implement memory barrier for LOONGARCH platforms.
Change-Id: I44f5e63e6eb3f8bf98e965a22fb86f94e727061d
Signed-off-by: Xue Liu <liuxue@loongson.cn>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16082
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
---
include/spdk/barrier.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/spdk/barrier.h b/include/spdk/barrier.h
index acae360..1ee7240 100644
--- a/include/spdk/barrier.h
+++ b/include/spdk/barrier.h
@@ -97,6 +97,15 @@ extern "C" {
#define _spdk_smp_mb() __asm volatile("lock addl $0, -128(%%esp); " ::: "memory");
#endif
+#elif defined(__loongarch__)
+
+#define _spdk_rmb() __asm volatile("dbar 0" ::: "memory")
+#define _spdk_wmb() __asm volatile("dbar 0" ::: "memory")
+#define _spdk_mb() __asm volatile("dbar 0" ::: "memory")
+#define _spdk_smp_rmb() __asm volatile("dbar 0" ::: "memory")
+#define _spdk_smp_wmb() __asm volatile("dbar 0" ::: "memory")
+#define _spdk_smp_mb() __asm volatile("dbar 0" ::: "memory")
+
#else
#define _spdk_rmb()
--
2.20.1

View File

@ -0,0 +1,34 @@
From e9a94122b8704411b79157b25c4d07580246be6c Mon Sep 17 00:00:00 2001
From: Xue Liu <liuxue@loongson.cn>
Date: Thu, 1 Dec 2022 18:38:57 +0800
Subject: [PATCH 2/3] nvme/pcie: add memory barrier for LOONGARCH
Add memory barrier for LOONGARCH in nvme_pcie_qpair_process_completions.
Signed-off-by: Xue Liu <liuxue@loongson.cn>
Change-Id: Icc992ef612a00dd18ff33f70ab8f54e8c5d5c5b7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16083
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
---
lib/nvme/nvme_pcie_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/nvme/nvme_pcie_common.c b/lib/nvme/nvme_pcie_common.c
index 0ef56cb..5fb6304 100644
--- a/lib/nvme/nvme_pcie_common.c
+++ b/lib/nvme/nvme_pcie_common.c
@@ -801,7 +801,7 @@ nvme_pcie_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_
__builtin_prefetch(&pqpair->tr[next_cpl->cid]);
}
-#ifdef __PPC64__
+#if defined(__PPC64__) || defined(__loongarch__)
/*
* This memory barrier prevents reordering of:
* - load after store from/to tr
--
2.20.1

View File

@ -0,0 +1,36 @@
From d7484395ac0fd85c91365beb4af00c6e5ea39ee6 Mon Sep 17 00:00:00 2001
From: Xue Liu <liuxue@loongson.cn>
Date: Thu, 1 Dec 2022 18:39:44 +0800
Subject: [PATCH 3/3] build: Specify the target build architecture for
LOONGARCH.
More information about LoongArch:
- https://loongson.github.io/LoongArch-Documentation/README-EN.html
Signed-off-by: Xue Liu <liuxue@loongson.cn>
Change-Id: I24852e31b5fadef3578354da2d26252014330e83
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16084
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
---
mk/spdk.common.mk | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mk/spdk.common.mk b/mk/spdk.common.mk
index da214c8..1e73776 100644
--- a/mk/spdk.common.mk
+++ b/mk/spdk.common.mk
@@ -80,6 +80,9 @@ COMMON_CFLAGS += -mcpu=$(TARGET_ARCHITECTURE)
else ifeq ($(TARGET_MACHINE),aarch64)
COMMON_CFLAGS += -march=$(TARGET_ARCHITECTURE)
COMMON_CFLAGS += -DPAGE_SIZE=$(shell getconf PAGESIZE)
+else ifneq ($(filter loongarch%,$(TARGET_MACHINE)),)
+COMMON_CFLAGS += -march=$(TARGET_ARCHITECTURE)
+COMMON_CFLAGS += -DPAGE_SIZE=$(shell getconf PAGESIZE)
else
COMMON_CFLAGS += -march=core-avx-i
endif
--
2.20.1

View File

@ -4,7 +4,7 @@
Name: spdk
Version: 21.01.1
Release: 15
Release: 16
Summary: Set of libraries and utilities for high performance user-mode storage
License: BSD and MIT
URL: http://spdk.io
@ -49,6 +49,9 @@ Patch37: 0037-scripts-nvmf_perf-check-extra_params-key-berofe-acce.patch
Patch38: 0038-nvme-rdma-Only-wait-for-the-RDMA-event-if-spdk_rdma_.patch
Patch39: 0039-Cleanup-Fix-boolean-arg-in-fio-plugin.patch
Patch40: 0040-initialized-status-variable-before-use.patch
Patch41: 0041-barrier-LOONGARCH-memory-barriers.patch
Patch42: 0042-nvme-pcie-add-memory-barrier-for-LOONGARCH.patch
Patch43: 0043-build-Specify-the-target-build-architecture-for-LOON.patch
%define package_version %{version}-%{release}
@ -63,7 +66,7 @@ Patch40: 0040-initialized-status-variable-before-use.patch
%define use_python2 0
%endif
ExclusiveArch: x86_64 aarch64
ExclusiveArch: x86_64 aarch64 loongarch64
BuildRequires: gcc gcc-c++ make
BuildRequires: dpdk-devel, numactl-devel, ncurses-devel
@ -225,6 +228,9 @@ mv doc/output/html/ %{install_docdir}
%changelog
* Fri Sep 1 2023 Xue Liu <liuxue@loongson.cn> - 21.01.1-16
- Add support for LOONGARCH.
* Sat Aug 26 2023 Weifeng Su <suweifeng1@huawei.com> - 21.01.1-15
- backport patch to fix gcc-12 warning