Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Add arm on s390 accelerator driver
@ 2026-12-04 14:45 Sven Schnelle
  2026-12-04 14:45 ` [PATCH 1/3] iommu: sva: allow SVA without PASID Sven Schnelle
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sven Schnelle @ 2026-12-04 14:45 UTC (permalink / raw)
  To: Marc Zyngier, Mark Rutland, Joerg Roedel (AMD), Will Deacon
  Cc: Robin Murphy, Catalin Marinas, Sudeep Holla, Ard Biesheuvel,
	linux-kernel, iommu, linux-arm-kernel, Christian Borntraeger,
	Hendrik Brueckner, Ulrich Weigand, Arnd Bergmann, linux-s390

Upcoming s390 machines will support crypto/deflate hardware acceleration
for arm64 guests. This works by providing a memory region to the guest
which can be written to via the st64bv0 instruction. In order to use this
instruction from userspace programs, a driver is needed that allows to map
the accelerator memory region via mmap(). Programs can then call
acceleration functions by writing a parameter block + function code with
st64bv0 to this memory region.

st64bv0 writes 32 bits of data taken from the ACCDATA_EL1 register together
with the other data. An additional patch is needed to make it possible to
use st64bv0 without a PASID. I agreed with Arnd that I send the patch
with this driver, as it is the use case for it.

NOTE: the patchset depends on patches 2-4 of the series from:

https://lore.kernel.org/all/20261203095703.655796-1-arnd@kernel.org/

Arnd Bergmann (1):
  iommu: sva: allow SVA without PASID

Sven Schnelle (2):
  dt-bindings: firmware: platform-accel: add yaml documentation
  drivers: firmware: add ARM on s390 accelerator driver

 .../bindings/firmware/platform-accel.yaml     |  37 ++++
 MAINTAINERS                                   |   7 +
 drivers/firmware/Kconfig                      |  10 ++
 drivers/firmware/Makefile                     |   1 +
 drivers/firmware/platform-accel.c             | 168 ++++++++++++++++++
 drivers/iommu/iommu-sva.c                     |  31 +++-
 drivers/iommu/iommu.c                         |  21 ++-
 include/linux/iommu.h                         |   8 +
 8 files changed, 275 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/firmware/platform-accel.yaml
 create mode 100644 drivers/firmware/platform-accel.c


base-commit: 007722b8211f7b34fdf21b1e6a9c32497633ea29
prerequisite-patch-id: 2ad19c35e53aa86d4d706692b991a5eb9d4a4dc7
prerequisite-patch-id: 334d1217dd04cccac70aafe00ce6e318e13c5afd
prerequisite-patch-id: 58d0d38039709bf5b6a592bd356257cc5cecba7e
-- 
2.56.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] iommu: sva: allow SVA without PASID
  2026-12-04 14:45 [PATCH 0/3] Add arm on s390 accelerator driver Sven Schnelle
@ 2026-12-04 14:45 ` Sven Schnelle
  2026-12-04 14:45 ` [PATCH 2/3] dt-bindings: firmware: platform-accel: add yaml documentation Sven Schnelle
  2026-12-04 14:45 ` [PATCH 3/3] drivers: firmware: add ARM on s390 accelerator driver Sven Schnelle
  2 siblings, 0 replies; 5+ messages in thread
From: Sven Schnelle @ 2026-12-04 14:45 UTC (permalink / raw)
  To: Marc Zyngier, Mark Rutland, Joerg Roedel (AMD), Will Deacon
  Cc: Robin Murphy, Catalin Marinas, Sudeep Holla, Ard Biesheuvel,
	linux-kernel, iommu, linux-arm-kernel, Christian Borntraeger,
	Hendrik Brueckner, Ulrich Weigand, Arnd Bergmann, linux-s390

From: Arnd Bergmann <arnd@arndb.de>

On devices that are tightly integrated with the CPU and use the regular
page tables for synchronous commands, the PASID is ignored and the
actual ASID is used in its place, on Arm CPUs this is in TTBR0_EL1.

Create a new iommu_sva_bind_device_no_iommu() interface that lets device
drivers install an iommu_mm object in an mm for such devices.

