lkml.org 
[lkml]   [2023]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 1/2] vdpa: support specify the pgprot of vq notification area
Date
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
\
 
 \ /
  Last update: 2023-03-27 00:00    [W:0.043 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site