From 6f9ce1f156a4d597e2e447443a2655fb0b288337 Mon Sep 17 00:00:00 2001 From: Christopher Taylor Date: Sat, 9 Nov 2024 16:02:56 +0000 Subject: [PATCH] initial import --- arch/riscv/Kconfig | 19 ++++++++ drivers/infiniband/hw/hfi1/Kconfig | 38 +++++++-------- drivers/infiniband/hw/hfi1/hfi.h | 14 ++++-- drivers/infiniband/hw/qib/Makefile | 1 + drivers/infiniband/hw/qib/qib.h | 6 ++- drivers/infiniband/hw/qib/qib_wc_riscv.c | 59 ++++++++++++++++++++++++ drivers/infiniband/sw/rdmavt/Kconfig | 12 ++--- drivers/infiniband/sw/rdmavt/qp.c | 16 +++++-- drivers/infiniband/ulp/opa_vnic/Kconfig | 14 +++--- 9 files changed, 140 insertions(+), 39 deletions(-) create mode 100644 drivers/infiniband/hw/qib/qib_wc_riscv.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 62545946ecf432..c5ee2419ff6e92 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -443,6 +443,25 @@ config SMP If you don't know what to do here, say N. +config HIGHMEM + bool "High Memory Support" + depends on MMU + select KMAP_LOCAL + select KMAP_LOCAL_NON_LINEAR_PTE_ARRAY + help + The address space of ARM processors is only 4 Gigabytes large + and it has to accommodate user address space, kernel address + space as well as some memory mapped IO. That means that, if you + have a large amount of physical memory and/or IO, not all of the + memory can be "permanently mapped" by the kernel. The physical + memory that is not permanently mapped is called "high memory". + + Depending on the selected kernel/user memory split, minimum + vmalloc space and actual amount of RAM, you may not need this + option which should result in a slightly faster kernel. + + If unsure, say n. + config SCHED_MC bool "Multi-core scheduler support" depends on SMP diff --git a/drivers/infiniband/hw/hfi1/Kconfig b/drivers/infiniband/hw/hfi1/Kconfig index 14b92e12bf2920..63406f32729396 100644 --- a/drivers/infiniband/hw/hfi1/Kconfig +++ b/drivers/infiniband/hw/hfi1/Kconfig @@ -1,23 +1,23 @@ # SPDX-License-Identifier: GPL-2.0-only config INFINIBAND_HFI1 - tristate "Cornelis OPX Gen1 support" - depends on X86_64 && INFINIBAND_RDMAVT && I2C && !UML - select MMU_NOTIFIER - select CRC32 - select I2C_ALGOBIT - help - This is a low-level driver for Cornelis OPX Gen1 adapter. + tristate "Cornelis OPX Gen1 support" + depends on ( X86_64 || RISCV ) && INFINIBAND_RDMAVT && I2C && !UML + select MMU_NOTIFIER + select CRC32 + select I2C_ALGOBIT + help + This is a low-level driver for Cornelis OPX Gen1 adapter. config HFI1_DEBUG_SDMA_ORDER - bool "HFI1 SDMA Order debug" - depends on INFINIBAND_HFI1 - default n - help - This is a debug flag to test for out of order - sdma completions for unit testing + bool "HFI1 SDMA Order debug" + depends on INFINIBAND_HFI1 + default n + help + This is a debug flag to test for out of order + sdma completions for unit testing config SDMA_VERBOSITY - bool "Config SDMA Verbosity" - depends on INFINIBAND_HFI1 - default n - help - This is a configuration flag to enable verbose - SDMA debug + bool "Config SDMA Verbosity" + depends on INFINIBAND_HFI1 + default n + help + This is a configuration flag to enable verbose + SDMA debug diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h index eb38f81aeeb1ee..2095c78b37e102 100644 --- a/drivers/infiniband/hw/hfi1/hfi.h +++ b/drivers/infiniband/hw/hfi1/hfi.h @@ -1,6 +1,7 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */ /* - * Copyright(c) 2020-2023 Cornelis Networks, Inc. + * Copyright(c) 2024 Tactical Computing Labs, LLC + * Copyright(c) 2020 Cornelis Networks, Inc. * Copyright(c) 2015-2020 Intel Corporation. */ @@ -1378,6 +1379,8 @@ struct hfi1_devdata { #define PT_INVALID 3 struct tid_rb_node; +struct mmu_rb_node; +struct mmu_rb_handler; /* Private data for file operations */ struct hfi1_filedata { @@ -2175,7 +2178,11 @@ struct pci_dev *get_pci_dev(struct rvt_dev_info *rdi); */ static inline void flush_wc(void) { +#if defined(CONFIG_X86_64) asm volatile("sfence" : : : "memory"); +#elif defined(CONFIG_RISCV) + asm volatile("fence rw,rw" : : : "memory"); +#endif } void handle_eflags(struct hfi1_packet *packet); @@ -2425,7 +2432,8 @@ static inline bool hfi1_need_drop(struct hfi1_devdata *dd) int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp); #define DD_DEV_ENTRY(dd) __string(dev, dev_name(&(dd)->pcidev->dev)) -#define DD_DEV_ASSIGN(dd) __assign_str(dev) +//#define DD_DEV_ASSIGN(dd) __assign_str(dev, dev_name(&(dd)->pcidev->dev)) +#define DD_DEV_ASSIGN(dd) __string(dev, dev_name(&(dd)->pcidev->dev)) static inline void hfi1_update_ah_attr(struct ib_device *ibdev, struct rdma_ah_attr *attr) diff --git a/drivers/infiniband/hw/qib/Makefile b/drivers/infiniband/hw/qib/Makefile index 80ffab88fbca0a..33edecd1d7dc6a 100644 --- a/drivers/infiniband/hw/qib/Makefile +++ b/drivers/infiniband/hw/qib/Makefile @@ -14,4 +14,5 @@ ib_qib-$(CONFIG_PCI_MSI) += qib_iba6120.o ib_qib-$(CONFIG_X86_64) += qib_wc_x86_64.o ib_qib-$(CONFIG_PPC64) += qib_wc_ppc64.o +ib_qib-$(CONFIG_RISCV) += qib_wc_riscv.o ib_qib-$(CONFIG_DEBUG_FS) += qib_debugfs.o diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index 8ee4edd7883c17..f788a83604eeba 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -1,6 +1,7 @@ #ifndef _QIB_KERNEL_H #define _QIB_KERNEL_H /* + * Copyright(c) 2024 Tactical Computing Labs, LLC * Copyright (c) 2012 - 2017 Intel Corporation. All rights reserved. * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. @@ -321,7 +322,7 @@ struct qib_verbs_txreq { * These 7 values (SDR, DDR, and QDR may be ORed for auto-speed * negotiation) are used for the 3rd argument to path_f_set_ib_cfg * with cmd QIB_IB_CFG_SPD_ENB, by direct calls or via sysfs. They - * are also the possible values for qib_link_speed_enabled and active + * are also the the possible values for qib_link_speed_enabled and active * The values were chosen to match values used within the IB spec. */ #define QIB_IB_SDR 1 @@ -1359,6 +1360,7 @@ static inline u32 qib_get_rcvhdrtail(const struct qib_ctxtdata *rcd) * sysfs interface. */ +extern const char ib_qib_version[]; extern const struct attribute_group qib_attr_group; extern const struct attribute_group *qib_attr_port_groups[]; @@ -1402,6 +1404,8 @@ static inline void qib_flush_wc(void) { #if defined(CONFIG_X86_64) asm volatile("sfence" : : : "memory"); +#elif defined(CONFIG_RISCV) + asm volatile("fence rw,rw" : : : "memory"); #else wmb(); /* no reorder around wc flush */ #endif diff --git a/drivers/infiniband/hw/qib/qib_wc_riscv.c b/drivers/infiniband/hw/qib/qib_wc_riscv.c new file mode 100644 index 00000000000000..44e2b4a5a4d676 --- /dev/null +++ b/drivers/infiniband/hw/qib/qib_wc_riscv.c @@ -0,0 +1,59 @@ +/* + * Copyright(c) 2024 Tactical Computing Labs, LLC + * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * This file is conditionally built on RISCV only. It is dervied from the + * PowerPC version. + */ + +#include "qib.h" + +/** + * qib_enable_wc - enable write combining for MMIO writes to the device + * @dd: qlogic_ib device + * + * Nothing to do on RISCV, so just return without error. + */ +int qib_enable_wc(struct qib_devdata *dd) +{ + return 0; +} + +/** + * qib_unordered_wc - indicate whether write combining is unordered + * + */ +int qib_unordered_wc(void) +{ + return 1; +} diff --git a/drivers/infiniband/sw/rdmavt/Kconfig b/drivers/infiniband/sw/rdmavt/Kconfig index 0df48b3a6b56c5..706207df0cc4ba 100644 --- a/drivers/infiniband/sw/rdmavt/Kconfig +++ b/drivers/infiniband/sw/rdmavt/Kconfig @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only config INFINIBAND_RDMAVT - tristate "RDMA verbs transport library" - depends on INFINIBAND_VIRT_DMA - depends on X86_64 - depends on PCI - help - This is a common software verbs provider for RDMA networks. + tristate "RDMA verbs transport library" + depends on INFINIBAND_VIRT_DMA + depends on ( X86_64 || RISCV ) + depends on PCI + help + This is a common software verbs provider for RDMA networks. diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c index e6203e26cc064f..aaa91cf291af24 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c @@ -1,5 +1,7 @@ -// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause /* + * Copyright(c) 2024 Tactical Computing Labs, LLC + * Copyright(c) 2024 Cornelis Networks, Inc. * Copyright(c) 2016 - 2020 Intel Corporation. */ @@ -85,19 +87,25 @@ EXPORT_SYMBOL(ib_rvt_state_ops); static int rvt_wss_llc_size(void) { /* assume that the boot CPU value is universal for all CPUs */ +#if defined(CONFIG_X86_64) return boot_cpu_data.x86_cache_size; +#elif defined(CONFIG_RISCV) + return 64; +#endif } /* platform specific: cacheless copy */ static void cacheless_memcpy(void *dst, void *src, size_t n) { +#if defined(CONFIG_X86_64) /* * Use the only available X64 cacheless copy. Add a __user cast * to quiet sparse. The src agument is already in the kernel so * there are no security issues. The extra fault recovery machinery * is not invoked. */ - __copy_user_nocache(dst, (void __user *)src, n); + __copy_user_nocache(dst, (void __user *)src, n, 0); +#endif } void rvt_wss_exit(struct rvt_dev_info *rdi) @@ -464,6 +472,8 @@ void rvt_qp_exit(struct rvt_dev_info *rdi) if (qps_inuse) rvt_pr_err(rdi, "QP memory leak! %u still in use\n", qps_inuse); + if (!rdi->qp_dev) + return; kfree(rdi->qp_dev->qp_table); free_qpn_table(&rdi->qp_dev->qpn_table); @@ -2038,7 +2048,7 @@ static int rvt_post_one_wr(struct rvt_qp *qp, wqe = rvt_get_swqe_ptr(qp, qp->s_head); /* cplen has length from above */ - memcpy(&wqe->ud_wr, wr, cplen); + memcpy(&wqe->wr, wr, cplen); wqe->length = 0; j = 0; diff --git a/drivers/infiniband/ulp/opa_vnic/Kconfig b/drivers/infiniband/ulp/opa_vnic/Kconfig index 4d43d055fa8e56..f91178007b4b9d 100644 --- a/drivers/infiniband/ulp/opa_vnic/Kconfig +++ b/drivers/infiniband/ulp/opa_vnic/Kconfig @@ -1,9 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only config INFINIBAND_OPA_VNIC - tristate "Cornelis OPX VNIC support" - depends on X86_64 && INFINIBAND - help - This is Omni-Path Express (OPX) Virtual Network Interface Controller (VNIC) - driver for Ethernet over Omni-Path feature. It implements the HW - independent VNIC functionality. It interfaces with Linux stack for - data path and IB MAD for the control path. + tristate "Cornelis OPX VNIC support" + depends on ( X86_64 || RISCV) && INFINIBAND + help + This is Omni-Path Express (OPX) Virtual Network Interface Controller (VNIC) + driver for Ethernet over Omni-Path feature. It implements the HW + independent VNIC functionality. It interfaces with Linux stack for + data path and IB MAD for the control path.