As before, multiple SVA devices can be used by the same process as long
as all of them are able to use the same PASID. When a device without
an IOMMU enables SVA, the process will still allocate a PASID that can
be used for any other devices accessed by the same process after a
successful call to iommu_sva_bind_device().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
 drivers/iommu/iommu-sva.c | 31 ++++++++++++++++++++++++++++++-
 drivers/iommu/iommu.c     | 21 ++++++++++++++-------
 include/linux/iommu.h     |  8 ++++++++
 3 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c
index 9827cb804363..b444f3483f6d 100644
--- a/drivers/iommu/iommu-sva.c
+++ b/drivers/iommu/iommu-sva.c
@@ -29,7 +29,7 @@ static struct iommu_mm_data *iommu_alloc_mm_data(struct mm_struct *mm, struct de
 	iommu_mm = mm->iommu_mm;
 	/* Is a PASID already associated with this mm? */
 	if (iommu_mm) {
-		if (iommu_mm->pasid >= dev->iommu->max_pasids)
+		if (dev->iommu && iommu_mm->pasid >= dev->iommu->max_pasids)
 			return ERR_PTR(-EOVERFLOW);
 		return iommu_mm;
 	}
@@ -156,6 +156,35 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
 }
 EXPORT_SYMBOL_GPL(iommu_sva_bind_device);
 
+/**
+ * iommu_sva_bind_device_no_iommu() - Bind a process address space to a device without iommu
+ * @dev: the device
+ * @mm: the mm to bind, caller must hold a reference to mm_users
+ *
+ * Allow the use of shared virtual addressing on devices that transparently
+ * use the CPU's page table instead of an IOMMU. A global PASID is allocated
+ * in case the same process uses another device with an IOMMU later.
+ *
+ * The reference is held until the mm_struct is destroyed.
+ *
+ * On error, returns a negative error number, or zero on success.
+ */
+int iommu_sva_bind_device_no_iommu(struct device *dev, struct mm_struct *mm)
+{
+	struct iommu_mm_data *iommu_mm;
+
+	if (dev->iommu_group)
+		return -EINVAL;
+
+	mutex_lock(&iommu_sva_lock);
+	/* Allocate mm->pasid if necessary. */
+	iommu_mm = iommu_alloc_mm_data(mm, dev);
+	mutex_unlock(&iommu_sva_lock);
+
+	return PTR_ERR_OR_ZERO(iommu_mm);
+}
+EXPORT_SYMBOL_GPL(iommu_sva_bind_device_no_iommu);
+
 /**
  * iommu_sva_unbind_device() - Remove a bond created with iommu_sva_bind_device
  * @handle: the handle returned by iommu_sva_bind_device()
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index b486b8bbd1fc..1470bb9c1ca8 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -3827,17 +3827,24 @@ EXPORT_SYMBOL_GPL(iommu_detach_device_pasid);
 ioasid_t iommu_alloc_global_pasid(struct device *dev)
 {
 	int ret;
+	unsigned int max_pasid;
 
-	/* max_pasids == 0 means that the device does not support PASID */
-	if (!dev->iommu->max_pasids)
+	if (!dev->iommu) {
+		/* no IOMMU but capable of enqcmd/st64bv0: pick any PASID */
+		max_pasid = IOMMU_PASID_INVALID - 1;
+	} else if (dev->iommu->max_pasids) {
+		/*
+		 * max_pasids is set up by vendor driver based on number of
+		 * PASID bits supported but the IDA allocation is inclusive.
+		 */
+		max_pasid = dev->iommu->max_pasids - 1;
+	} else {
+		/* max_pasids == 0 means that the device does not support PASID */
 		return IOMMU_PASID_INVALID;
+	}
 
-	/*
-	 * max_pasids is set up by vendor driver based on number of PASID bits
-	 * supported but the IDA allocation is inclusive.
-	 */
 	ret = ida_alloc_range(&iommu_global_pasid_ida, IOMMU_FIRST_GLOBAL_PASID,
-			      dev->iommu->max_pasids - 1, GFP_KERNEL);
+			      max_pasid, GFP_KERNEL);
 	return ret < 0 ? IOMMU_PASID_INVALID : ret;
 }
 EXPORT_SYMBOL_GPL(iommu_alloc_global_pasid);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index ef5043752a36..131595da295f 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -1663,6 +1663,8 @@ static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm)
 void mm_pasid_drop(struct mm_struct *mm);
 struct iommu_sva *iommu_sva_bind_device(struct device *dev,
 					struct mm_struct *mm);
