Skip to content

Commit

Permalink
[bluefield] Fix BF drivers compilation under 5.10 Kernel.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandrivantsiv committed Dec 7, 2021
1 parent 7d6e8a5 commit 6eb5b6c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
2 changes: 2 additions & 0 deletions platform/nvidia-bluefield/i2c-mlxbf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ $(addprefix $(DEST)/, $(MLXBF_I2C_DRIVER)): $(DEST)/% :

pushd ${MLXBF_I2C}

patch -p1 < ../ioremap.patch

# Build the package
ifeq ($(CROSS_BUILD_ENVIRON), y)
CONFIG_SITE=/etc/dpkg-cross/cross-config.$(CONFIGURED_ARCH) LD_LIBRARY_PATH=$(CROSS_LIB_PATH) KVER=$(KVERSION) WITH_DKMS=0 dpkg-buildpackage -rfakeroot -us -uc -b -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR)
Expand Down
49 changes: 49 additions & 0 deletions platform/nvidia-bluefield/i2c-mlxbf/ioremap.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
diff --git a/i2c-mlxbf.c b/i2c-mlxbf.c
index 05c3025..6fdd865 100644
--- a/i2c-mlxbf.c
+++ b/i2c-mlxbf.c
@@ -20,6 +20,8 @@
#include <linux/acpi.h>
#include <linux/mutex.h>

+#include <linux/version.h>
+
/* Defines what functionality is present */
#define MLX_I2C_FUNC_SMBUS_BLOCK \
(I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL)
@@ -1396,7 +1398,11 @@ static int mlx_i2c_get_gpio(struct platform_device *pdev,
if (!devm_request_mem_region(dev, params->start, size, params->name))
return -EFAULT;

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
+ gpio_res->io = devm_ioremap(dev, params->start, size);
+#else
gpio_res->io = devm_ioremap_nocache(dev, params->start, size);
+#endif
if (IS_ERR(gpio_res->io)) {
devm_release_mem_region(dev, params->start, size);
return PTR_ERR(gpio_res->io);
@@ -1460,7 +1466,11 @@ static int mlx_i2c_get_corepll(struct platform_device *pdev,
if (!devm_request_mem_region(dev, params->start, size, params->name))
return -EFAULT;

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
+ corepll_res->io = devm_ioremap(dev, params->start, size);
+#else
corepll_res->io = devm_ioremap_nocache(dev, params->start, size);
+#endif
if (IS_ERR(corepll_res->io)) {
devm_release_mem_region(dev, params->start, size);
return PTR_ERR(corepll_res->io);
@@ -1813,7 +1823,11 @@ static int mlx_i2c_init_coalesce(struct platform_device *pdev,
if (!request_mem_region(params->start, size, params->name))
return -EFAULT;

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+ coalesce_res->io = ioremap(params->start, size);
+#else
coalesce_res->io = ioremap_nocache(params->start, size);
+#endif
if (IS_ERR(coalesce_res->io)) {
release_mem_region(params->start, size);
return PTR_ERR(coalesce_res->io);
2 changes: 2 additions & 0 deletions platform/nvidia-bluefield/mlxbf-pka/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ $(addprefix $(DEST)/, $(MLXBF_PKA_DRIVER)): $(DEST)/% :

pushd ${MLXBF_PKA}

patch -p1 < ../ioremap.patch

# Build the package
ifeq ($(CROSS_BUILD_ENVIRON), y)
make -C /lib/modules/$(KVERSION)/build ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- M=$(MODULE_DIR)
Expand Down
24 changes: 24 additions & 0 deletions platform/nvidia-bluefield/mlxbf-pka/ioremap.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/pka_dev.c b/pka_dev.c
index a084713..93032be 100644
--- a/pka_dev.c
+++ b/pka_dev.c
@@ -38,6 +38,7 @@
#include <linux/ioport.h>
#include <linux/timex.h>
#include <linux/vfio.h>
+#include <linux/version.h>
#else
#include <stdint.h>
#include <string.h>
@@ -239,7 +240,11 @@ static int pka_dev_set_resource_config(pka_dev_shim_t *shim,
return -EPERM;
}

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+ res_ptr->ioaddr = ioremap(res_ptr->base, res_ptr->size);
+#else
res_ptr->ioaddr = ioremap_nocache(res_ptr->base, res_ptr->size);
+#endif
}

res_ptr->status = PKA_DEV_RES_STATUS_MAPPED;

0 comments on commit 6eb5b6c

Please sign in to comment.