Skip to contentSkip to conversation

vfio, platform: add HIDMA and ACPI support

PATCH Superseded Sinan Kaya 3 participants 11 messages Mar 11, 2016 – Mar 27, 2016

Subsystems (4)

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

v2 cover vfio, platform: add HIDMA and ACPI support

The patchset makes three different changes.
1. Add support for probing ACPI platform reset drivers.
2. Make reset driver a requirement now
3. Add support for HIDMA reset driver.

Specific changes:

vfio, platform: add support for ACPI while detecting the reset driver Changes from V1: (https://lkml.org/lkml/2016/1/29/672)
* renamed VFIO_PLATFORM_RESET_MODULE_ALIAS to
* MODULE_ALIAS_VFIO_PLATFORM_RESET

Sinan Kaya (3):
vfio, platform: add support for ACPI while detecting the reset driver vfio, platform: make reset driver a requirement
vfio, platform: add QTI HIDMA reset driver

 drivers/vfio/platform/reset/Kconfig                |   9 ++
 drivers/vfio/platform/reset/Makefile               |   2 +
 .../vfio/platform/reset/vfio_platform_amdxgbe.c    |   4 +-
 .../platform/reset/vfio_platform_calxedaxgmac.c    |   4 +-
 .../vfio/platform/reset/vfio_platform_qcomhidma.c  | 101 +++++++++++++++++
 drivers/vfio/platform/vfio_platform_common.c       | 123 ++++++++++++++++-----
 drivers/vfio/platform/vfio_platform_private.h      |  43 ++++---
 7 files changed, 241 insertions(+), 45 deletions(-)
 create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
Signature · 1 line
1.8.2.1
author
#1 lore raw

PATCH v2 1/3 vfio, platform: add support for ACPI while detecting the reset driver

The code is using the compatible DT string to associate a reset driver with the actual device itself. The compatible string does not exist on ACPI based systems. HID is the unique identifier for a device driver instead. The change allows a driver to register with DT compatible string or ACPI HID and then match the object with one of these conditions.

Rules for loading the reset driver are as follow:
- ACPI HID needs match for ACPI systems
- DT compat needs to match for OF systems

---
 .../vfio/platform/reset/vfio_platform_amdxgbe.c    |   4 +-
 .../platform/reset/vfio_platform_calxedaxgmac.c    |   4 +-
 drivers/vfio/platform/vfio_platform_common.c       | 107 +++++++++++++++++----
 drivers/vfio/platform/vfio_platform_private.h      |  43 +++++----
 4 files changed, 120 insertions(+), 38 deletions(-)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +3 -1
index d4030d0..6d87442 100644
@@ -119,7 +119,9 @@ int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
 	return 0;
 }
 
-module_vfio_reset_handler("amd,xgbe-seattle-v1a", vfio_platform_amdxgbe_reset);
+module_vfio_reset_handler("amd,xgbe-seattle-v1a", NULL,
+			  vfio_platform_amdxgbe_reset);
+MODULE_ALIAS_VFIO_PLATFORM_RESET("amd,xgbe-seattle-v1a");
 
 MODULE_VERSION("0.1");
 MODULE_LICENSE("GPL v2");
drivers/vfio/platform/reset/vfio_platform_calxedaxgmac.c +3 -1
index e3d3d94..952dd55 100644
@@ -77,7 +77,9 @@ int vfio_platform_calxedaxgmac_reset(struct vfio_platform_device *vdev)
 	return 0;
 }
 
-module_vfio_reset_handler("calxeda,hb-xgmac", vfio_platform_calxedaxgmac_reset);
+module_vfio_reset_handler("calxeda,hb-xgmac", NULL,
+			  vfio_platform_calxedaxgmac_reset);
+MODULE_ALIAS_VFIO_PLATFORM_RESET("calxeda,hb-xgmac");
 
 MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL v2");
drivers/vfio/platform/vfio_platform_common.c +89 -18

164 lines not on this page · raw message

drivers/vfio/platform/vfio_platform_private.h +25 -18

64 lines not on this page · raw message

Signature · 1 line
1.8.2.1
author
#2 lore raw

PATCH v2 2/3 vfio, platform: make reset driver a requirement

In reply to Sinan Kaya

The code was allowing platform devices to be used without a supporting VFIO reset driver. The hardware can be left in some inconsistent state after a guest machine abort.

The reset driver will put the hardware back to safe state and disable interrupts before returning the control back to the host machine.

---
 drivers/vfio/platform/vfio_platform_common.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +9 -7
index b3f6ba2..5535fe1 100644
@@ -165,12 +165,8 @@ static void vfio_platform_release(void *device_data)
 	mutex_lock(&driver_lock);
 
 	if (!(--vdev->refcnt)) {
-		if (vdev->reset) {
-			dev_info(vdev->device, "reset\n");
-			vdev->reset(vdev);
-		} else {
-			dev_warn(vdev->device, "no reset function found!\n");
-		}
+		dev_info(vdev->device, "reset\n");
+		vdev->reset(vdev);
 		vfio_platform_regions_cleanup(vdev);
 		vfio_platform_irq_cleanup(vdev);
 	}