+int iommu_sva_bind_device_no_iommu(struct device *dev,
+				   struct mm_struct *mm);
 void iommu_sva_unbind_device(struct iommu_sva *handle);
 u32 iommu_sva_get_pasid(struct iommu_sva *handle);
 void iommu_sva_invalidate_kva_range(unsigned long start, unsigned long end);
@@ -1673,6 +1675,12 @@ iommu_sva_bind_device(struct device *dev, struct mm_struct *mm)
 	return ERR_PTR(-ENODEV);
 }
 
+static inline int iommu_sva_bind_device_no_iommu(struct device *dev,
+				   struct mm_struct *mm)
+{
+	return -ENODEV;
+}
+
 static inline void iommu_sva_unbind_device(struct iommu_sva *handle)
 {
 }
-- 
2.56.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] dt-bindings: firmware: platform-accel: add yaml documentation
  2026-12-04 14:45 [PATCH 0/3] Add arm on s390 accelerator driver Sven Schnelle
  2026-12-04 14:45 ` [PATCH 1/3] iommu: sva: allow SVA without PASID Sven Schnelle
@ 2026-12-04 14:45 ` Sven Schnelle
  2026-12-04 14:45 ` [PATCH 3/3] drivers: firmware: add ARM on s390 accelerator driver Sven Schnelle
  2 siblings, 0 replies; 5+ messages in thread
From: Sven Schnelle @ 2026-12-04 14:45 UTC (permalink / raw)
  To: Marc Zyngier, Mark Rutland, Joerg Roedel (AMD), Will Deacon
  Cc: Robin Murphy, Catalin Marinas, Sudeep Holla, Ard Biesheuvel,
	linux-kernel, iommu, linux-arm-kernel, Christian Borntraeger,
	Hendrik Brueckner, Ulrich Weigand, Arnd Bergmann, linux-s390

Add the yaml file describing platform-accel. Also add the file to
MAINTAINERS.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
 .../bindings/firmware/platform-accel.yaml     | 37 +++++++++++++++++++
 MAINTAINERS                                   |  7 ++++
 2 files changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/platform-accel.yaml

diff --git a/Documentation/devicetree/bindings/firmware/platform-accel.yaml b/Documentation/devicetree/bindings/firmware/platform-accel.yaml
new file mode 100644
index 000000000000..056a62b05a7c
--- /dev/null
+++ b/Documentation/devicetree/bindings/firmware/platform-accel.yaml
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/firmware/platform-accel.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: IBM Platform acceleration for ARM guests
+
+description:
+  A memory region available on s390 in ARM guests used to perform hardware
+  acceleration functions.
+
+maintainers:
+  - Sven Schnelle <svens@linux.ibm.com>
+
+properties:
+  compatible:
+    enum:
+      - ibm,platform-accel-v1.0-cpacf
+      - ibm,platform-accel-v1.0-dfltcc
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    platform-accel@0 {
+        compatible = "ibm,platform-accel-v1.0-cpacf";
+        reg = <0x0 0x10000>;
+    };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 02ac35ecda70..139ef5d1ebe4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -24755,6 +24755,13 @@ F:	drivers/cpuidle/cpuidle-s390.c
 F:	drivers/s390/
 F:	drivers/watchdog/diag288_wdt.c
 
+S390 ARM GUEST ACCELERATION DRIVER
+M:	Sven Schnelle <svens@linux.ibm.com>
+L:	linux-s390@vger.kernel.org
+S:	Supported
+F:	Documentation/devicetree/bindings/firmware/platform-accel.yaml
+F:	drivers/firmware/platform-accel.c
+
 S390 COMMON I/O LAYER
 M:	Vineeth Vijayan <vneethv@linux.ibm.com>
 M:	Peter Oberparleiter <oberpar@linux.ibm.com>
-- 
2.56.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] drivers: firmware: add ARM on s390 accelerator driver
  2026-12-04 14:45 [PATCH 0/3] Add arm on s390 accelerator driver Sven Schnelle
  2026-12-04 14:45 ` [PATCH 1/3] iommu: sva: allow SVA without PASID Sven Schnelle
  2026-12-04 14:45 ` [PATCH 2/3] dt-bindings: firmware: platform-accel: add yaml documentation Sven Schnelle
@ 2026-12-04 14:45 ` Sven Schnelle
  2026-12-04 15:28   ` Arnd Bergmann
  2 siblings, 1 reply; 5+ messages in thread
From: Sven Schnelle @ 2026-12-04 14:45 UTC (permalink / raw)
  To: Marc Zyngier, Mark Rutland, Joerg Roedel (AMD), Will Deacon
  Cc: Robin Murphy, Catalin Marinas, Sudeep Holla, Ard Biesheuvel,
	linux-kernel, iommu, linux-arm-kernel, Christian Borntraeger,
	Hendrik Brueckner, Ulrich Weigand, Arnd Bergmann, linux-s390

s390 support for ARM guests supports hardware acceleration for
crypto and other functions. This is implemented by providing a special
memory region that can be accessed via st64bv0. To allow userspace to
utilize this functionality, add a driver to map the accelerator memory
region into the userspace process. Note that the misc device files
are created with permission 0666 so all userspace processes can use
the driver without additional configuration.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
 drivers/firmware/Kconfig          |  10 ++
 drivers/firmware/Makefile         |   1 +
 drivers/firmware/platform-accel.c | 168 ++++++++++++++++++++++++++++++
 3 files changed, 179 insertions(+)
 create mode 100644 drivers/firmware/platform-accel.c

diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 43e2e2a64594..bc90aa19b5d3 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -299,6 +299,16 @@ config TURRIS_MOX_RWTM_KEYCTL
 
 endif # TURRIS_MOX_RWTM
 
+config PLATFORM_ACCEL
+	tristate "Acceleration driver for arm64"
+	depends on ARM64
+	select IOMMU_SVA
+	help
+	  Say y here to enable the platform driver for providing a userspace
+	  device to utilize acceleration in s390 ARM KVM guests. This works by
+	  providing a misc device which can be used to mmap() the required
+	  memory region and perform functions with st64bv0 on it.
+
 source "drivers/firmware/arm_ffa/Kconfig"
 source "drivers/firmware/arm_rmm/Kconfig"
 source "drivers/firmware/broadcom/Kconfig"
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 50b338313152..c76e84872fc1 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_TH1520_AON_PROTOCOL) += thead,th1520-aon.o
 obj-$(CONFIG_TI_SCI_PROTOCOL)	+= ti_sci.o
 obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o
 obj-$(CONFIG_TURRIS_MOX_RWTM)	+= turris-mox-rwtm.o
+obj-$(CONFIG_PLATFORM_ACCEL)	+= platform-accel.o
 
 obj-y				+= arm_ffa/
 obj-y				+= arm_rmm/
diff --git a/drivers/firmware/platform-accel.c b/drivers/firmware/platform-accel.c
new file mode 100644
index 000000000000..0e77a8243d03
--- /dev/null
+++ b/drivers/firmware/platform-accel.c
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/miscdevice.h>
+#include <linux/iommu.h>
+#include <linux/cpufeature.h>
+#include <linux/pgtable.h>
+
+struct platform_accel {
+	struct platform_device *pdev;
+	resource_size_t phys_size;
+	phys_addr_t phys_base;
+	struct miscdevice misc;
+	struct mutex lock;
+	bool present;
+};
+
+static int platform_accel_mmap(struct file *filep, struct vm_area_struct *vma)
+{
+	struct miscdevice *misc = filep->private_data;
+	struct platform_accel *dev = container_of(misc, struct platform_accel, misc);
+	int ret = -ENODEV;
+
+	mutex_lock(&dev->lock);
+	if (!dev->present)
+		goto out;
+
+	ret = iommu_sva_bind_device_no_iommu(&dev->pdev->dev, current->mm);
+	if (ret)
+		goto out;
+	vma->vm_page_prot = pgprot_device(vma->vm_page_prot);
+	ret = vm_iomap_memory(vma, dev->phys_base, dev->phys_size);
+out:
+	mutex_unlock(&dev->lock);
+	return ret;
+}
+
+static const struct file_operations platform_accel_fops = {
+	.owner = THIS_MODULE,
+	.open = nonseekable_open,
+	.mmap = platform_accel_mmap,
+};
+
+static struct platform_accel platform_accel_dev_cpacf = {
+	.misc = {
+		.name = "platform-accel-cpacf",
+		.minor = MISC_DYNAMIC_MINOR,
+		.fops = &platform_accel_fops,
+		.mode = 0666,
+	},
+	.lock = __MUTEX_INITIALIZER(platform_accel_dev_cpacf.lock),
+};
+
+static struct platform_accel platform_accel_dev_dfltcc = {
+	.misc = {
+		.name = "platform-accel-dfltcc",
+		.minor = MISC_DYNAMIC_MINOR,
+		.fops = &platform_accel_fops,
+		.mode = 0666,
+	},
+	.lock = __MUTEX_INITIALIZER(platform_accel_dev_dfltcc.lock),
+};
+
+static int platform_accel_do_platform_probe(struct platform_device *pdev)
+{
+	struct platform_accel *dev = platform_get_drvdata(pdev);
+	struct resource *r;
+	void __iomem *ret;
+
+	ret = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
+	if (IS_ERR(ret))
+		return PTR_ERR(ret);
+
+	dev_info(&pdev->dev, "mmio at %pR\n", r);
+	dev->phys_base = r->start;
+	dev->phys_size = resource_size(r);
+	dev->pdev = pdev;
+	return 0;
+}
+
+static int platform_accel_probe(struct platform_device *pdev)
+{
+	struct platform_accel *dev;
+	int err;
+
+	if (!system_supports_ls64_accdata())
+		return -ENODEV;
+
+	dev = (struct platform_accel *)device_get_match_data(&pdev->dev);
+	if (!dev)
+		return -EINVAL;
+
+	mutex_lock(&dev->lock);
+	if (dev->present) {
+		err = -EBUSY;
+		goto out;
+	}
+	platform_set_drvdata(pdev, dev);
+
+	err = platform_accel_do_platform_probe(pdev);
+	if (err)
+		goto err_clear;
+
+	dev->present = true;
+	err = misc_register(&dev->misc);
+	if (err)
+		goto err_cleanup;
+	mutex_unlock(&dev->lock);
+	return 0;
+
+err_cleanup:
+	dev->present = false;
+err_clear:
+	platform_set_drvdata(pdev, NULL);
+out:
+	mutex_unlock(&dev->lock);
+	return err;
+}
+
+static void platform_accel_remove(struct platform_device *pdev)
+{
+	struct platform_accel *dev = platform_get_drvdata(pdev);
+
+	mutex_lock(&dev->lock);
+	misc_deregister(&dev->misc);
+	dev->present = false;
+	platform_set_drvdata(pdev, NULL);
+	dev->pdev = NULL;
+	mutex_unlock(&dev->lock);
+}
+
+static const struct of_device_id platform_accel_of_match[] = {
+	{ .compatible = "ibm,platform-accel-v1.0-cpacf", .data = &platform_accel_dev_cpacf },
+	{ .compatible = "ibm,platform-accel-v1.0-dfltcc", .data = &platform_accel_dev_dfltcc },
+	{},
+};
+MODULE_DEVICE_TABLE(of, platform_accel_of_match);
+
+#if IS_ENABLED(CONFIG_ACPI)
+static const struct acpi_device_id platform_accel_acpi_match[] = {
+	{ "IBM077A", (kernel_ulong_t)&platform_accel_dev_cpacf },
+	{ "IBM077B", (kernel_ulong_t)&platform_accel_dev_dfltcc },
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, platform_accel_acpi_match);
+#endif
+
+static struct platform_driver platform_accel_driver = {
+	.probe = platform_accel_probe,
+	.remove = platform_accel_remove,
+	.driver = {
+		.name = "platform-accel",
+		.of_match_table = platform_accel_of_match,
+#if IS_ENABLED(CONFIG_ACPI)
+		.acpi_match_table = ACPI_PTR(platform_accel_acpi_match),
+#endif
+	},
+};
+
+module_platform_driver(platform_accel_driver);
+
+MODULE_AUTHOR("IBM Corporation");
+MODULE_DESCRIPTION("IBM s390 ARM acceleration platform driver");
+MODULE_LICENSE("GPL");
-- 
2.56.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] drivers: firmware: add ARM on s390 accelerator driver
  2026-12-04 14:45 ` [PATCH 3/3] drivers: firmware: add ARM on s390 accelerator driver Sven Schnelle
