[PATCH 2/2] drm/i915/gvt: Change fb_info->size from pages to bytes
Zhenyu Wang
zhenyuw at linux.intel.com
Thu Mar 21 07:52:54 UTC 2019
On 2019.03.19 10:28:45 +0800, Xiong Zhang wrote:
> fb_info->size is in pages, but some function need bytes when it
> is a parameter. Such as:
> a. intel_gvt_ggtt_validate_range() according to function definition
> b. vfio_device_gfx_plane_info->size according to the comment of
> its definition
>
> This patch change fb_info->size into bytes.
>
I think we should keep plane's size in info->size instead of assigning
casted page size there, but just round up to page size when create dmabuf
object, then actual object size is kept in obj->size.
> Signed-off-by: Xiong Zhang <xiong.y.zhang at intel.com>
> ---
> drivers/gpu/drm/i915/gvt/dmabuf.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
> index 5d887f7..90d2ef6 100644
> --- a/drivers/gpu/drm/i915/gvt/dmabuf.c
> +++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
> @@ -45,6 +45,7 @@ static int vgpu_gem_get_pages(
> int i, ret;
> gen8_pte_t __iomem *gtt_entries;
> struct intel_vgpu_fb_info *fb_info;
> + u32 page_num;
>
> fb_info = (struct intel_vgpu_fb_info *)obj->gvt_info;
> if (WARN_ON(!fb_info))
> @@ -54,14 +55,15 @@ static int vgpu_gem_get_pages(
> if (unlikely(!st))
> return -ENOMEM;
>
> - ret = sg_alloc_table(st, fb_info->size, GFP_KERNEL);
> + page_num = fb_info->size >> PAGE_SHIFT;
> + ret = sg_alloc_table(st, page_num, GFP_KERNEL);
> if (ret) {
> kfree(st);
> return ret;
> }
> gtt_entries = (gen8_pte_t __iomem *)dev_priv->ggtt.gsm +
> (fb_info->start >> PAGE_SHIFT);
> - for_each_sg(st->sgl, sg, fb_info->size, i) {
> + for_each_sg(st->sgl, sg, page_num, i) {
> sg->offset = 0;
> sg->length = PAGE_SIZE;
> sg_dma_address(sg) =
> @@ -157,8 +159,7 @@ static struct drm_i915_gem_object *vgpu_create_gem(struct drm_device *dev,
> if (obj == NULL)
> return NULL;
>
> - drm_gem_private_object_init(dev, &obj->base,
> - info->size << PAGE_SHIFT);
> + drm_gem_private_object_init(dev, &obj->base, info->size);
> i915_gem_object_init(obj, &intel_vgpu_gem_ops);
>
> obj->read_domains = I915_GEM_DOMAIN_GTT;
> @@ -210,6 +211,7 @@ static int vgpu_get_plane_info(struct drm_device *dev,
> struct intel_vgpu_primary_plane_format p;
> struct intel_vgpu_cursor_plane_format c;
> int ret;
> + u32 page_num;
>
> if (plane_id == DRM_PLANE_TYPE_PRIMARY) {
> ret = intel_vgpu_decode_primary_plane(vgpu, &p);
> @@ -264,8 +266,10 @@ static int vgpu_get_plane_info(struct drm_device *dev,
> return -EINVAL;
> }
>
> - info->size = (info->stride * info->height + PAGE_SIZE - 1)
> + // align to page
> + page_num = (info->stride * info->height + PAGE_SIZE - 1)
> >> PAGE_SHIFT;
> + info->size = page_num << PAGE_SHIFT;
> if (info->size == 0) {
> gvt_vgpu_err("fb size is zero\n");
> return -EINVAL;
> @@ -275,7 +279,7 @@ static int vgpu_get_plane_info(struct drm_device *dev,
> gvt_vgpu_err("Not aligned fb address:0x%llx\n", info->start);
> return -EFAULT;
> }
> - if (((info->start >> PAGE_SHIFT) + info->size) >
> + if (((info->start >> PAGE_SHIFT) + page_num) >
> ggtt_total_entries(&dev_priv->ggtt)) {
> gvt_vgpu_err("Invalid GTT offset or size\n");
> return -EFAULT;
> --
> 2.7.4
>
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20190321/3075f98c/attachment.sig>
More information about the intel-gvt-dev
mailing list