@@ -634,7 +630,13 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 		return ret;
 	}
 
-	vfio_platform_get_reset(vdev);
+	ret = vfio_platform_get_reset(vdev);
+	if (ret) {
+		pr_err("vfio: no reset function found for device %s\n",
+		       vdev->name);
+		iommu_group_put(group);
+		return ret;
+	}
 	mutex_init(&vdev->igate);
 
 	return 0;
Signature · 1 line
1.8.2.1
author
#3 lore raw

Re: [PATCH V2 2/3] vfio, platform: make reset driver a requirement

Quoted 4 lines · Sinan Kaya

The code was allowing platform devices to be used without a supporting VFIO reset driver. The hardware can be left in some inconsistent state after a guest machine abort.

Quoted 8 lines

The reset driver will put the hardware back to safe state and disable interrupts before returning the control back to the host machine.

---
 drivers/vfio/platform/vfio_platform_common.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

I was looking at the code. It looks like this is going to break VFIO AMBA. The common implementation is shared with AMBA and platform devices.

I couldn't see a reset function for AMBA devices.

Is there anyway to write reset function for it? I have no experience with AMBA devices.

Would you include a reset needed flag and just not require it for AMBA? (I honestly don't like this idea)

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#4 lore raw

Re: [PATCH V2 2/3] vfio, platform: make reset driver a requirement

Hi Sinan,

Quoted 13 lines · Sinan Kaya
Quoted 4 lines · Sinan Kaya

The code was allowing platform devices to be used without a supporting VFIO reset driver. The hardware can be left in some inconsistent state after a guest machine abort.

Quoted 8 lines

The reset driver will put the hardware back to safe state and disable interrupts before returning the control back to the host machine.

---
 drivers/vfio/platform/vfio_platform_common.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
Quoted 7 lines

I was looking at the code. It looks like this is going to break VFIO AMBA. The common implementation is shared with AMBA and platform devices.

I couldn't see a reset function for AMBA devices.

Is there anyway to write reset function for it? I have no experience with AMBA devices.

To my knowledge only the PL330 DMA controller (drivers/dma/pl330.c) was passthrough'ed at some point, rather for development purpose than production purpose. This was done by Virtual Open Systems (ask Baptiste for more details). But I don't think this is really used.

Quoted 4 lines

Would you include a reset needed flag and just not require it for AMBA? (I honestly don't like this idea)

I think the requirement also makes sense for AMBA.

Maybe an option would be to add a module parameter that would allow to use the vfio platform/amba driver without reset module (with explicit opt-in from the user). Maybe this can be done later on.

FYI I will not have access to my mailbox until the end of the week.

Best Regards

Eric

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#5 lore raw

Re: [PATCH V2 2/3] vfio, platform: make reset driver a requirement

Hi Baptiste,

Quoted 8 lines
Quoted 4 lines

I couldn't see a reset function for AMBA devices.

Is there anyway to write reset function for it? I have no experience with AMBA devices.

To my knowledge only the PL330 DMA controller (drivers/dma/pl330.c) was passthrough'ed at some point, rather for development purpose than production purpose. This was done by Virtual Open Systems (ask Baptiste for more details). But I don't think this is really used.

Are you OK with requiring reset driver for AMBA devices too? The PL330 driver won't work until a reset driver is submitted for it.

Quoted 9 lines
Quoted 4 lines

Would you include a reset needed flag and just not require it for AMBA? (I honestly don't like this idea)

I think the requirement also makes sense for AMBA.

Maybe an option would be to add a module parameter that would allow to use the vfio platform/amba driver without reset module (with explicit opt-in from the user). Maybe this can be done later on.

I can see this flag useful for testing purposes but it should not be used in production.

How about I add a module parameter which is not set by default? When set, I don't perform the reset requirement check.

Quoted 2 lines

FYI I will not have access to my mailbox until the end of the week.

OK, no rush.

Quoted 5 lines

Best Regards

Eric

Signature · 7 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Re: [PATCH V2 2/3] vfio, platform: make reset driver a requirement

Hi Sinan,

Quoted 24 lines · Sinan Kaya

Hi Baptiste,

Quoted 8 lines
Quoted 4 lines

I couldn't see a reset function for AMBA devices.

Is there anyway to write reset function for it? I have no experience with AMBA devices.

To my knowledge only the PL330 DMA controller (drivers/dma/pl330.c) was passthrough'ed at some point, rather for development purpose than production purpose. This was done by Virtual Open Systems (ask Baptiste for more details). But I don't think this is really used.

Are you OK with requiring reset driver for AMBA devices too? The PL330 driver won't work until a reset driver is submitted for it.

Quoted 9 lines
Quoted 4 lines

Would you include a reset needed flag and just not require it for AMBA? (I honestly don't like this idea)

I think the requirement also makes sense for AMBA.

Maybe an option would be to add a module parameter that would allow to use the vfio platform/amba driver without reset module (with explicit opt-in from the user). Maybe this can be done later on.

Quoted 5 lines

I can see this flag useful for testing purposes but it should not be used in production.

How about I add a module parameter which is not set by default? When set, I don't perform the reset requirement check.

Yes that's what I meant

Best Regards

Eric

Quoted 13 lines
Quoted 3 lines

FYI I will not have access to my mailbox until the end of the week.

OK, no rush.

Quoted 5 lines

Best Regards

Eric

author
#7 lore raw

Re: [PATCH V2 2/3] vfio, platform: make reset driver a requirement

Quoted 7 lines · Eric Auger
Quoted 2 lines

How about I add a module parameter which is not set by default? When set,

Quoted 1 line

I don't perform the reset requirement check.

Yes that's what I meant

Best Regards

Eric

Got it. I'll post something soon.

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#8 lore raw

PATCH v2 3/3 vfio, platform: add QTI HIDMA reset driver

In reply to Sinan Kaya

In situations where the userspace driver is stopped abnormally and the VFIO platform device is released, the assigned HW device currently is left running. As a consequence the HW device might continue issuing IRQs and performing DMA accesses.

This patch is implementing a reset driver for HIDMA platform driver. This gets called by the VFIO platform reset interface.

---
 drivers/vfio/platform/reset/Kconfig                |   9 ++
 drivers/vfio/platform/reset/Makefile               |   2 +
 .../vfio/platform/reset/vfio_platform_qcomhidma.c  | 101 +++++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
drivers/vfio/platform/reset/Kconfig +9 -0
index 70cccc5..d02b3b5 100644
@@ -13,3 +13,12 @@ config VFIO_PLATFORM_AMDXGBE_RESET
 	  Enables the VFIO platform driver to handle reset for AMD XGBE
 
 	  If you don't know what to do here, say N.
+
+config VFIO_PLATFORM_QCOMHIDMA_RESET
+	tristate "VFIO support for Qualcomm Technologies HIDMA reset"
+	depends on VFIO_PLATFORM
+	help
+	  Enables the VFIO platform driver to handle reset for Qualcomm Technologies
+	  HIDMA Channel.
+
+	  If you don't know what to do here, say N.
drivers/vfio/platform/reset/Makefile +2 -0
index 93f4e23..ec7748a 100644
@@ -1,7 +1,9 @@
 vfio-platform-calxedaxgmac-y := vfio_platform_calxedaxgmac.o
 vfio-platform-amdxgbe-y := vfio_platform_amdxgbe.o
+vfio-platform-qcomhidma-y := vfio_platform_qcomhidma.o
 
 ccflags-y += -Idrivers/vfio/platform
 
 obj-$(CONFIG_VFIO_PLATFORM_CALXEDAXGMAC_RESET) += vfio-platform-calxedaxgmac.o
+obj-$(CONFIG_VFIO_PLATFORM_QCOMHIDMA_RESET) += vfio-platform-qcomhidma.o
 obj-$(CONFIG_VFIO_PLATFORM_AMDXGBE_RESET) += vfio-platform-amdxgbe.o
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +101 -0

101 lines not on this page · raw message

Signature · 1 line
1.8.2.1
author
#9 lore raw

Re: [PATCH V2 3/3] vfio, platform: add QTI HIDMA reset driver

Quoted 2 lines · Sinan Kaya

VFIO_PLATFORM_MODULE_ALIAS("qcom,hidma-1.0");
+VFIO_PLATFORM_MODULE_ALIAS("QCOM8061");

I forgot to rename these to MODULE_ALIAS_VFIO_PLATFORM_RESET.

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#10 lore raw

Re: [PATCH V2 3/3] vfio, platform: add QTI HIDMA reset driver

In reply to Sinan Kaya
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Sinan,

[auto build test ERROR on vfio/next]
[also build test ERROR on v4.5-rc7 next-20160311]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Sinan-Kaya/vfio-platform-add-HIDMA-and-ACPI-support/20160312-005737
base:   https://github.com/awilliam/linux-vfio.git next
config: arm-allmodconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

>> drivers/vfio/platform/reset/vfio_platform_qcomhidma.c:97:28: error: expected declaration specifiers or '...' before string constant
    VFIO_PLATFORM_MODULE_ALIAS("qcom,hidma-1.0");
                               ^
   drivers/vfio/platform/reset/vfio_platform_qcomhidma.c:98:28: error: expected declaration specifiers or '...' before string constant
    VFIO_PLATFORM_MODULE_ALIAS("QCOM8061");
                               ^

vim +97 drivers/vfio/platform/reset/vfio_platform_qcomhidma.c

    91	
    92		pr_info("HIDMA channel reset\n");
    93		return 0;
    94	}
    95	module_vfio_reset_handler("qcom,hidma-1.0", "QCOM8061",
    96				  vfio_platform_qcomhidma_reset);
  > 97	VFIO_PLATFORM_MODULE_ALIAS("qcom,hidma-1.0");
    98	VFIO_PLATFORM_MODULE_ALIAS("QCOM8061");
    99	

100 MODULE_LICENSE("GPL v2");

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation