From: Sherry Sun <sherry.sun@nxp.com>
To: hch@infradead.org, sudeep.dutt@intel.com,
ashutosh.dixit@intel.com, arnd@arndb.de,
gregkh@linuxfoundation.org, kishon@ti.com,
lorenzo.pieralisi@arm.com
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-imx@nxp.com
Subject: [PATCH V3 3/4] misc: vop: simply return the saved dma address instead of virt_to_phys
Date: Thu, 22 Oct 2020 13:06:37 +0800 [thread overview]
Message-ID: <20201022050638.29641-4-sherry.sun@nxp.com> (raw)
In-Reply-To: <20201022050638.29641-1-sherry.sun@nxp.com>
The device page and vring should use consistent memory which are
allocated by dma_alloc_coherent api, when user space wants to get its
physical address, virt_to_phys cannot be used, should simply return the
saved device page dma address by get_dp_dma callback and the vring dma
address saved in mic_vqconfig.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
drivers/misc/mic/bus/vop_bus.h | 2 ++
drivers/misc/mic/host/mic_boot.c | 8 ++++++++
drivers/misc/mic/vop/vop_vringh.c | 8 +++++++-
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/mic/bus/vop_bus.h b/drivers/misc/mic/bus/vop_bus.h
index 4fa02808c1e2..d891eacae358 100644
--- a/drivers/misc/mic/bus/vop_bus.h
+++ b/drivers/misc/mic/bus/vop_bus.h
@@ -75,6 +75,7 @@ struct vop_driver {
* node to add/remove/configure virtio devices.
* @get_dp: Get access to the virtio device page used by the self
* node to add/remove/configure virtio devices.
+ * @get_dp_dma: Get dma address of the virtio device page.
* @send_intr: Send an interrupt to the peer node on a specified doorbell.
* @remap: Map a buffer with the specified DMA address and length.
* @unmap: Unmap a buffer previously mapped.
@@ -92,6 +93,7 @@ struct vop_hw_ops {
void (*ack_interrupt)(struct vop_device *vpdev, int num);
void __iomem * (*get_remote_dp)(struct vop_device *vpdev);
void * (*get_dp)(struct vop_device *vpdev);
+ dma_addr_t (*get_dp_dma)(struct vop_device *vpdev);
void (*send_intr)(struct vop_device *vpdev, int db);
void __iomem * (*remap)(struct vop_device *vpdev,
dma_addr_t pa, size_t len);
diff --git a/drivers/misc/mic/host/mic_boot.c b/drivers/misc/mic/host/mic_boot.c
index 8cb85b8b3e19..9591bf609f57 100644
--- a/drivers/misc/mic/host/mic_boot.c
+++ b/drivers/misc/mic/host/mic_boot.c
@@ -89,6 +89,13 @@ static void *__mic_get_dp(struct vop_device *vpdev)
return mdev->dp;
}
+static dma_addr_t __mic_get_dp_dma(struct vop_device *vpdev)
+{
+ struct mic_device *mdev = vpdev_to_mdev(&vpdev->dev);
+
+ return mdev->dp_dma_addr;
+}
+
static void __iomem *__mic_get_remote_dp(struct vop_device *vpdev)
{
return NULL;
@@ -120,6 +127,7 @@ static struct vop_hw_ops vop_hw_ops = {
.ack_interrupt = __mic_ack_interrupt,
.next_db = __mic_next_db,
.get_dp = __mic_get_dp,
+ .get_dp_dma = __mic_get_dp_dma,
.get_remote_dp = __mic_get_remote_dp,
.send_intr = __mic_send_intr,
.remap = __mic_ioremap,
diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
index cc928d45af5a..b5612183dcb8 100644
--- a/drivers/misc/mic/vop/vop_vringh.c
+++ b/drivers/misc/mic/vop/vop_vringh.c
@@ -1009,7 +1009,13 @@ vop_query_offset(struct vop_vdev *vdev, unsigned long offset,
* ....
*/
if (!offset) {
- *pa = virt_to_phys(vpdev->hw_ops->get_dp(vpdev));
+ if (vpdev->hw_ops->get_dp_dma)
+ *pa = vpdev->hw_ops->get_dp_dma(vpdev);
+ else {
+ dev_err(vop_dev(vdev), "can't get device page physical address\n");
+ return -EINVAL;
+ }
+
*size = MIC_DP_SIZE;
return 0;
}
--
2.17.1
next prev parent reply other threads:[~2020-10-22 5:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-22 5:06 [PATCH V3 0/4] Change vring space from nomal memory to dma coherent memory Sherry Sun
2020-10-22 5:06 ` [PATCH V3 1/4] misc: vop: change the way of allocating vring and device page Sherry Sun
2020-10-22 7:58 ` kernel test robot
2020-10-23 9:25 ` Christoph Hellwig
2020-10-26 2:54 ` Sherry Sun
2020-10-22 5:06 ` [PATCH V3 2/4] misc: vop: do not allocate and reassign the used ring Sherry Sun
2020-10-22 8:53 ` kernel test robot
2020-10-23 9:26 ` Christoph Hellwig
2020-10-26 3:04 ` Sherry Sun
2020-10-27 6:28 ` gregkh
2020-10-22 5:06 ` Sherry Sun [this message]
2020-10-22 5:06 ` [PATCH V3 4/4] misc: vop: mapping kernel memory to user space as noncached Sherry Sun
2020-10-23 9:28 ` Christoph Hellwig
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=20201022050638.29641-4-sherry.sun@nxp.com \
--to=sherry.sun@nxp.com \
--cc=arnd@arndb.de \
--cc=ashutosh.dixit@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=kishon@ti.com \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=sudeep.dutt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).