From: Jason Wang <jasowang@redhat.com>
To: mst@redhat.com, jasowang@redhat.com,
virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Cc: cunming.liang@intel.com, zhihong.wang@intel.com,
lingshan.zhu@intel.com, lulu@redhat.com
Subject: [RFC PATCH 1/2] virtio: accept parent as a parameter when allocating virtqueue
Date: Tue, 29 Oct 2019 18:58:42 +0800 [thread overview]
Message-ID: <20191029105843.12061-2-jasowang@redhat.com> (raw)
In-Reply-To: <20191029105843.12061-1-jasowang@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/virtio/virtio_ring.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index bdc08244a648..51d83f4d7c32 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -269,12 +269,12 @@ size_t virtio_max_dma_size(struct virtio_device *vdev)
}
EXPORT_SYMBOL_GPL(virtio_max_dma_size);
-static void *vring_alloc_queue(struct virtio_device *vdev, size_t size,
- dma_addr_t *dma_handle, gfp_t flag)
+static void *vring_alloc_queue(struct virtio_device *vdev,
+ struct device *parent, size_t size,
+ dma_addr_t *dma_handle, gfp_t flag)
{
if (vring_use_dma_api(vdev)) {
- return dma_alloc_coherent(vdev->dev.parent, size,
- dma_handle, flag);
+ return dma_alloc_coherent(parent, size, dma_handle, flag);
} else {
void *queue = alloc_pages_exact(PAGE_ALIGN(size), flag);
@@ -859,6 +859,7 @@ static struct virtqueue *vring_create_virtqueue_split(
dma_addr_t dma_addr;
size_t queue_size_in_bytes;
struct vring vring;
+ struct device *parent = vdev->dev.parent;
/* We assume num is a power of 2. */
if (num & (num - 1)) {
@@ -868,7 +869,8 @@ static struct virtqueue *vring_create_virtqueue_split(
/* TODO: allocate each queue chunk individually */
for (; num && vring_size(num, vring_align) > PAGE_SIZE; num /= 2) {
- queue = vring_alloc_queue(vdev, vring_size(num, vring_align),
+ queue = vring_alloc_queue(vdev, parent,
+ vring_size(num, vring_align),
&dma_addr,
GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
if (queue)
@@ -882,7 +884,8 @@ static struct virtqueue *vring_create_virtqueue_split(
if (!queue) {
/* Try to get a single page. You are my only hope! */
- queue = vring_alloc_queue(vdev, vring_size(num, vring_align),
+ queue = vring_alloc_queue(vdev, parent,
+ vring_size(num, vring_align),
&dma_addr, GFP_KERNEL|__GFP_ZERO);
}
if (!queue)
@@ -1569,10 +1572,11 @@ static struct virtqueue *vring_create_virtqueue_packed(
dma_addr_t ring_dma_addr, driver_event_dma_addr, device_event_dma_addr;
size_t ring_size_in_bytes, event_size_in_bytes;
unsigned int i;
+ struct device *parent = vdev->dev.parent;
ring_size_in_bytes = num * sizeof(struct vring_packed_desc);
- ring = vring_alloc_queue(vdev, ring_size_in_bytes,
+ ring = vring_alloc_queue(vdev, parent, ring_size_in_bytes,
&ring_dma_addr,
GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
if (!ring)
@@ -1580,13 +1584,13 @@ static struct virtqueue *vring_create_virtqueue_packed(
event_size_in_bytes = sizeof(struct vring_packed_desc_event);
- driver = vring_alloc_queue(vdev, event_size_in_bytes,
+ driver = vring_alloc_queue(vdev, parent, event_size_in_bytes,
&driver_event_dma_addr,
GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
if (!driver)
goto err_driver;
- device = vring_alloc_queue(vdev, event_size_in_bytes,
+ device = vring_alloc_queue(vdev, parent, event_size_in_bytes,
&device_event_dma_addr,
GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
if (!device)
--
2.19.1
next prev parent reply other threads:[~2019-10-29 10:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 10:58 [RFC PATCH 0/2] virtio: allow per vq DMA domain Jason Wang
2019-10-29 10:58 ` Jason Wang [this message]
2019-10-29 10:58 ` [RFC PATCH 2/2] virtio: allow query vq parent device Jason Wang
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=20191029105843.12061-2-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=cunming.liang@intel.com \
--cc=lingshan.zhu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=zhihong.wang@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).