@ 2026-12-04 15:28   ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2026-12-04 15:28 UTC (permalink / raw)
  To: Sven Schnelle, Marc Zyngier, Mark Rutland, Joerg Roedel,
	Will Deacon
  Cc: Robin Murphy, Catalin Marinas, Sudeep Holla, Ard Biesheuvel,
	linux-kernel, iommu, linux-arm-kernel, Christian Borntraeger,
	Hendrik Brueckner, Ulrich Weigand, linux-s390

On Fri, Dec 4, 2026, at 15:45, Sven Schnelle wrote:
> s390 support for ARM guests supports hardware acceleration for
> crypto and other functions. This is implemented by providing a special
> memory region that can be accessed via st64bv0. To allow userspace to
> utilize this functionality, add a driver to map the accelerator memory
> region into the userspace process. Note that the misc device files
> are created with permission 0666 so all userspace processes can use
> the driver without additional configuration.
>
> Signed-off-by: Sven Schnelle <svens@linux.ibm.com>

Hi Sven,

I noticed a few details:

> +config PLATFORM_ACCEL
> +	tristate "Acceleration driver for arm64"
> +	depends on ARM64
> +	select IOMMU_SVA

CONFIG_IOMMU_SVA depends on CONFIG_IOMMU_SUPPORT, so you need to
make this

      depends on IOMMU_SUPPORT

