Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'drm-misc-next-2019-03-28-1' of git://anongit.freedesktop.org/drm/drm-misc into drm-next

drm-misc-next for 5.2:

UAPI Changes:
- Remove unused DRM_DISPLAY_INFO_LEN (Ville)

Cross-subsystem Changes:
- None

Core Changes:
- Fix compilation when CONFIG_FBDEV not selected (Daniel)
- fbdev: Make skip_vt_switch default (Daniel)
- Merge fb_helper_fill_fix, fb_helper_fill_var into fb_helper_fill_info (Daniel)
- Remove unused fields in connector, display_info, and edid_quirks (Ville)

Driver Changes:
- virtio: package function args in virtio_gpu_object_params (Gerd)
- vkms: Fix potential NULL-dereference bug (Kangjie)

Signed-off-by: Dave Airlie <airlied@redhat.com>

From: Sean Paul <sean@poorly.run>
Link: https://patchwork.freedesktop.org/patch/msgid/20190328183045.GA44823@art_vandelay

+292 -442
-1
Documentation/gpu/kms-properties.csv
··· 17 17 ,Virtual GPU,“suggested X”,RANGE,"Min=0, Max=0xffffffff",Connector,property to suggest an X offset for a connector 18 18 ,,“suggested Y”,RANGE,"Min=0, Max=0xffffffff",Connector,property to suggest an Y offset for a connector 19 19 ,Optional,"""aspect ratio""",ENUM,"{ ""None"", ""4:3"", ""16:9"" }",Connector,TDB 20 - ,Optional,"""content type""",ENUM,"{ ""No Data"", ""Graphics"", ""Photo"", ""Cinema"", ""Game"" }",Connector,TBD 21 20 i915,Generic,"""Broadcast RGB""",ENUM,"{ ""Automatic"", ""Full"", ""Limited 16:235"" }",Connector,"When this property is set to Limited 16:235 and CTM is set, the hardware will be programmed with the result of the multiplication of CTM by the limited range matrix to ensure the pixels normaly in the range 0..1.0 are remapped to the range 16/255..235/255." 22 21 ,,“audio”,ENUM,"{ ""force-dvi"", ""off"", ""auto"", ""on"" }",Connector,TBD 23 22 ,SDVO-TV,“mode”,ENUM,"{ ""NTSC_M"", ""NTSC_J"", ""NTSC_443"", ""PAL_B"" } etc.",Connector,TBD
+8 -17
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
··· 49 49 static int 50 50 amdgpufb_open(struct fb_info *info, int user) 51 51 { 52 - struct amdgpu_fbdev *rfbdev = info->par; 53 - struct amdgpu_device *adev = rfbdev->adev; 54 - int ret = pm_runtime_get_sync(adev->ddev->dev); 52 + struct drm_fb_helper *fb_helper = info->par; 53 + int ret = pm_runtime_get_sync(fb_helper->dev->dev); 55 54 if (ret < 0 && ret != -EACCES) { 56 - pm_runtime_mark_last_busy(adev->ddev->dev); 57 - pm_runtime_put_autosuspend(adev->ddev->dev); 55 + pm_runtime_mark_last_busy(fb_helper->dev->dev); 56 + pm_runtime_put_autosuspend(fb_helper->dev->dev); 58 57 return ret; 59 58 } 60 59 return 0; ··· 62 63 static int 63 64 amdgpufb_release(struct fb_info *info, int user) 64 65 { 65 - struct amdgpu_fbdev *rfbdev = info->par; 66 - struct amdgpu_device *adev = rfbdev->adev; 66 + struct drm_fb_helper *fb_helper = info->par; 67 67 68 - pm_runtime_mark_last_busy(adev->ddev->dev); 69 - pm_runtime_put_autosuspend(adev->ddev->dev); 68 + pm_runtime_mark_last_busy(fb_helper->dev->dev); 69 + pm_runtime_put_autosuspend(fb_helper->dev->dev); 70 70 return 0; 71 71 } 72 72 ··· 231 233 goto out; 232 234 } 233 235 234 - info->par = rfbdev; 235 - info->skip_vt_switch = true; 236 - 237 236 ret = amdgpu_display_framebuffer_init(adev->ddev, &rfbdev->rfb, 238 237 &mode_cmd, gobj); 239 238 if (ret) { ··· 243 248 /* setup helper */ 244 249 rfbdev->helper.fb = fb; 245 250 246 - strcpy(info->fix.id, "amdgpudrmfb"); 247 - 248 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 249 - 250 251 info->fbops = &amdgpufb_ops; 251 252 252 253 tmp = amdgpu_bo_gpu_offset(abo) - adev->gmc.vram_start; ··· 251 260 info->screen_base = amdgpu_bo_kptr(abo); 252 261 info->screen_size = amdgpu_bo_size(abo); 253 262 254 - drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height); 263 + drm_fb_helper_fill_info(info, &rfbdev->helper, sizes); 255 264 256 265 /* setup aperture base/size for vesafb takeover */ 257 266 info->apertures->ranges[0].base = adev->ddev->mode_config.fb_base;
+1 -5
drivers/gpu/drm/armada/armada_fbdev.c
··· 78 78 goto err_fballoc; 79 79 } 80 80 81 - strlcpy(info->fix.id, "armada-drmfb", sizeof(info->fix.id)); 82 - info->par = fbh; 83 81 info->fbops = &armada_fb_ops; 84 82 info->fix.smem_start = obj->phys_addr; 85 83 info->fix.smem_len = obj->obj.size; ··· 85 87 info->screen_base = ptr; 86 88 fbh->fb = &dfb->fb; 87 89 88 - drm_fb_helper_fill_fix(info, dfb->fb.pitches[0], 89 - dfb->fb.format->depth); 90 - drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height); 90 + drm_fb_helper_fill_info(info, fbh, sizes); 91 91 92 92 DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08llx\n", 93 93 dfb->fb.width, dfb->fb.height, dfb->fb.format->cpp[0] * 8,
+1 -1
drivers/gpu/drm/ast/ast_drv.h
··· 259 259 }; 260 260 261 261 struct ast_fbdev { 262 - struct drm_fb_helper helper; 262 + struct drm_fb_helper helper; /* must be first */ 263 263 struct ast_framebuffer afb; 264 264 void *sysram; 265 265 int size;
+1 -6
drivers/gpu/drm/ast/ast_fb.c
··· 217 217 ret = PTR_ERR(info); 218 218 goto out; 219 219 } 220 - info->par = afbdev; 221 - 222 220 ret = ast_framebuffer_init(dev, &afbdev->afb, &mode_cmd, gobj); 223 221 if (ret) 224 222 goto out; ··· 227 229 fb = &afbdev->afb.base; 228 230 afbdev->helper.fb = fb; 229 231 230 - strcpy(info->fix.id, "astdrmfb"); 231 - 232 232 info->fbops = &astfb_ops; 233 233 234 234 info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0); 235 235 info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0); 236 236 237 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 238 - drm_fb_helper_fill_var(info, &afbdev->helper, sizes->fb_width, sizes->fb_height); 237 + drm_fb_helper_fill_info(info, &afbdev->helper, sizes); 239 238 240 239 info->screen_base = sysram; 241 240 info->screen_size = size;
+1 -1
drivers/gpu/drm/cirrus/cirrus_drv.h
··· 143 143 144 144 145 145 struct cirrus_fbdev { 146 - struct drm_fb_helper helper; 146 + struct drm_fb_helper helper; /* must be first */ 147 147 struct drm_framebuffer *gfb; 148 148 void *sysram; 149 149 int size;
+1 -7
drivers/gpu/drm/cirrus/cirrus_fbdev.c
··· 195 195 goto err_vfree; 196 196 } 197 197 198 - info->par = gfbdev; 199 - 200 198 fb = kzalloc(sizeof(*fb), GFP_KERNEL); 201 199 if (!fb) { 202 200 ret = -ENOMEM; ··· 212 214 /* setup helper */ 213 215 gfbdev->helper.fb = fb; 214 216 215 - strcpy(info->fix.id, "cirrusdrmfb"); 216 - 217 217 info->fbops = &cirrusfb_ops; 218 218 219 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 220 - drm_fb_helper_fill_var(info, &gfbdev->helper, sizes->fb_width, 221 - sizes->fb_height); 219 + drm_fb_helper_fill_info(info, &gfbdev->helper, sizes); 222 220 223 221 /* setup aperture base/size for vesafb takeover */ 224 222 info->apertures->ranges[0].base = cdev->dev->mode_config.fb_base;
-10
drivers/gpu/drm/drm_edid.c
··· 68 68 * maximum size and use that. 69 69 */ 70 70 #define EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE (1 << 4) 71 - /* Monitor forgot to set the first detailed is preferred bit. */ 72 - #define EDID_QUIRK_FIRST_DETAILED_PREFERRED (1 << 5) 73 71 /* use +hsync +vsync for detailed mode */ 74 72 #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6) 75 73 /* Force reduced-blanking timings for detailed modes */ ··· 105 107 { "ACR", 44358, EDID_QUIRK_PREFER_LARGE_60 }, 106 108 /* Acer F51 */ 107 109 { "API", 0x7602, EDID_QUIRK_PREFER_LARGE_60 }, 108 - /* Unknown Acer */ 109 - { "ACR", 2423, EDID_QUIRK_FIRST_DETAILED_PREFERRED }, 110 110 111 111 /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ 112 112 { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, ··· 140 144 /* LG Philips LCD LP154W01-A5 */ 141 145 { "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, 142 146 { "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, 143 - 144 - /* Philips 107p5 CRT */ 145 - { "PHL", 57364, EDID_QUIRK_FIRST_DETAILED_PREFERRED }, 146 - 147 - /* Proview AY765C */ 148 - { "PTS", 765, EDID_QUIRK_FIRST_DETAILED_PREFERRED }, 149 147 150 148 /* Samsung SyncMaster 205BW. Note: irony */ 151 149 { "SAM", 541, EDID_QUIRK_DETAILED_SYNC_PP },
+39 -41
drivers/gpu/drm/drm_fb_helper.c
··· 934 934 } 935 935 936 936 fb_helper->fbdev = info; 937 + info->skip_vt_switch = true; 937 938 938 939 return info; 939 940 ··· 2037 2036 return 0; 2038 2037 } 2039 2038 2040 - /** 2041 - * drm_fb_helper_fill_fix - initializes fixed fbdev information 2042 - * @info: fbdev registered by the helper 2043 - * @pitch: desired pitch 2044 - * @depth: desired depth 2045 - * 2046 - * Helper to fill in the fixed fbdev information useful for a non-accelerated 2047 - * fbdev emulations. Drivers which support acceleration methods which impose 2048 - * additional constraints need to set up their own limits. 2049 - * 2050 - * Drivers should call this (or their equivalent setup code) from their 2051 - * &drm_fb_helper_funcs.fb_probe callback. 2052 - */ 2053 - void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, 2054 - uint32_t depth) 2039 + static void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, 2040 + uint32_t depth) 2055 2041 { 2056 2042 info->fix.type = FB_TYPE_PACKED_PIXELS; 2057 2043 info->fix.visual = depth == 8 ? FB_VISUAL_PSEUDOCOLOR : ··· 2053 2065 2054 2066 info->fix.line_length = pitch; 2055 2067 } 2056 - EXPORT_SYMBOL(drm_fb_helper_fill_fix); 2057 2068 2058 - /** 2059 - * drm_fb_helper_fill_var - initalizes variable fbdev information 2060 - * @info: fbdev instance to set up 2061 - * @fb_helper: fb helper instance to use as template 2062 - * @fb_width: desired fb width 2063 - * @fb_height: desired fb height 2064 - * 2065 - * Sets up the variable fbdev metainformation from the given fb helper instance 2066 - * and the drm framebuffer allocated in &drm_fb_helper.fb. 2067 - * 2068 - * Drivers should call this (or their equivalent setup code) from their 2069 - * &drm_fb_helper_funcs.fb_probe callback after having allocated the fbdev 2070 - * backing storage framebuffer. 2071 - */ 2072 - void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper, 2073 - uint32_t fb_width, uint32_t fb_height) 2069 + static void drm_fb_helper_fill_var(struct fb_info *info, 2070 + struct drm_fb_helper *fb_helper, 2071 + uint32_t fb_width, uint32_t fb_height) 2074 2072 { 2075 2073 struct drm_framebuffer *fb = fb_helper->fb; 2076 2074 ··· 2076 2102 info->var.xres = fb_width; 2077 2103 info->var.yres = fb_height; 2078 2104 } 2079 - EXPORT_SYMBOL(drm_fb_helper_fill_var); 2105 + 2106 + /** 2107 + * drm_fb_helper_fill_info - initializes fbdev information 2108 + * @info: fbdev instance to set up 2109 + * @fb_helper: fb helper instance to use as template 2110 + * @sizes: describes fbdev size and scanout surface size 2111 + * 2112 + * Sets up the variable and fixed fbdev metainformation from the given fb helper 2113 + * instance and the drm framebuffer allocated in &drm_fb_helper.fb. 2114 + * 2115 + * Drivers should call this (or their equivalent setup code) from their 2116 + * &drm_fb_helper_funcs.fb_probe callback after having allocated the fbdev 2117 + * backing storage framebuffer. 2118 + */ 2119 + void drm_fb_helper_fill_info(struct fb_info *info, 2120 + struct drm_fb_helper *fb_helper, 2121 + struct drm_fb_helper_surface_size *sizes) 2122 + { 2123 + struct drm_framebuffer *fb = fb_helper->fb; 2124 + 2125 + drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 2126 + drm_fb_helper_fill_var(info, fb_helper, 2127 + sizes->fb_width, sizes->fb_height); 2128 + 2129 + info->par = fb_helper; 2130 + snprintf(info->fix.id, sizeof(info->fix.id), "%sdrmfb", 2131 + fb_helper->dev->driver->name); 2132 + 2133 + } 2134 + EXPORT_SYMBOL(drm_fb_helper_fill_info); 2080 2135 2081 2136 static int drm_fb_helper_probe_connector_modes(struct drm_fb_helper *fb_helper, 2082 2137 uint32_t maxX, ··· 2783 2780 * 2784 2781 * This function will call down into the &drm_fb_helper_funcs.fb_probe callback 2785 2782 * to let the driver allocate and initialize the fbdev info structure and the 2786 - * drm framebuffer used to back the fbdev. drm_fb_helper_fill_var() and 2787 - * drm_fb_helper_fill_fix() are provided as helpers to setup simple default 2788 - * values for the fbdev info structure. 2783 + * drm framebuffer used to back the fbdev. drm_fb_helper_fill_info() is provided 2784 + * as a helper to setup simple default values for the fbdev info structure. 2789 2785 * 2790 2786 * HANG DEBUGGING: 2791 2787 * ··· 3153 3151 if (IS_ERR(fbi)) 3154 3152 return PTR_ERR(fbi); 3155 3153 3156 - fbi->par = fb_helper; 3157 3154 fbi->fbops = &drm_fbdev_fb_ops; 3158 3155 fbi->screen_size = fb->height * fb->pitches[0]; 3159 3156 fbi->fix.smem_len = fbi->screen_size; ··· 3163 3162 fbi->fix.smem_start = 3164 3163 page_to_phys(virt_to_page(fbi->screen_buffer)); 3165 3164 #endif 3166 - strcpy(fbi->fix.id, "DRM emulated"); 3167 - 3168 - drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); 3169 - drm_fb_helper_fill_var(fbi, fb_helper, sizes->fb_width, sizes->fb_height); 3165 + drm_fb_helper_fill_info(fbi, fb_helper, sizes); 3170 3166 3171 3167 if (fb->funcs->dirty) { 3172 3168 struct fb_ops *fbops;
+1 -3
drivers/gpu/drm/exynos/exynos_drm_fbdev.c
··· 87 87 return PTR_ERR(fbi); 88 88 } 89 89 90 - fbi->par = helper; 91 90 fbi->fbops = &exynos_drm_fb_ops; 92 91 93 - drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); 94 - drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); 92 + drm_fb_helper_fill_info(fbi, helper, sizes); 95 93 96 94 nr_pages = exynos_gem->size >> PAGE_SHIFT; 97 95
+1 -6
drivers/gpu/drm/gma500/framebuffer.c
··· 389 389 ret = PTR_ERR(info); 390 390 goto out; 391 391 } 392 - info->par = fbdev; 393 392 394 393 mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth); 395 394 ··· 400 401 psbfb->fbdev = info; 401 402 402 403 fbdev->psb_fb_helper.fb = fb; 403 - 404 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 405 - strcpy(info->fix.id, "psbdrmfb"); 406 404 407 405 if (dev_priv->ops->accel_2d && pitch_lines > 8) /* 2D engine */ 408 406 info->fbops = &psbfb_ops; ··· 423 427 info->apertures->ranges[0].size = dev_priv->gtt.stolen_size; 424 428 } 425 429 426 - drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper, 427 - sizes->fb_width, sizes->fb_height); 430 + drm_fb_helper_fill_info(info, &fbdev->psb_fb_helper, sizes); 428 431 429 432 info->fix.mmio_start = pci_resource_start(dev->pdev, 0); 430 433 info->fix.mmio_len = pci_resource_len(dev->pdev, 0);
+1 -1
drivers/gpu/drm/gma500/framebuffer.h
··· 34 34 }; 35 35 36 36 struct psb_fbdev { 37 - struct drm_fb_helper psb_fb_helper; 37 + struct drm_fb_helper psb_fb_helper; /* must be first */ 38 38 struct psb_framebuffer pfb; 39 39 }; 40 40
+1 -1
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
··· 31 31 }; 32 32 33 33 struct hibmc_fbdev { 34 - struct drm_fb_helper helper; 34 + struct drm_fb_helper helper; /* must be first */ 35 35 struct hibmc_framebuffer *fb; 36 36 int size; 37 37 };
+1 -8
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
··· 116 116 goto out_release_fbi; 117 117 } 118 118 119 - info->par = hi_fbdev; 120 - 121 119 hi_fbdev->fb = hibmc_framebuffer_init(priv->dev, &mode_cmd, gobj); 122 120 if (IS_ERR(hi_fbdev->fb)) { 123 121 ret = PTR_ERR(hi_fbdev->fb); ··· 127 129 priv->fbdev->size = size; 128 130 hi_fbdev->helper.fb = &hi_fbdev->fb->fb; 129 131 130 - strcpy(info->fix.id, "hibmcdrmfb"); 131 - 132 132 info->fbops = &hibmc_drm_fb_ops; 133 133 134 - drm_fb_helper_fill_fix(info, hi_fbdev->fb->fb.pitches[0], 135 - hi_fbdev->fb->fb.format->depth); 136 - drm_fb_helper_fill_var(info, &priv->fbdev->helper, sizes->fb_width, 137 - sizes->fb_height); 134 + drm_fb_helper_fill_info(info, &priv->fbdev->helper, sizes); 138 135 139 136 info->screen_base = bo->kmap.virtual; 140 137 info->screen_size = size;
-7
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c
··· 33 33 return MODE_OK; 34 34 } 35 35 36 - static struct drm_encoder * 37 - hibmc_connector_best_encoder(struct drm_connector *connector) 38 - { 39 - return drm_encoder_find(connector->dev, NULL, connector->encoder_ids[0]); 40 - } 41 - 42 36 static const struct drm_connector_helper_funcs 43 37 hibmc_connector_helper_funcs = { 44 38 .get_modes = hibmc_connector_get_modes, 45 39 .mode_valid = hibmc_connector_mode_valid, 46 - .best_encoder = hibmc_connector_best_encoder, 47 40 }; 48 41 49 42 static const struct drm_connector_funcs hibmc_connector_funcs = {
-1
drivers/gpu/drm/i915/i915_debugfs.c
··· 2866 2866 if (connector->status == connector_status_disconnected) 2867 2867 return; 2868 2868 2869 - seq_printf(m, "\tname: %s\n", connector->display_info.name); 2870 2869 seq_printf(m, "\tphysical dimensions: %dx%dmm\n", 2871 2870 connector->display_info.width_mm, 2872 2871 connector->display_info.height_mm);
+1 -9
drivers/gpu/drm/i915/intel_fbdev.c
··· 235 235 goto out_unpin; 236 236 } 237 237 238 - info->par = helper; 239 - 240 238 ifbdev->helper.fb = fb; 241 - 242 - strcpy(info->fix.id, "inteldrmfb"); 243 239 244 240 info->fbops = &intelfb_ops; 245 241 ··· 255 259 info->screen_base = vaddr; 256 260 info->screen_size = vma->node.size; 257 261 258 - /* This driver doesn't need a VT switch to restore the mode on resume */ 259 - info->skip_vt_switch = true; 260 - 261 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 262 - drm_fb_helper_fill_var(info, &ifbdev->helper, sizes->fb_width, sizes->fb_height); 262 + drm_fb_helper_fill_info(info, &ifbdev->helper, sizes); 263 263 264 264 /* If the object is shmemfs backed, it will have given us zeroed pages. 265 265 * If the object is stolen however, it will be full of whatever
+1 -1
drivers/gpu/drm/mgag200/mgag200_drv.h
··· 113 113 }; 114 114 115 115 struct mga_fbdev { 116 - struct drm_fb_helper helper; 116 + struct drm_fb_helper helper; /* must be first */ 117 117 struct mga_framebuffer mfb; 118 118 void *sysram; 119 119 int size;
+1 -7
drivers/gpu/drm/mgag200/mgag200_fb.c
··· 195 195 goto err_alloc_fbi; 196 196 } 197 197 198 - info->par = mfbdev; 199 - 200 198 ret = mgag200_framebuffer_init(dev, &mfbdev->mfb, &mode_cmd, gobj); 201 199 if (ret) 202 200 goto err_alloc_fbi; ··· 207 209 /* setup helper */ 208 210 mfbdev->helper.fb = fb; 209 211 210 - strcpy(info->fix.id, "mgadrmfb"); 211 - 212 212 info->fbops = &mgag200fb_ops; 213 213 214 214 /* setup aperture base/size for vesafb takeover */ 215 215 info->apertures->ranges[0].base = mdev->dev->mode_config.fb_base; 216 216 info->apertures->ranges[0].size = mdev->mc.vram_size; 217 217 218 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 219 - drm_fb_helper_fill_var(info, &mfbdev->helper, sizes->fb_width, 220 - sizes->fb_height); 218 + drm_fb_helper_fill_info(info, &mfbdev->helper, sizes); 221 219 222 220 info->screen_base = sysram; 223 221 info->screen_size = size;
+1 -5
drivers/gpu/drm/msm/msm_fbdev.c
··· 122 122 fbdev->fb = fb; 123 123 helper->fb = fb; 124 124 125 - fbi->par = helper; 126 125 fbi->fbops = &msm_fb_ops; 127 126 128 - strcpy(fbi->fix.id, "msm"); 129 - 130 - drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); 131 - drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); 127 + drm_fb_helper_fill_info(fbi, helper, sizes); 132 128 133 129 dev->mode_config.fb_base = paddr; 134 130
+1 -7
drivers/gpu/drm/nouveau/nouveau_fbcon.c
··· 365 365 ret = PTR_ERR(info); 366 366 goto out_unlock; 367 367 } 368 - info->skip_vt_switch = 1; 369 - 370 - info->par = fbcon; 371 368 372 369 /* setup helper */ 373 370 fbcon->helper.fb = &fb->base; 374 371 375 - strcpy(info->fix.id, "nouveaufb"); 376 372 if (!chan) 377 373 info->flags = FBINFO_HWACCEL_DISABLED; 378 374 else ··· 383 387 info->screen_base = nvbo_kmap_obj_iovirtual(fb->nvbo); 384 388 info->screen_size = fb->nvbo->bo.mem.num_pages << PAGE_SHIFT; 385 389 386 - drm_fb_helper_fill_fix(info, fb->base.pitches[0], 387 - fb->base.format->depth); 388 - drm_fb_helper_fill_var(info, &fbcon->helper, sizes->fb_width, sizes->fb_height); 390 + drm_fb_helper_fill_info(info, &fbcon->helper, sizes); 389 391 390 392 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ 391 393
+1 -1
drivers/gpu/drm/nouveau/nouveau_fbcon.h
··· 32 32 #include "nouveau_display.h" 33 33 34 34 struct nouveau_fbdev { 35 - struct drm_fb_helper helper; 35 + struct drm_fb_helper helper; /* must be first */ 36 36 unsigned int saved_flags; 37 37 struct nvif_object surf2d; 38 38 struct nvif_object clip;
+1 -5
drivers/gpu/drm/omapdrm/omap_fbdev.c
··· 183 183 fbdev->fb = fb; 184 184 helper->fb = fb; 185 185 186 - fbi->par = helper; 187 186 fbi->fbops = &omap_fb_ops; 188 187 189 - strcpy(fbi->fix.id, MODULE_NAME); 190 - 191 - drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); 192 - drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); 188 + drm_fb_helper_fill_info(fbi, helper, sizes); 193 189 194 190 dev->mode_config.fb_base = dma_addr; 195 191
-2
drivers/gpu/drm/panel/panel-arm-versatile.c
··· 264 264 struct versatile_panel *vpanel = to_versatile_panel(panel); 265 265 struct drm_display_mode *mode; 266 266 267 - strncpy(connector->display_info.name, vpanel->panel_type->name, 268 - DRM_DISPLAY_INFO_LEN); 269 267 connector->display_info.width_mm = vpanel->panel_type->width_mm; 270 268 connector->display_info.height_mm = vpanel->panel_type->height_mm; 271 269 connector->display_info.bus_flags = vpanel->panel_type->bus_flags;
-2
drivers/gpu/drm/panel/panel-ilitek-ili9322.c
··· 662 662 struct ili9322 *ili = panel_to_ili9322(panel); 663 663 struct drm_display_mode *mode; 664 664 665 - strncpy(connector->display_info.name, "ILI9322 TFT LCD driver\0", 666 - DRM_DISPLAY_INFO_LEN); 667 665 connector->display_info.width_mm = ili->conf->width_mm; 668 666 connector->display_info.height_mm = ili->conf->height_mm; 669 667
-1
drivers/gpu/drm/panel/panel-olimex-lcd-olinuxino.c
··· 190 190 num++; 191 191 } 192 192 193 - memcpy(connector->display_info.name, lcd_info->name, 32); 194 193 connector->display_info.width_mm = lcd_info->width_mm; 195 194 connector->display_info.height_mm = lcd_info->height_mm; 196 195 connector->display_info.bpc = lcd_info->bpc;
-3
drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
··· 148 148 struct drm_connector *connector = panel->connector; 149 149 struct drm_display_mode *mode; 150 150 151 - strncpy(connector->display_info.name, "Samsung S6D16D0\0", 152 - DRM_DISPLAY_INFO_LEN); 153 - 154 151 mode = drm_mode_duplicate(panel->drm, &samsung_s6d16d0_mode); 155 152 if (!mode) { 156 153 DRM_ERROR("bad mode or failed to add mode\n");
-2
drivers/gpu/drm/panel/panel-tpo-tpg110.c
··· 390 390 struct tpg110 *tpg = to_tpg110(panel); 391 391 struct drm_display_mode *mode; 392 392 393 - strncpy(connector->display_info.name, tpg->panel_mode->name, 394 - DRM_DISPLAY_INFO_LEN); 395 393 connector->display_info.width_mm = tpg->width; 396 394 connector->display_info.height_mm = tpg->height; 397 395 connector->display_info.bus_flags = tpg->panel_mode->bus_flags;
+4 -7
drivers/gpu/drm/radeon/radeon_fb.c
··· 42 42 * the helper contains a pointer to radeon framebuffer baseclass. 43 43 */ 44 44 struct radeon_fbdev { 45 - struct drm_fb_helper helper; 45 + struct drm_fb_helper helper; /* must be first */ 46 46 struct drm_framebuffer fb; 47 47 struct radeon_device *rdev; 48 48 }; ··· 244 244 goto out; 245 245 } 246 246 247 - info->par = rfbdev; 247 + /* radeon resume is fragile and needs a vt switch to help it along */ 248 + info->skip_vt_switch = false; 248 249 249 250 ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->fb, &mode_cmd, gobj); 250 251 if (ret) { ··· 260 259 261 260 memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo)); 262 261 263 - strcpy(info->fix.id, "radeondrmfb"); 264 - 265 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 266 - 267 262 info->fbops = &radeonfb_ops; 268 263 269 264 tmp = radeon_bo_gpu_offset(rbo) - rdev->mc.vram_start; ··· 268 271 info->screen_base = rbo->kptr; 269 272 info->screen_size = radeon_bo_size(rbo); 270 273 271 - drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height); 274 + drm_fb_helper_fill_info(info, &rfbdev->helper, sizes); 272 275 273 276 /* setup aperture base/size for vesafb takeover */ 274 277 info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
+1 -5
drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
··· 90 90 goto out; 91 91 } 92 92 93 - fbi->par = helper; 94 93 fbi->fbops = &rockchip_drm_fbdev_ops; 95 94 96 95 fb = helper->fb; 97 - drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); 98 - drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); 96 + drm_fb_helper_fill_info(fbi, helper, sizes); 99 97 100 98 offset = fbi->var.xoffset * bytes_per_pixel; 101 99 offset += fbi->var.yoffset * fb->pitches[0]; ··· 107 109 fb->width, fb->height, fb->format->depth, 108 110 rk_obj->kvaddr, 109 111 offset, size); 110 - 111 - fbi->skip_vt_switch = true; 112 112 113 113 return 0; 114 114
+1 -3
drivers/gpu/drm/tegra/fb.c
··· 255 255 helper->fb = fb; 256 256 helper->fbdev = info; 257 257 258 - info->par = helper; 259 258 info->fbops = &tegra_fb_ops; 260 259 261 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 262 - drm_fb_helper_fill_var(info, helper, fb->width, fb->height); 260 + drm_fb_helper_fill_info(info, helper, sizes); 263 261 264 262 offset = info->var.xoffset * bytes_per_pixel + 265 263 info->var.yoffset * fb->pitches[0];
+2 -6
drivers/gpu/drm/udl/udl_fb.c
··· 32 32 module_param(fb_defio, int, S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP); 33 33 34 34 struct udl_fbdev { 35 - struct drm_fb_helper helper; 35 + struct drm_fb_helper helper; /* must be first */ 36 36 struct udl_framebuffer ufb; 37 37 int fb_count; 38 38 }; ··· 392 392 ret = PTR_ERR(info); 393 393 goto out_gfree; 394 394 } 395 - info->par = ufbdev; 396 395 397 396 ret = udl_framebuffer_init(dev, &ufbdev->ufb, &mode_cmd, obj); 398 397 if (ret) ··· 401 402 402 403 ufbdev->helper.fb = fb; 403 404 404 - strcpy(info->fix.id, "udldrmfb"); 405 - 406 405 info->screen_base = ufbdev->ufb.obj->vmapping; 407 406 info->fix.smem_len = size; 408 407 info->fix.smem_start = (unsigned long)ufbdev->ufb.obj->vmapping; 409 408 410 409 info->fbops = &udlfb_ops; 411 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 412 - drm_fb_helper_fill_var(info, &ufbdev->helper, sizes->fb_width, sizes->fb_height); 410 + drm_fb_helper_fill_info(info, &ufbdev->helper, sizes); 413 411 414 412 DRM_DEBUG_KMS("allocated %dx%d vmal %p\n", 415 413 fb->width, fb->height,
+1 -7
drivers/gpu/drm/vboxvideo/vbox_fb.c
··· 90 90 if (IS_ERR(info->screen_base)) 91 91 return PTR_ERR(info->screen_base); 92 92 93 - info->par = helper; 94 - 95 93 fb = &vbox->afb.base; 96 94 helper->fb = fb; 97 - 98 - strcpy(info->fix.id, "vboxdrmfb"); 99 95 100 96 info->fbops = &vboxfb_ops; 101 97 ··· 102 106 info->apertures->ranges[0].base = pci_resource_start(pdev, 0); 103 107 info->apertures->ranges[0].size = pci_resource_len(pdev, 0); 104 108 105 - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 106 - drm_fb_helper_fill_var(info, helper, sizes->fb_width, 107 - sizes->fb_height); 109 + drm_fb_helper_fill_info(info, helper, sizes); 108 110 109 111 gpu_addr = vbox_bo_gpu_offset(bo); 110 112 info->fix.smem_start = info->apertures->ranges[0].base + gpu_addr;
+26 -1
drivers/gpu/drm/virtio/virtgpu_debugfs.c
··· 28 28 29 29 #include "virtgpu_drv.h" 30 30 31 + static void virtio_add_bool(struct seq_file *m, const char *name, 32 + bool value) 33 + { 34 + seq_printf(m, "%-16s : %s\n", name, value ? "yes" : "no"); 35 + } 36 + 37 + static void virtio_add_int(struct seq_file *m, const char *name, 38 + int value) 39 + { 40 + seq_printf(m, "%-16s : %d\n", name, value); 41 + } 42 + 43 + static int virtio_gpu_features(struct seq_file *m, void *data) 44 + { 45 + struct drm_info_node *node = (struct drm_info_node *) m->private; 46 + struct virtio_gpu_device *vgdev = node->minor->dev->dev_private; 47 + 48 + virtio_add_bool(m, "virgl", vgdev->has_virgl_3d); 49 + virtio_add_bool(m, "edid", vgdev->has_edid); 50 + virtio_add_int(m, "cap sets", vgdev->num_capsets); 51 + virtio_add_int(m, "scanouts", vgdev->num_scanouts); 52 + return 0; 53 + } 54 + 31 55 static int 32 56 virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data) 33 57 { ··· 65 41 } 66 42 67 43 static struct drm_info_list virtio_gpu_debugfs_list[] = { 68 - { "irq_fence", virtio_gpu_debugfs_irq_info, 0, NULL }, 44 + { "virtio-gpu-features", virtio_gpu_features }, 45 + { "virtio-gpu-irq-fence", virtio_gpu_debugfs_irq_info, 0, NULL }, 69 46 }; 70 47 71 48 #define VIRTIO_GPU_DEBUGFS_ENTRIES ARRAY_SIZE(virtio_gpu_debugfs_list)
+33 -10
drivers/gpu/drm/virtio/virtgpu_drv.h
··· 50 50 #define DRIVER_MINOR 1 51 51 #define DRIVER_PATCHLEVEL 0 52 52 53 + struct virtio_gpu_object_params { 54 + uint32_t format; 55 + uint32_t width; 56 + uint32_t height; 57 + unsigned long size; 58 + bool dumb; 59 + /* 3d */ 60 + bool virgl; 61 + uint32_t target; 62 + uint32_t bind; 63 + uint32_t depth; 64 + uint32_t array_size; 65 + uint32_t last_level; 66 + uint32_t nr_samples; 67 + uint32_t flags; 68 + }; 69 + 53 70 struct virtio_gpu_object { 54 71 struct drm_gem_object gem_base; 55 72 uint32_t hw_res_handle; ··· 221 204 /* virtio_ioctl.c */ 222 205 #define DRM_VIRTIO_NUM_IOCTLS 10 223 206 extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS]; 207 + int virtio_gpu_object_list_validate(struct ww_acquire_ctx *ticket, 208 + struct list_head *head); 209 + void virtio_gpu_unref_list(struct list_head *head); 224 210 225 211 /* virtio_kms.c */ 226 212 int virtio_gpu_init(struct drm_device *dev); ··· 237 217 void virtio_gpu_gem_fini(struct virtio_gpu_device *vgdev); 238 218 int virtio_gpu_gem_create(struct drm_file *file, 239 219 struct drm_device *dev, 240 - uint64_t size, 220 + struct virtio_gpu_object_params *params, 241 221 struct drm_gem_object **obj_p, 242 222 uint32_t *handle_p); 243 223 int virtio_gpu_gem_object_open(struct drm_gem_object *obj, 244 224 struct drm_file *file); 245 225 void virtio_gpu_gem_object_close(struct drm_gem_object *obj, 246 226 struct drm_file *file); 247 - struct virtio_gpu_object *virtio_gpu_alloc_object(struct drm_device *dev, 248 - size_t size, bool kernel, 249 - bool pinned); 227 + struct virtio_gpu_object* 228 + virtio_gpu_alloc_object(struct drm_device *dev, 229 + struct virtio_gpu_object_params *params, 230 + struct virtio_gpu_fence *fence); 250 231 int virtio_gpu_mode_dumb_create(struct drm_file *file_priv, 251 232 struct drm_device *dev, 252 233 struct drm_mode_create_dumb *args); ··· 264 243 void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev); 265 244 void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, 266 245 struct virtio_gpu_object *bo, 267 - uint32_t format, 268 - uint32_t width, 269 - uint32_t height); 246 + struct virtio_gpu_object_params *params, 247 + struct virtio_gpu_fence *fence); 270 248 void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev, 271 249 uint32_t resource_id); 272 250 void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, ··· 324 304 void 325 305 virtio_gpu_cmd_resource_create_3d(struct virtio_gpu_device *vgdev, 326 306 struct virtio_gpu_object *bo, 327 - struct virtio_gpu_resource_create_3d *rc_3d); 307 + struct virtio_gpu_object_params *params, 308 + struct virtio_gpu_fence *fence); 328 309 void virtio_gpu_ctrl_ack(struct virtqueue *vq); 329 310 void virtio_gpu_cursor_ack(struct virtqueue *vq); 330 311 void virtio_gpu_fence_ack(struct virtqueue *vq); ··· 353 332 int virtio_gpu_mmap(struct file *filp, struct vm_area_struct *vma); 354 333 355 334 /* virtio_gpu_fence.c */ 335 + bool virtio_fence_signaled(struct dma_fence *f); 356 336 struct virtio_gpu_fence *virtio_gpu_fence_alloc( 357 337 struct virtio_gpu_device *vgdev); 358 338 int virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev, ··· 364 342 365 343 /* virtio_gpu_object */ 366 344 int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, 367 - unsigned long size, bool kernel, bool pinned, 368 - struct virtio_gpu_object **bo_ptr); 345 + struct virtio_gpu_object_params *params, 346 + struct virtio_gpu_object **bo_ptr, 347 + struct virtio_gpu_fence *fence); 369 348 void virtio_gpu_object_kunmap(struct virtio_gpu_object *bo); 370 349 int virtio_gpu_object_kmap(struct virtio_gpu_object *bo); 371 350 int virtio_gpu_object_get_sg_table(struct virtio_gpu_device *qdev,
+2 -2
drivers/gpu/drm/virtio/virtgpu_fence.c
··· 36 36 return "controlq"; 37 37 } 38 38 39 - static bool virtio_signaled(struct dma_fence *f) 39 + bool virtio_fence_signaled(struct dma_fence *f) 40 40 { 41 41 struct virtio_gpu_fence *fence = to_virtio_fence(f); 42 42 ··· 62 62 static const struct dma_fence_ops virtio_fence_ops = { 63 63 .get_driver_name = virtio_get_driver_name, 64 64 .get_timeline_name = virtio_get_timeline_name, 65 - .signaled = virtio_signaled, 65 + .signaled = virtio_fence_signaled, 66 66 .fence_value_str = virtio_fence_value_str, 67 67 .timeline_value_str = virtio_timeline_value_str, 68 68 };
+14 -21
drivers/gpu/drm/virtio/virtgpu_gem.c
··· 34 34 virtio_gpu_object_unref(&obj); 35 35 } 36 36 37 - struct virtio_gpu_object *virtio_gpu_alloc_object(struct drm_device *dev, 38 - size_t size, bool kernel, 39 - bool pinned) 37 + struct virtio_gpu_object* 38 + virtio_gpu_alloc_object(struct drm_device *dev, 39 + struct virtio_gpu_object_params *params, 40 + struct virtio_gpu_fence *fence) 40 41 { 41 42 struct virtio_gpu_device *vgdev = dev->dev_private; 42 43 struct virtio_gpu_object *obj; 43 44 int ret; 44 45 45 - ret = virtio_gpu_object_create(vgdev, size, kernel, pinned, &obj); 46 + ret = virtio_gpu_object_create(vgdev, params, &obj, fence); 46 47 if (ret) 47 48 return ERR_PTR(ret); 48 49 ··· 52 51 53 52 int virtio_gpu_gem_create(struct drm_file *file, 54 53 struct drm_device *dev, 55 - uint64_t size, 54 + struct virtio_gpu_object_params *params, 56 55 struct drm_gem_object **obj_p, 57 56 uint32_t *handle_p) 58 57 { ··· 60 59 int ret; 61 60 u32 handle; 62 61 63 - obj = virtio_gpu_alloc_object(dev, size, false, false); 62 + obj = virtio_gpu_alloc_object(dev, params, NULL); 64 63 if (IS_ERR(obj)) 65 64 return PTR_ERR(obj); 66 65 ··· 83 82 struct drm_device *dev, 84 83 struct drm_mode_create_dumb *args) 85 84 { 86 - struct virtio_gpu_device *vgdev = dev->dev_private; 87 85 struct drm_gem_object *gobj; 88 - struct virtio_gpu_object *obj; 86 + struct virtio_gpu_object_params params = { 0 }; 89 87 int ret; 90 88 uint32_t pitch; 91 - uint32_t format; 92 89 93 90 if (args->bpp != 32) 94 91 return -EINVAL; ··· 95 96 args->size = pitch * args->height; 96 97 args->size = ALIGN(args->size, PAGE_SIZE); 97 98 98 - ret = virtio_gpu_gem_create(file_priv, dev, args->size, &gobj, 99 + params.format = virtio_gpu_translate_format(DRM_FORMAT_HOST_XRGB8888); 100 + params.width = args->width; 101 + params.height = args->height; 102 + params.size = args->size; 103 + params.dumb = true; 104 + ret = virtio_gpu_gem_create(file_priv, dev, &params, &gobj, 99 105 &args->handle); 100 106 if (ret) 101 107 goto fail; 102 108 103 - format = virtio_gpu_translate_format(DRM_FORMAT_HOST_XRGB8888); 104 - obj = gem_to_virtio_gpu_obj(gobj); 105 - virtio_gpu_cmd_create_resource(vgdev, obj, format, 106 - args->width, args->height); 107 - 108 - /* attach the object to the resource */ 109 - ret = virtio_gpu_object_attach(vgdev, obj, NULL); 110 - if (ret) 111 - goto fail; 112 - 113 - obj->dumb = true; 114 109 args->pitch = pitch; 115 110 return ret; 116 111
+26 -81
drivers/gpu/drm/virtio/virtgpu_ioctl.c
··· 54 54 &virtio_gpu_map->offset); 55 55 } 56 56 57 - static int virtio_gpu_object_list_validate(struct ww_acquire_ctx *ticket, 58 - struct list_head *head) 57 + int virtio_gpu_object_list_validate(struct ww_acquire_ctx *ticket, 58 + struct list_head *head) 59 59 { 60 60 struct ttm_operation_ctx ctx = { false, false }; 61 61 struct ttm_validate_buffer *buf; ··· 79 79 return 0; 80 80 } 81 81 82 - static void virtio_gpu_unref_list(struct list_head *head) 82 + void virtio_gpu_unref_list(struct list_head *head) 83 83 { 84 84 struct ttm_validate_buffer *buf; 85 85 struct ttm_buffer_object *bo; ··· 275 275 { 276 276 struct virtio_gpu_device *vgdev = dev->dev_private; 277 277 struct drm_virtgpu_resource_create *rc = data; 278 + struct virtio_gpu_fence *fence; 278 279 int ret; 279 280 struct virtio_gpu_object *qobj; 280 281 struct drm_gem_object *obj; 281 282 uint32_t handle = 0; 282 - uint32_t size; 283 - struct list_head validate_list; 284 - struct ttm_validate_buffer mainbuf; 285 - struct virtio_gpu_fence *fence = NULL; 286 - struct ww_acquire_ctx ticket; 287 - struct virtio_gpu_resource_create_3d rc_3d; 283 + struct virtio_gpu_object_params params = { 0 }; 288 284 289 285 if (vgdev->has_virgl_3d == false) { 290 286 if (rc->depth > 1) ··· 295 299 return -EINVAL; 296 300 } 297 301 298 - INIT_LIST_HEAD(&validate_list); 299 - memset(&mainbuf, 0, sizeof(struct ttm_validate_buffer)); 300 - 301 - size = rc->size; 302 - 302 + params.format = rc->format; 303 + params.width = rc->width; 304 + params.height = rc->height; 305 + params.size = rc->size; 306 + if (vgdev->has_virgl_3d) { 307 + params.virgl = true; 308 + params.target = rc->target; 309 + params.bind = rc->bind; 310 + params.depth = rc->depth; 311 + params.array_size = rc->array_size; 312 + params.last_level = rc->last_level; 313 + params.nr_samples = rc->nr_samples; 314 + params.flags = rc->flags; 315 + } 303 316 /* allocate a single page size object */ 304 - if (size == 0) 305 - size = PAGE_SIZE; 317 + if (params.size == 0) 318 + params.size = PAGE_SIZE; 306 319 307 - qobj = virtio_gpu_alloc_object(dev, size, false, false); 320 + fence = virtio_gpu_fence_alloc(vgdev); 321 + if (!fence) 322 + return -ENOMEM; 323 + qobj = virtio_gpu_alloc_object(dev, &params, fence); 324 + dma_fence_put(&fence->f); 308 325 if (IS_ERR(qobj)) 309 326 return PTR_ERR(qobj); 310 327 obj = &qobj->gem_base; 311 328 312 - if (!vgdev->has_virgl_3d) { 313 - virtio_gpu_cmd_create_resource(vgdev, qobj, rc->format, 314 - rc->width, rc->height); 315 - 316 - ret = virtio_gpu_object_attach(vgdev, qobj, NULL); 317 - } else { 318 - /* use a gem reference since unref list undoes them */ 319 - drm_gem_object_get(&qobj->gem_base); 320 - mainbuf.bo = &qobj->tbo; 321 - list_add(&mainbuf.head, &validate_list); 322 - 323 - ret = virtio_gpu_object_list_validate(&ticket, &validate_list); 324 - if (ret) { 325 - DRM_DEBUG("failed to validate\n"); 326 - goto fail_unref; 327 - } 328 - 329 - rc_3d.resource_id = cpu_to_le32(qobj->hw_res_handle); 330 - rc_3d.target = cpu_to_le32(rc->target); 331 - rc_3d.format = cpu_to_le32(rc->format); 332 - rc_3d.bind = cpu_to_le32(rc->bind); 333 - rc_3d.width = cpu_to_le32(rc->width); 334 - rc_3d.height = cpu_to_le32(rc->height); 335 - rc_3d.depth = cpu_to_le32(rc->depth); 336 - rc_3d.array_size = cpu_to_le32(rc->array_size); 337 - rc_3d.last_level = cpu_to_le32(rc->last_level); 338 - rc_3d.nr_samples = cpu_to_le32(rc->nr_samples); 339 - rc_3d.flags = cpu_to_le32(rc->flags); 340 - 341 - fence = virtio_gpu_fence_alloc(vgdev); 342 - if (!fence) { 343 - ret = -ENOMEM; 344 - goto fail_backoff; 345 - } 346 - 347 - virtio_gpu_cmd_resource_create_3d(vgdev, qobj, &rc_3d); 348 - ret = virtio_gpu_object_attach(vgdev, qobj, fence); 349 - if (ret) { 350 - dma_fence_put(&fence->f); 351 - goto fail_backoff; 352 - } 353 - ttm_eu_fence_buffer_objects(&ticket, &validate_list, &fence->f); 354 - } 355 - 356 329 ret = drm_gem_handle_create(file_priv, obj, &handle); 357 330 if (ret) { 358 - 359 331 drm_gem_object_release(obj); 360 - if (vgdev->has_virgl_3d) { 361 - virtio_gpu_unref_list(&validate_list); 362 - dma_fence_put(&fence->f); 363 - } 364 332 return ret; 365 333 } 366 334 drm_gem_object_put_unlocked(obj); 367 335 368 336 rc->res_handle = qobj->hw_res_handle; /* similiar to a VM address */ 369 337 rc->bo_handle = handle; 370 - 371 - if (vgdev->has_virgl_3d) { 372 - virtio_gpu_unref_list(&validate_list); 373 - dma_fence_put(&fence->f); 374 - } 375 338 return 0; 376 - fail_backoff: 377 - ttm_eu_backoff_reservation(&ticket, &validate_list); 378 - fail_unref: 379 - if (vgdev->has_virgl_3d) { 380 - virtio_gpu_unref_list(&validate_list); 381 - dma_fence_put(&fence->f); 382 - } 383 - //fail_obj: 384 - // drm_gem_object_handle_unreference_unlocked(obj); 385 - return ret; 386 339 } 387 340 388 341 static int virtio_gpu_resource_info_ioctl(struct drm_device *dev, void *data,
+55 -19
drivers/gpu/drm/virtio/virtgpu_object.c
··· 23 23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 24 */ 25 25 26 + #include <drm/ttm/ttm_execbuf_util.h> 27 + 26 28 #include "virtgpu_drv.h" 27 29 28 30 static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, ··· 76 74 kfree(bo); 77 75 } 78 76 79 - static void virtio_gpu_init_ttm_placement(struct virtio_gpu_object *vgbo, 80 - bool pinned) 77 + static void virtio_gpu_init_ttm_placement(struct virtio_gpu_object *vgbo) 81 78 { 82 79 u32 c = 1; 83 - u32 pflag = pinned ? TTM_PL_FLAG_NO_EVICT : 0; 84 80 85 81 vgbo->placement.placement = &vgbo->placement_code; 86 82 vgbo->placement.busy_placement = &vgbo->placement_code; 87 83 vgbo->placement_code.fpfn = 0; 88 84 vgbo->placement_code.lpfn = 0; 89 85 vgbo->placement_code.flags = 90 - TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT | pflag; 86 + TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT | 87 + TTM_PL_FLAG_NO_EVICT; 91 88 vgbo->placement.num_placement = c; 92 89 vgbo->placement.num_busy_placement = c; 93 90 94 91 } 95 92 96 93 int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, 97 - unsigned long size, bool kernel, bool pinned, 98 - struct virtio_gpu_object **bo_ptr) 94 + struct virtio_gpu_object_params *params, 95 + struct virtio_gpu_object **bo_ptr, 96 + struct virtio_gpu_fence *fence) 99 97 { 100 98 struct virtio_gpu_object *bo; 101 - enum ttm_bo_type type; 102 99 size_t acc_size; 103 100 int ret; 104 101 105 - if (kernel) 106 - type = ttm_bo_type_kernel; 107 - else 108 - type = ttm_bo_type_device; 109 102 *bo_ptr = NULL; 110 103 111 - acc_size = ttm_bo_dma_acc_size(&vgdev->mman.bdev, size, 104 + acc_size = ttm_bo_dma_acc_size(&vgdev->mman.bdev, params->size, 112 105 sizeof(struct virtio_gpu_object)); 113 106 114 107 bo = kzalloc(sizeof(struct virtio_gpu_object), GFP_KERNEL); ··· 114 117 kfree(bo); 115 118 return ret; 116 119 } 117 - size = roundup(size, PAGE_SIZE); 118 - ret = drm_gem_object_init(vgdev->ddev, &bo->gem_base, size); 120 + params->size = roundup(params->size, PAGE_SIZE); 121 + ret = drm_gem_object_init(vgdev->ddev, &bo->gem_base, params->size); 119 122 if (ret != 0) { 120 123 virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); 121 124 kfree(bo); 122 125 return ret; 123 126 } 124 - bo->dumb = false; 125 - virtio_gpu_init_ttm_placement(bo, pinned); 127 + bo->dumb = params->dumb; 126 128 127 - ret = ttm_bo_init(&vgdev->mman.bdev, &bo->tbo, size, type, 128 - &bo->placement, 0, !kernel, acc_size, 129 - NULL, NULL, &virtio_gpu_ttm_bo_destroy); 129 + if (params->virgl) { 130 + virtio_gpu_cmd_resource_create_3d(vgdev, bo, params, fence); 131 + } else { 132 + virtio_gpu_cmd_create_resource(vgdev, bo, params, fence); 133 + } 134 + 135 + virtio_gpu_init_ttm_placement(bo); 136 + ret = ttm_bo_init(&vgdev->mman.bdev, &bo->tbo, params->size, 137 + ttm_bo_type_device, &bo->placement, 0, 138 + true, acc_size, NULL, NULL, 139 + &virtio_gpu_ttm_bo_destroy); 130 140 /* ttm_bo_init failure will call the destroy */ 131 141 if (ret != 0) 132 142 return ret; 143 + 144 + if (fence) { 145 + struct virtio_gpu_fence_driver *drv = &vgdev->fence_drv; 146 + struct list_head validate_list; 147 + struct ttm_validate_buffer mainbuf; 148 + struct ww_acquire_ctx ticket; 149 + unsigned long irq_flags; 150 + bool signaled; 151 + 152 + INIT_LIST_HEAD(&validate_list); 153 + memset(&mainbuf, 0, sizeof(struct ttm_validate_buffer)); 154 + 155 + /* use a gem reference since unref list undoes them */ 156 + drm_gem_object_get(&bo->gem_base); 157 + mainbuf.bo = &bo->tbo; 158 + list_add(&mainbuf.head, &validate_list); 159 + 160 + ret = virtio_gpu_object_list_validate(&ticket, &validate_list); 161 + if (ret == 0) { 162 + spin_lock_irqsave(&drv->lock, irq_flags); 163 + signaled = virtio_fence_signaled(&fence->f); 164 + if (!signaled) 165 + /* virtio create command still in flight */ 166 + ttm_eu_fence_buffer_objects(&ticket, &validate_list, 167 + &fence->f); 168 + spin_unlock_irqrestore(&drv->lock, irq_flags); 169 + if (signaled) 170 + /* virtio create command finished */ 171 + ttm_eu_backoff_reservation(&ticket, &validate_list); 172 + } 173 + virtio_gpu_unref_list(&validate_list); 174 + } 133 175 134 176 *bo_ptr = bo; 135 177 return 0;
+24 -74
drivers/gpu/drm/virtio/virtgpu_ttm.c
··· 116 116 static int virtio_gpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, 117 117 struct ttm_mem_type_manager *man) 118 118 { 119 - struct virtio_gpu_device *vgdev; 120 - 121 - vgdev = virtio_gpu_get_vgdev(bdev); 122 - 123 119 switch (type) { 124 120 case TTM_PL_SYSTEM: 125 121 /* System memory */ ··· 190 194 */ 191 195 struct virtio_gpu_ttm_tt { 192 196 struct ttm_dma_tt ttm; 193 - struct virtio_gpu_device *vgdev; 194 - u64 offset; 197 + struct virtio_gpu_object *obj; 195 198 }; 196 199 197 - static int virtio_gpu_ttm_backend_bind(struct ttm_tt *ttm, 198 - struct ttm_mem_reg *bo_mem) 200 + static int virtio_gpu_ttm_tt_bind(struct ttm_tt *ttm, 201 + struct ttm_mem_reg *bo_mem) 199 202 { 200 - struct virtio_gpu_ttm_tt *gtt = (void *)ttm; 203 + struct virtio_gpu_ttm_tt *gtt = 204 + container_of(ttm, struct virtio_gpu_ttm_tt, ttm.ttm); 205 + struct virtio_gpu_device *vgdev = 206 + virtio_gpu_get_vgdev(gtt->obj->tbo.bdev); 201 207 202 - gtt->offset = (unsigned long)(bo_mem->start << PAGE_SHIFT); 203 - if (!ttm->num_pages) 204 - WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n", 205 - ttm->num_pages, bo_mem, ttm); 206 - 207 - /* Not implemented */ 208 + virtio_gpu_object_attach(vgdev, gtt->obj, NULL); 208 209 return 0; 209 210 } 210 211 211 - static int virtio_gpu_ttm_backend_unbind(struct ttm_tt *ttm) 212 + static int virtio_gpu_ttm_tt_unbind(struct ttm_tt *ttm) 212 213 { 213 - /* Not implemented */ 214 + struct virtio_gpu_ttm_tt *gtt = 215 + container_of(ttm, struct virtio_gpu_ttm_tt, ttm.ttm); 216 + struct virtio_gpu_device *vgdev = 217 + virtio_gpu_get_vgdev(gtt->obj->tbo.bdev); 218 + 219 + virtio_gpu_object_detach(vgdev, gtt->obj); 214 220 return 0; 215 221 } 216 222 217 - static void virtio_gpu_ttm_backend_destroy(struct ttm_tt *ttm) 223 + static void virtio_gpu_ttm_tt_destroy(struct ttm_tt *ttm) 218 224 { 219 - struct virtio_gpu_ttm_tt *gtt = (void *)ttm; 225 + struct virtio_gpu_ttm_tt *gtt = 226 + container_of(ttm, struct virtio_gpu_ttm_tt, ttm.ttm); 220 227 221 228 ttm_dma_tt_fini(&gtt->ttm); 222 229 kfree(gtt); 223 230 } 224 231 225 - static struct ttm_backend_func virtio_gpu_backend_func = { 226 - .bind = &virtio_gpu_ttm_backend_bind, 227 - .unbind = &virtio_gpu_ttm_backend_unbind, 228 - .destroy = &virtio_gpu_ttm_backend_destroy, 232 + static struct ttm_backend_func virtio_gpu_tt_func = { 233 + .bind = &virtio_gpu_ttm_tt_bind, 234 + .unbind = &virtio_gpu_ttm_tt_unbind, 235 + .destroy = &virtio_gpu_ttm_tt_destroy, 229 236 }; 230 237 231 238 static struct ttm_tt *virtio_gpu_ttm_tt_create(struct ttm_buffer_object *bo, ··· 241 242 gtt = kzalloc(sizeof(struct virtio_gpu_ttm_tt), GFP_KERNEL); 242 243 if (gtt == NULL) 243 244 return NULL; 244 - gtt->ttm.ttm.func = &virtio_gpu_backend_func; 245 - gtt->vgdev = vgdev; 245 + gtt->ttm.ttm.func = &virtio_gpu_tt_func; 246 + gtt->obj = container_of(bo, struct virtio_gpu_object, tbo); 246 247 if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) { 247 248 kfree(gtt); 248 249 return NULL; ··· 250 251 return &gtt->ttm.ttm; 251 252 } 252 253 253 - static void virtio_gpu_move_null(struct ttm_buffer_object *bo, 254 - struct ttm_mem_reg *new_mem) 255 - { 256 - struct ttm_mem_reg *old_mem = &bo->mem; 257 - 258 - BUG_ON(old_mem->mm_node != NULL); 259 - *old_mem = *new_mem; 260 - new_mem->mm_node = NULL; 261 - } 262 - 263 - static int virtio_gpu_bo_move(struct ttm_buffer_object *bo, bool evict, 264 - struct ttm_operation_ctx *ctx, 265 - struct ttm_mem_reg *new_mem) 266 - { 267 - int ret; 268 - 269 - ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu); 270 - if (ret) 271 - return ret; 272 - 273 - virtio_gpu_move_null(bo, new_mem); 274 - return 0; 275 - } 276 - 277 - static void virtio_gpu_bo_move_notify(struct ttm_buffer_object *tbo, 278 - bool evict, 279 - struct ttm_mem_reg *new_mem) 280 - { 281 - struct virtio_gpu_object *bo; 282 - struct virtio_gpu_device *vgdev; 283 - 284 - bo = container_of(tbo, struct virtio_gpu_object, tbo); 285 - vgdev = (struct virtio_gpu_device *)bo->gem_base.dev->dev_private; 286 - 287 - if (!new_mem || (new_mem->placement & TTM_PL_FLAG_SYSTEM)) { 288 - if (bo->hw_res_handle) 289 - virtio_gpu_object_detach(vgdev, bo); 290 - 291 - } else if (new_mem->placement & TTM_PL_FLAG_TT) { 292 - if (bo->hw_res_handle) { 293 - virtio_gpu_object_attach(vgdev, bo, NULL); 294 - } 295 - } 296 - } 297 - 298 254 static void virtio_gpu_bo_swap_notify(struct ttm_buffer_object *tbo) 299 255 { 300 256 struct virtio_gpu_object *bo; 301 - struct virtio_gpu_device *vgdev; 302 257 303 258 bo = container_of(tbo, struct virtio_gpu_object, tbo); 304 - vgdev = (struct virtio_gpu_device *)bo->gem_base.dev->dev_private; 305 259 306 260 if (bo->pages) 307 261 virtio_gpu_object_free_sg_table(bo); ··· 266 314 .init_mem_type = &virtio_gpu_init_mem_type, 267 315 .eviction_valuable = ttm_bo_eviction_valuable, 268 316 .evict_flags = &virtio_gpu_evict_flags, 269 - .move = &virtio_gpu_bo_move, 270 317 .verify_access = &virtio_gpu_verify_access, 271 318 .io_mem_reserve = &virtio_gpu_ttm_io_mem_reserve, 272 319 .io_mem_free = &virtio_gpu_ttm_io_mem_free, 273 - .move_notify = &virtio_gpu_bo_move_notify, 274 320 .swap_notify = &virtio_gpu_bo_swap_notify, 275 321 }; 276 322
+23 -13
drivers/gpu/drm/virtio/virtgpu_vq.c
··· 376 376 /* create a basic resource */ 377 377 void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, 378 378 struct virtio_gpu_object *bo, 379 - uint32_t format, 380 - uint32_t width, 381 - uint32_t height) 379 + struct virtio_gpu_object_params *params, 380 + struct virtio_gpu_fence *fence) 382 381 { 383 382 struct virtio_gpu_resource_create_2d *cmd_p; 384 383 struct virtio_gpu_vbuffer *vbuf; ··· 387 388 388 389 cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_CREATE_2D); 389 390 cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); 390 - cmd_p->format = cpu_to_le32(format); 391 - cmd_p->width = cpu_to_le32(width); 392 - cmd_p->height = cpu_to_le32(height); 391 + cmd_p->format = cpu_to_le32(params->format); 392 + cmd_p->width = cpu_to_le32(params->width); 393 + cmd_p->height = cpu_to_le32(params->height); 393 394 394 - virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); 395 + virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, &cmd_p->hdr, fence); 395 396 bo->created = true; 396 397 } 397 398 ··· 827 828 void 828 829 virtio_gpu_cmd_resource_create_3d(struct virtio_gpu_device *vgdev, 829 830 struct virtio_gpu_object *bo, 830 - struct virtio_gpu_resource_create_3d *rc_3d) 831 + struct virtio_gpu_object_params *params, 832 + struct virtio_gpu_fence *fence) 831 833 { 832 834 struct virtio_gpu_resource_create_3d *cmd_p; 833 835 struct virtio_gpu_vbuffer *vbuf; ··· 836 836 cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); 837 837 memset(cmd_p, 0, sizeof(*cmd_p)); 838 838 839 - *cmd_p = *rc_3d; 840 839 cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_CREATE_3D); 841 - cmd_p->hdr.flags = 0; 840 + cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); 841 + cmd_p->format = cpu_to_le32(params->format); 842 + cmd_p->width = cpu_to_le32(params->width); 843 + cmd_p->height = cpu_to_le32(params->height); 842 844 843 - virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); 845 + cmd_p->target = cpu_to_le32(params->target); 846 + cmd_p->bind = cpu_to_le32(params->bind); 847 + cmd_p->depth = cpu_to_le32(params->depth); 848 + cmd_p->array_size = cpu_to_le32(params->array_size); 849 + cmd_p->last_level = cpu_to_le32(params->last_level); 850 + cmd_p->nr_samples = cpu_to_le32(params->nr_samples); 851 + cmd_p->flags = cpu_to_le32(params->flags); 852 + 853 + virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, &cmd_p->hdr, fence); 844 854 bo->created = true; 845 855 } 846 856 ··· 934 924 struct scatterlist *sg; 935 925 int si, nents; 936 926 937 - if (!obj->created) 938 - return 0; 927 + if (WARN_ON_ONCE(!obj->created)) 928 + return -EINVAL; 939 929 940 930 if (!obj->pages) { 941 931 int ret;
+2
drivers/gpu/drm/vkms/vkms_crtc.c
··· 219 219 spin_lock_init(&vkms_out->state_lock); 220 220 221 221 vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0); 222 + if (!vkms_out->crc_workq) 223 + return -ENOMEM; 222 224 223 225 return ret; 224 226 }
+2 -12
include/drm/drm_connector.h
··· 356 356 */ 357 357 struct drm_display_info { 358 358 /** 359 - * @name: Name of the display. 360 - */ 361 - char name[DRM_DISPLAY_INFO_LEN]; 362 - 363 - /** 364 359 * @width_mm: Physical width in mm. 365 360 */ 366 - unsigned int width_mm; 361 + unsigned int width_mm; 362 + 367 363 /** 368 364 * @height_mm: Physical height in mm. 369 365 */ 370 366 unsigned int height_mm; 371 367 372 - /** 373 - * @pixel_clock: Maximum pixel clock supported by the sink, in units of 374 - * 100Hz. This mismatches the clock in &drm_display_mode (which is in 375 - * kHZ), because that's what the EDID uses as base unit. 376 - */ 377 - unsigned int pixel_clock; 378 368 /** 379 369 * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs. 380 370 */
+3 -3
include/drm/drm_drv.h
··· 152 152 /** 153 153 * struct drm_driver - DRM driver structure 154 154 * 155 - * This structure represent the common code for a family of cards. There will 156 - * one drm_device for each card present in this family. It contains lots of 157 - * vfunc entries, and a pile of those probably should be moved to more 155 + * This structure represent the common code for a family of cards. There will be 156 + * one &struct drm_device for each card present in this family. It contains lots 157 + * of vfunc entries, and a pile of those probably should be moved to more 158 158 * appropriate places like &drm_mode_config_funcs or into a new operations 159 159 * structure for GEM drivers. 160 160 */
+9 -16
include/drm/drm_fb_helper.h
··· 68 68 * according to the largest width/height (so it is large enough for all CRTCs 69 69 * to scanout). But the fbdev width/height is sized to the minimum width/ 70 70 * height of all the displays. This ensures that fbcon fits on the smallest 71 - * of the attached displays. 72 - * 73 - * So what is passed to drm_fb_helper_fill_var() should be fb_width/fb_height, 74 - * rather than the surface size. 71 + * of the attached displays. fb_width/fb_height is used by 72 + * drm_fb_helper_fill_info() to fill out the &fb_info.var structure. 75 73 */ 76 74 struct drm_fb_helper_surface_size { 77 75 u32 fb_width; ··· 287 289 288 290 struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper); 289 291 void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper); 290 - void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper, 291 - uint32_t fb_width, uint32_t fb_height); 292 - void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, 293 - uint32_t depth); 292 + void drm_fb_helper_fill_info(struct fb_info *info, 293 + struct drm_fb_helper *fb_helper, 294 + struct drm_fb_helper_surface_size *sizes); 294 295 295 296 void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper); 296 297 ··· 415 418 { 416 419 } 417 420 418 - static inline void drm_fb_helper_fill_var(struct fb_info *info, 419 - struct drm_fb_helper *fb_helper, 420 - uint32_t fb_width, uint32_t fb_height) 421 - { 422 - } 423 - 424 - static inline void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, 425 - uint32_t depth) 421 + static inline void 422 + drm_fb_helper_fill_info(struct fb_info *info, 423 + struct drm_fb_helper *fb_helper, 424 + struct drm_fb_helper_surface_size *sizes) 426 425 { 427 426 } 428 427
-1
include/uapi/drm/drm_mode.h
··· 33 33 extern "C" { 34 34 #endif 35 35 36 - #define DRM_DISPLAY_INFO_LEN 32 37 36 #define DRM_CONNECTOR_NAME_LEN 32 38 37 #define DRM_DISPLAY_MODE_LEN 32 39 38 #define DRM_PROP_NAME_LEN 32