mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Longpeng(Mike)" <longpeng2@huawei.com>
To: <mst@redhat.com>, <jasowang@redhat.com>
Cc: <stefanha@redhat.com>, <sgarzare@redhat.com>,
	<arei.gonglei@huawei.com>, <yechuan@huawei.com>,
	<huangzhichao@huawei.com>,
	<virtualization@lists.linux-foundation.org>,
	<linux-kernel@vger.kernel.org>, <eperezma@redhat.com>,
	Longpeng <longpeng2@huawei.com>
Subject: [PATCH v3 1/2] vdpa: support specify the pgprot of vq notification area
Date: Sun, 29 Jan 2023 10:50:33 +0800	[thread overview]
Message-ID: <20230129025034.2000-2-longpeng2@huawei.com> (raw)
In-Reply-To: <20230129025034.2000-1-longpeng2@huawei.com>

From: Longpeng <longpeng2@huawei.com>

Adds get_vq_notification_pgprot operation to vdpa_config_ops to support
specify the pgprot of vq norification area. It's an optional operation,
the vdpa framework will treat the pgprot of vq notification area as
noncached as default as usual.
---
 drivers/vhost/vdpa.c | 4 +++-
 include/linux/vdpa.h | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 166044642fd5..036fe88425c8 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -1263,7 +1263,9 @@ static vm_fault_t vhost_vdpa_fault(struct vm_fault *vmf)
 
 	notify = ops->get_vq_notification(vdpa, index);
 
-	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+	vma->vm_page_prot = ops->get_vq_notification_pgprot ?
+		ops->get_vq_notification_pgprot(vdpa, index, vma->vm_page_prot) :
+		pgprot_noncached(vma->vm_page_prot);
 	if (remap_pfn_range(vma, vmf->address & PAGE_MASK,
 			    PFN_DOWN(notify.addr), PAGE_SIZE,
 			    vma->vm_page_prot))
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index 6d0f5e4e82c2..07fcf5e6abc8 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -169,6 +169,12 @@ struct vdpa_map_file {
  *				@vdev: vdpa device
  *				@idx: virtqueue index
  *				Returns the notifcation area
+ * @get_vq_notification_pgprot:	Get the pgprot of the vq's notification area (optional)
+ *				@vdev: vdpa device
+ *				@idx: virtqueue index
+ *				@prot: original page protection value of the
+ *				       notification area
+ *				Returns pgprot_t: the pgprot of the notification area
  * @get_vq_irq:			Get the irq number of a virtqueue (optional,
  *				but must implemented if require vq irq offloading)
  *				@vdev: vdpa device
@@ -305,6 +311,9 @@ struct vdpa_config_ops {
 				   struct netlink_ext_ack *extack);
 	struct vdpa_notification_area
 	(*get_vq_notification)(struct vdpa_device *vdev, u16 idx);
+	pgprot_t (*get_vq_notification_pgprot)(struct vdpa_device *vdev,
+					       u16 idx,
+					       pgprot_t prot);
 	/* vq irq is not expected to be changed once DRIVER_OK is set */
 	int (*get_vq_irq)(struct vdpa_device *vdev, u16 idx);
 
-- 
2.23.0


  reply	other threads:[~2023-01-29  2:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-29  2:50 [PATCH v3 0/2] vdpasim: support doorbell mapping Longpeng(Mike)
2023-01-29  2:50 ` Longpeng(Mike) [this message]
2023-01-29  6:03   ` [PATCH v3 1/2] vdpa: support specify the pgprot of vq notification area Jason Wang
2023-01-29  2:50 ` [PATCH v3 2/2] vdpasim: support doorbell mapping Longpeng(Mike)
2023-01-29  6:19   ` Jason Wang
2023-02-13 12:05     ` Michael S. Tsirkin
2023-02-14  2:05       ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)

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=20230129025034.2000-2-longpeng2@huawei.com \
    --to=longpeng2@huawei.com \
    --cc=arei.gonglei@huawei.com \
    --cc=eperezma@redhat.com \
    --cc=huangzhichao@huawei.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=yechuan@huawei.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

all inboxes | Powered by JetHome®