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