From: Sinan Kaya <okaya@codeaurora.org>
To: dmaengine@vger.kernel.org, marc.zyngier@arm.com,
mark.rutland@arm.com, timur@codeaurora.org,
devicetree@vger.kernel.org, cov@codeaurora.org,
vinod.koul@intel.com, jcm@redhat.com
Cc: shankerd@codeaurora.org, vikrams@codeaurora.org,
eric.auger@linaro.org, agross@codeaurora.org, arnd@arndb.de,
linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Sinan Kaya <okaya@codeaurora.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH V13 10/10] vfio, platform: add QTI HIDMA reset driver
Date: Fri, 29 Jan 2016 17:35:13 -0500 [thread overview]
Message-ID: <1454106914-15857-11-git-send-email-okaya@codeaurora.org> (raw)
In-Reply-To: <1454106914-15857-1-git-send-email-okaya@codeaurora.org>
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.
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
drivers/vfio/platform/reset/Kconfig | 9 ++
drivers/vfio/platform/reset/Makefile | 2 +
.../vfio/platform/reset/vfio_platform_qcomhidma.c | 99 ++++++++++++++++++++++
3 files changed, 110 insertions(+)
create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
diff --git a/drivers/vfio/platform/reset/Kconfig b/drivers/vfio/platform/reset/Kconfig
index 70cccc5..d02b3b5 100644
--- a/drivers/vfio/platform/reset/Kconfig
+++ b/drivers/vfio/platform/reset/Kconfig
@@ -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.
diff --git a/drivers/vfio/platform/reset/Makefile b/drivers/vfio/platform/reset/Makefile
index 93f4e23..ec7748a 100644
--- a/drivers/vfio/platform/reset/Makefile
+++ b/drivers/vfio/platform/reset/Makefile
@@ -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
diff --git a/drivers/vfio/platform/reset/vfio_platform_qcomhidma.c b/drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
new file mode 100644
index 0000000..4e7a59c
--- /dev/null
+++ b/drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
@@ -0,0 +1,99 @@
+/*
+ * Qualcomm Technologies HIDMA VFIO Reset Driver
+ *
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/device.h>
+#include <linux/iopoll.h>
+
+#include "vfio_platform_private.h"
+
+#define TRCA_CTRLSTS_OFFSET 0x000
+#define EVCA_CTRLSTS_OFFSET 0x000
+
+#define CH_CONTROL_MASK GENMASK(7, 0)
+#define CH_STATE_MASK GENMASK(7, 0)
+#define CH_STATE_BIT_POS 0x8
+
+#define HIDMA_CH_STATE(val) \
+ ((val >> CH_STATE_BIT_POS) & CH_STATE_MASK)
+
+#define EVCA_IRQ_EN_OFFSET 0x110
+
+#define CH_RESET 9
+#define CH_DISABLED 0
+
+int vfio_platform_qcomhidma_reset(struct vfio_platform_device *vdev)
+{
+ struct vfio_platform_region trreg;
+ struct vfio_platform_region evreg;
+ u32 val;
+ int ret;
+
+ if (vdev->num_regions != 2)
+ return -ENODEV;
+
+ trreg = vdev->regions[0];
+ if (!trreg.ioaddr) {
+ trreg.ioaddr =
+ ioremap_nocache(trreg.addr, trreg.size);
+ if (!trreg.ioaddr)
+ return -ENOMEM;
+ }
+
+ evreg = vdev->regions[1];
+ if (!evreg.ioaddr) {
+ evreg.ioaddr =
+ ioremap_nocache(evreg.addr, evreg.size);
+ if (!evreg.ioaddr)
+ return -ENOMEM;
+ }
+
+ /* disable IRQ */
+ writel(0, evreg.ioaddr + EVCA_IRQ_EN_OFFSET);
+
+ /* reset both transfer and event channels */
+ val = readl(trreg.ioaddr + TRCA_CTRLSTS_OFFSET);
+ val &= ~(CH_CONTROL_MASK << 16);
+ val |= CH_RESET << 16;
+ writel(val, trreg.ioaddr + TRCA_CTRLSTS_OFFSET);
+
+ ret = readl_poll_timeout(trreg.ioaddr + TRCA_CTRLSTS_OFFSET, val,
+ HIDMA_CH_STATE(val) == CH_DISABLED, 1000,
+ 10000);
+ if (ret)
+ return ret;
+
+ val = readl(evreg.ioaddr + EVCA_CTRLSTS_OFFSET);
+ val &= ~(CH_CONTROL_MASK << 16);
+ val |= CH_RESET << 16;
+ writel(val, evreg.ioaddr + EVCA_CTRLSTS_OFFSET);
+
+ ret = readl_poll_timeout(evreg.ioaddr + EVCA_CTRLSTS_OFFSET, val,
+ HIDMA_CH_STATE(val) == CH_DISABLED, 1000,
+ 10000);
+ if (ret)
+ return ret;
+
+ pr_info("HIDMA channel reset\n");
+ return 0;
+}
+module_vfio_reset_handler("qcom,hidma", NULL,
+ vfio_platform_qcomhidma_reset);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Reset support for Qualcomm Technologies HIDMA device");
--
1.8.2.1
WARNING: multiple messages have this Message-ID (diff)
From: okaya@codeaurora.org (Sinan Kaya)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V13 10/10] vfio, platform: add QTI HIDMA reset driver
Date: Fri, 29 Jan 2016 17:35:13 -0500 [thread overview]
Message-ID: <1454106914-15857-11-git-send-email-okaya@codeaurora.org> (raw)
In-Reply-To: <1454106914-15857-1-git-send-email-okaya@codeaurora.org>
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.
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
drivers/vfio/platform/reset/Kconfig | 9 ++
drivers/vfio/platform/reset/Makefile | 2 +
.../vfio/platform/reset/vfio_platform_qcomhidma.c | 99 ++++++++++++++++++++++
3 files changed, 110 insertions(+)
create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
diff --git a/drivers/vfio/platform/reset/Kconfig b/drivers/vfio/platform/reset/Kconfig
index 70cccc5..d02b3b5 100644
--- a/drivers/vfio/platform/reset/Kconfig
+++ b/drivers/vfio/platform/reset/Kconfig
@@ -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.
diff --git a/drivers/vfio/platform/reset/Makefile b/drivers/vfio/platform/reset/Makefile
index 93f4e23..ec7748a 100644
--- a/drivers/vfio/platform/reset/Makefile
+++ b/drivers/vfio/platform/reset/Makefile
@@ -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
diff --git a/drivers/vfio/platform/reset/vfio_platform_qcomhidma.c b/drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
new file mode 100644
index 0000000..4e7a59c
--- /dev/null
+++ b/drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
@@ -0,0 +1,99 @@
+/*
+ * Qualcomm Technologies HIDMA VFIO Reset Driver
+ *
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/device.h>
+#include <linux/iopoll.h>
+
+#include "vfio_platform_private.h"
+
+#define TRCA_CTRLSTS_OFFSET 0x000
+#define EVCA_CTRLSTS_OFFSET 0x000
+
+#define CH_CONTROL_MASK GENMASK(7, 0)
+#define CH_STATE_MASK GENMASK(7, 0)
+#define CH_STATE_BIT_POS 0x8
+
+#define HIDMA_CH_STATE(val) \
+ ((val >> CH_STATE_BIT_POS) & CH_STATE_MASK)
+
+#define EVCA_IRQ_EN_OFFSET 0x110
+
+#define CH_RESET 9
+#define CH_DISABLED 0
+
+int vfio_platform_qcomhidma_reset(struct vfio_platform_device *vdev)
+{
+ struct vfio_platform_region trreg;
+ struct vfio_platform_region evreg;
+ u32 val;
+ int ret;
+
+ if (vdev->num_regions != 2)
+ return -ENODEV;
+
+ trreg = vdev->regions[0];
+ if (!trreg.ioaddr) {
+ trreg.ioaddr =
+ ioremap_nocache(trreg.addr, trreg.size);
+ if (!trreg.ioaddr)
+ return -ENOMEM;
+ }
+
+ evreg = vdev->regions[1];
+ if (!evreg.ioaddr) {
+ evreg.ioaddr =
+ ioremap_nocache(evreg.addr, evreg.size);
+ if (!evreg.ioaddr)
+ return -ENOMEM;
+ }
+
+ /* disable IRQ */
+ writel(0, evreg.ioaddr + EVCA_IRQ_EN_OFFSET);
+
+ /* reset both transfer and event channels */
+ val = readl(trreg.ioaddr + TRCA_CTRLSTS_OFFSET);
+ val &= ~(CH_CONTROL_MASK << 16);
+ val |= CH_RESET << 16;
+ writel(val, trreg.ioaddr + TRCA_CTRLSTS_OFFSET);
+
+ ret = readl_poll_timeout(trreg.ioaddr + TRCA_CTRLSTS_OFFSET, val,
+ HIDMA_CH_STATE(val) == CH_DISABLED, 1000,
+ 10000);
+ if (ret)
+ return ret;
+
+ val = readl(evreg.ioaddr + EVCA_CTRLSTS_OFFSET);
+ val &= ~(CH_CONTROL_MASK << 16);
+ val |= CH_RESET << 16;
+ writel(val, evreg.ioaddr + EVCA_CTRLSTS_OFFSET);
+
+ ret = readl_poll_timeout(evreg.ioaddr + EVCA_CTRLSTS_OFFSET, val,
+ HIDMA_CH_STATE(val) == CH_DISABLED, 1000,
+ 10000);
+ if (ret)
+ return ret;
+
+ pr_info("HIDMA channel reset\n");
+ return 0;
+}
+module_vfio_reset_handler("qcom,hidma", NULL,
+ vfio_platform_qcomhidma_reset);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Reset support for Qualcomm Technologies HIDMA device");
--
1.8.2.1
next prev parent reply other threads:[~2016-01-29 22:35 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-29 22:35 [PATCH V13 00/10] dma: add Qualcomm Technologies HIDMA driver Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 01/10] dma: qcom_bam_dma: move to qcom directory Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 02/10] dma: hidma: Add Device Tree binding Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 03/10] dma: add Qualcomm Technologies HIDMA management driver Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 04/10] dma: add Qualcomm Technologies HIDMA channel driver Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 05/10] dma: qcom_hidma: implement lower level hardware interface Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 06/10] dma: qcom_hidma: add debugfs hooks Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 07/10] dma: qcom_hidma: add support for object hierarchy Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 08/10] dma: qcom_hidma: read the channel id from HW Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-02-01 15:14 ` Rob Herring
2016-02-01 15:14 ` Rob Herring
2016-02-03 18:32 ` Sinan Kaya
2016-02-03 18:32 ` Sinan Kaya
2016-02-01 15:35 ` Mark Rutland
2016-02-01 15:35 ` Mark Rutland
2016-02-01 15:46 ` Sinan Kaya
2016-02-01 15:46 ` Sinan Kaya
2016-02-03 18:32 ` Sinan Kaya
2016-02-03 18:32 ` Sinan Kaya
2016-02-03 18:32 ` Sinan Kaya
2016-02-03 18:36 ` Mark Rutland
2016-02-03 18:36 ` Mark Rutland
2016-02-03 18:46 ` Sinan Kaya
2016-02-03 18:46 ` Sinan Kaya
2016-02-07 15:04 ` Sinan Kaya
2016-02-07 15:04 ` Sinan Kaya
2016-02-07 15:04 ` Sinan Kaya
2016-02-09 21:01 ` Sinan Kaya
2016-02-09 21:01 ` Sinan Kaya
2016-01-29 22:35 ` [PATCH V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya
2016-01-30 12:52 ` kbuild test robot
2016-01-30 12:52 ` kbuild test robot
2016-01-30 12:52 ` kbuild test robot
2016-01-31 13:53 ` Sinan Kaya
2016-01-31 13:53 ` Sinan Kaya
2016-01-31 13:53 ` Sinan Kaya
2016-02-01 16:08 ` Eric Auger
2016-02-01 16:08 ` Eric Auger
2016-02-01 16:16 ` Sinan Kaya
2016-02-01 16:16 ` Sinan Kaya
2016-02-01 16:29 ` Eric Auger
2016-02-01 16:29 ` Eric Auger
2016-02-01 16:44 ` Sinan Kaya
2016-02-01 16:44 ` Sinan Kaya
2016-02-01 16:49 ` Timur Tabi
2016-02-01 16:49 ` Timur Tabi
2016-02-01 16:56 ` Sinan Kaya
2016-02-01 16:56 ` Sinan Kaya
2016-02-03 18:38 ` Sinan Kaya
2016-02-03 18:38 ` Sinan Kaya
2016-01-29 22:35 ` Sinan Kaya [this message]
2016-01-29 22:35 ` [PATCH V13 10/10] vfio, platform: add QTI HIDMA " Sinan Kaya
2016-02-01 15:41 ` Eric Auger
2016-02-01 15:41 ` Eric Auger
2016-02-01 15:41 ` Eric Auger
2016-02-01 15:51 ` Sinan Kaya
2016-02-01 15:51 ` Sinan Kaya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454106914-15857-11-git-send-email-okaya@codeaurora.org \
--to=okaya@codeaurora.org \
--cc=agross@codeaurora.org \
--cc=arnd@arndb.de \
--cc=cov@codeaurora.org \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=eric.auger@linaro.org \
--cc=jcm@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=shankerd@codeaurora.org \
--cc=timur@codeaurora.org \
--cc=vikrams@codeaurora.org \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.