Ideally it would also be 'depends on ARM64 || COMPILE_TEST' to
give it build test coverage on other architectures, but only
if you can easily make it compile portably.

> +static int platform_accel_mmap(struct file *filep, struct 
> vm_area_struct *vma)

Lorenzo has been going through device drivers to convert the .mmap()
callback to .mmap_prepare(), see https://lore.kernel.org/all/?q=mmap_prepare
for recent patches. It's probably best to do the same thing here.

> +static int platform_accel_probe(struct platform_device *pdev)
> +{
> +	struct platform_accel *dev;
> +	int err;
> +
> +	if (!system_supports_ls64_accdata())
> +		return -ENODEV;

I think the system_supports_ls64_accdata() call is the only compile time
dependency on my "arm64: dynamically enable st64bv0 for SVA" patch,  but it's
not actually a runtime dependency as the hypervisor platform should
only provide the device if it can be used, and the failure mode should
still be fine, as userspace should probably check the hwcap as well.

If you take out this call or open-code the check for ARM64_HAS_LS64_ACCDATA,
the series can be merged independently through another tree.

> +      dev_info(&pdev->dev, "mmio at %pR\n", r);

I'd drop this from the production version, as working drivers are
supposed to be quiet.

> +#if IS_ENABLED(CONFIG_ACPI)
> +static const struct acpi_device_id platform_accel_acpi_match[] = {
> +	{ "IBM077A", (kernel_ulong_t)&platform_accel_dev_cpacf },
> +	{ "IBM077B", (kernel_ulong_t)&platform_accel_dev_dfltcc },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(acpi, platform_accel_acpi_match);
> +#endif

No need for the #if check here

> +#if IS_ENABLED(CONFIG_ACPI)
> +		.acpi_match_table = ACPI_PTR(platform_accel_acpi_match),
> +#endif

or the ACPI_PTR() here, which just duplicates the #if check.
I would just always leave the .acpi_match_table entry and waste
a few bytes of .rodata in favor of readability.

      Arnd


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-04 15:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 14:45 [PATCH 0/3] Add arm on s390 accelerator driver Sven Schnelle
2026-12-04 14:45 ` [PATCH 1/3] iommu: sva: allow SVA without PASID Sven Schnelle
2026-12-04 14:45 ` [PATCH 2/3] dt-bindings: firmware: platform-accel: add yaml documentation Sven Schnelle
2026-12-04 14:45 ` [PATCH 3/3] drivers: firmware: add ARM on s390 accelerator driver Sven Schnelle
2026-12-04 15:28   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox