Skip to content

Commit 7c0059d

Browse files
committed
Merge branch 'linux-4.14' of git://github.com/skeggsb/linux into drm-next
Not a lot that's ready to be included this round for Nouveau. GP108 modesetting support, and misc other fixes. * 'linux-4.14' of git://github.com/skeggsb/linux: drm/nouveau/kms/nv50: perform null check on msto[i] rathern than msto drm/nouveau/pci/msi: disable MSI on big-endian platforms by default drm/nouveau: silence suspend/resume debugging messages drm/nouveau/kms/nv04-nv4x: fix exposed format list drm/nouveau/kms/nv10-nv40: add NV21 support to overlay drm/nouveau/kms/nv04-nv40: improve overlay error detection, fix pitch setting drm/nouveau/kms/nv04-nv40: prevent undisplayable framebuffers from creation drm/nouveau/mpeg: print more debug info when rejecting dma objects drm/nouveau/fb/gf100-: zero mmu debug buffers drm/nouveau/bar/gf100: add config option to limit BAR2 to 16MiB initial support (display-only) for GP108 drm/nouveau/falcon: use a more reasonable msgqueue timeout value drm/nouveau/disp: Silence DCB warnings. drm/nouveau/bios: Demote missing fp table message to NV_DEBUG. drm/nouveau/pmu/gt215-: abstract detection of whether reset is needed drm/nouveau/pmu/gt215: fix reset drm/nouveau/mc/gf100: add pmu to reset mask drm/nouveau/disp/gf119-: avoid creating non-existent heads drm/nouveau/therm/gm200: Added drm/nouveau/therm: fix spelling mistake on array thresolds
2 parents 6b9dfb5 + 27a451e commit 7c0059d

39 files changed

Lines changed: 287 additions & 75 deletions

‎drivers/gpu/drm/nouveau/dispnv04/crtc.c‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,38 @@ static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = {
10961096
.disable = nv_crtc_disable,
10971097
};
10981098

1099+
static const uint32_t modeset_formats[] = {
1100+
DRM_FORMAT_XRGB8888,
1101+
DRM_FORMAT_RGB565,
1102+
DRM_FORMAT_XRGB1555,
1103+
};
1104+
1105+
static struct drm_plane *
1106+
create_primary_plane(struct drm_device *dev)
1107+
{
1108+
struct drm_plane *primary;
1109+
int ret;
1110+
1111+
primary = kzalloc(sizeof(*primary), GFP_KERNEL);
1112+
if (primary == NULL) {
1113+
DRM_DEBUG_KMS("Failed to allocate primary plane\n");
1114+
return NULL;
1115+
}
1116+
1117+
/* possible_crtc's will be filled in later by crtc_init */
1118+
ret = drm_universal_plane_init(dev, primary, 0,
1119+
&drm_primary_helper_funcs,
1120+
modeset_formats,
1121+
ARRAY_SIZE(modeset_formats), NULL,
1122+
DRM_PLANE_TYPE_PRIMARY, NULL);
1123+
if (ret) {
1124+
kfree(primary);
1125+
primary = NULL;
1126+
}
1127+
1128+
return primary;
1129+
}
1130+
10991131
int
11001132
nv04_crtc_create(struct drm_device *dev, int crtc_num)
11011133
{
@@ -1114,7 +1146,9 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
11141146
nv_crtc->save = nv_crtc_save;
11151147
nv_crtc->restore = nv_crtc_restore;
11161148

1117-
drm_crtc_init(dev, &nv_crtc->base, &nv04_crtc_funcs);
1149+
drm_crtc_init_with_planes(dev, &nv_crtc->base,
1150+
create_primary_plane(dev), NULL,
1151+
&nv04_crtc_funcs, NULL);
11181152
drm_crtc_helper_add(&nv_crtc->base, &nv04_crtc_helper_funcs);
11191153
drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);
11201154

‎drivers/gpu/drm/nouveau/dispnv04/overlay.c‎

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ static uint32_t formats[] = {
6363
DRM_FORMAT_YUYV,
6464
DRM_FORMAT_UYVY,
6565
DRM_FORMAT_NV12,
66+
DRM_FORMAT_NV21,
6667
};
6768

6869
/* Sine can be approximated with
@@ -89,6 +90,26 @@ cos_mul(int degrees, int factor)
8990
return sin_mul((degrees + 90) % 360, factor);
9091
}
9192

93+
static int
94+
verify_scaling(const struct drm_framebuffer *fb, uint8_t shift,
95+
uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h,
96+
uint32_t crtc_w, uint32_t crtc_h)
97+
{
98+
if (crtc_w < (src_w >> shift) || crtc_h < (src_h >> shift)) {
99+
DRM_DEBUG_KMS("Unsuitable framebuffer scaling: %dx%d -> %dx%d\n",
100+
src_w, src_h, crtc_w, crtc_h);
101+
return -ERANGE;
102+
}
103+
104+
if (src_x != 0 || src_y != 0) {
105+
DRM_DEBUG_KMS("Unsuitable framebuffer offset: %d,%d\n",
106+
src_x, src_y);
107+
return -ERANGE;
108+
}
109+
110+
return 0;
111+
}
112+
92113
static int
93114
nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
94115
struct drm_framebuffer *fb, int crtc_x, int crtc_y,
@@ -107,26 +128,19 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
107128
bool flip = nv_plane->flip;
108129
int soff = NV_PCRTC0_SIZE * nv_crtc->index;
109130
int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index;
110-
int format, ret;
131+
unsigned shift = drm->client.device.info.chipset >= 0x30 ? 1 : 3;
132+
unsigned format = 0;
133+
int ret;
111134

112135
/* Source parameters given in 16.16 fixed point, ignore fractional. */
113136
src_x >>= 16;
114137
src_y >>= 16;
115138
src_w >>= 16;
116139
src_h >>= 16;
117140

118-
format = ALIGN(src_w * 4, 0x100);
119-
120-
if (format > 0xffff)
121-
return -ERANGE;
122-
123-
if (drm->client.device.info.chipset >= 0x30) {
124-
if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1))
125-
return -ERANGE;
126-
} else {
127-
if (crtc_w < (src_w >> 3) || crtc_h < (src_h >> 3))
128-
return -ERANGE;
129-
}
141+
ret = verify_scaling(fb, shift, 0, 0, src_w, src_h, crtc_w, crtc_h);
142+
if (ret)
143+
return ret;
130144

131145
ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM, false);
132146
if (ret)
@@ -146,21 +160,23 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
146160
nvif_wr32(dev, NV_PVIDEO_POINT_OUT(flip), crtc_y << 16 | crtc_x);
147161
nvif_wr32(dev, NV_PVIDEO_SIZE_OUT(flip), crtc_h << 16 | crtc_w);
148162

149-
if (fb->format->format != DRM_FORMAT_UYVY)
163+
if (fb->format->format == DRM_FORMAT_YUYV ||
164+
fb->format->format == DRM_FORMAT_NV12)
150165
format |= NV_PVIDEO_FORMAT_COLOR_LE_CR8YB8CB8YA8;
151-
if (fb->format->format == DRM_FORMAT_NV12)
166+
if (fb->format->format == DRM_FORMAT_NV12 ||
167+
fb->format->format == DRM_FORMAT_NV21)
152168
format |= NV_PVIDEO_FORMAT_PLANAR;
153169
if (nv_plane->iturbt_709)
154170
format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709;
155171
if (nv_plane->colorkey & (1 << 24))
156172
format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY;
157173

158-
if (fb->format->format == DRM_FORMAT_NV12) {
174+
if (format & NV_PVIDEO_FORMAT_PLANAR) {
159175
nvif_wr32(dev, NV_PVIDEO_UVPLANE_BASE(flip), 0);
160176
nvif_wr32(dev, NV_PVIDEO_UVPLANE_OFFSET_BUFF(flip),
161177
nv_fb->nvbo->bo.offset + fb->offsets[1]);
162178
}
163-
nvif_wr32(dev, NV_PVIDEO_FORMAT(flip), format);
179+
nvif_wr32(dev, NV_PVIDEO_FORMAT(flip), format | fb->pitches[0]);
164180
nvif_wr32(dev, NV_PVIDEO_STOP, 0);
165181
/* TODO: wait for vblank? */
166182
nvif_wr32(dev, NV_PVIDEO_BUFFER, flip ? 0x10 : 0x1);
@@ -357,25 +373,17 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
357373
struct nouveau_bo *cur = nv_plane->cur;
358374
uint32_t overlay = 1;
359375
int brightness = (nv_plane->brightness - 512) * 62 / 512;
360-
int pitch, ret, i;
376+
int ret, i;
361377

362378
/* Source parameters given in 16.16 fixed point, ignore fractional. */
363379
src_x >>= 16;
364380
src_y >>= 16;
365381
src_w >>= 16;
366382
src_h >>= 16;
367383

368-
pitch = ALIGN(src_w * 4, 0x100);
369-
370-
if (pitch > 0xffff)
371-
return -ERANGE;
372-
373-
/* TODO: Compute an offset? Not sure how to do this for YUYV. */
374-
if (src_x != 0 || src_y != 0)
375-
return -ERANGE;
376-
377-
if (crtc_w < src_w || crtc_h < src_h)
378-
return -ERANGE;
384+
ret = verify_scaling(fb, 0, src_x, src_y, src_w, src_h, crtc_w, crtc_h);
385+
if (ret)
386+
return ret;
379387

380388
ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM, false);
381389
if (ret)
@@ -389,8 +397,9 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
389397

390398
for (i = 0; i < 2; i++) {
391399
nvif_wr32(dev, NV_PVIDEO_BUFF0_START_ADDRESS + 4 * i,
392-
nv_fb->nvbo->bo.offset);
393-
nvif_wr32(dev, NV_PVIDEO_BUFF0_PITCH_LENGTH + 4 * i, pitch);
400+
nv_fb->nvbo->bo.offset);
401+
nvif_wr32(dev, NV_PVIDEO_BUFF0_PITCH_LENGTH + 4 * i,
402+
fb->pitches[0]);
394403
nvif_wr32(dev, NV_PVIDEO_BUFF0_OFFSET + 4 * i, 0);
395404
}
396405
nvif_wr32(dev, NV_PVIDEO_WINDOW_START, crtc_y << 16 | crtc_x);

‎drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ enum dcb_connector_type {
1818
DCB_CONNECTOR_HDMI_C = 0x63,
1919
DCB_CONNECTOR_DMS59_DP0 = 0x64,
2020
DCB_CONNECTOR_DMS59_DP1 = 0x65,
21+
DCB_CONNECTOR_WFD = 0x70,
2122
DCB_CONNECTOR_NONE = 0xff
2223
};
2324

‎drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/dcb.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ enum dcb_output_type {
66
DCB_OUTPUT_TMDS = 0x2,
77
DCB_OUTPUT_LVDS = 0x3,
88
DCB_OUTPUT_DP = 0x6,
9+
DCB_OUTPUT_WFD = 0x8,
910
DCB_OUTPUT_EOL = 0xe,
1011
DCB_OUTPUT_UNUSED = 0xf,
1112
DCB_OUTPUT_ANY = -1,

‎drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ int g84_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
9696
int gt215_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
9797
int gf119_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
9898
int gm107_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
99+
int gm200_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
99100
#endif

‎drivers/gpu/drm/nouveau/nouveau_bios.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,8 @@ static int parse_fp_mode_table(struct drm_device *dev, struct nvbios *bios)
351351
struct lvdstableheader lth;
352352

353353
if (bios->fp.fptablepointer == 0x0) {
354-
/* Apple cards don't have the fp table; the laptops use DDC */
355-
/* The table is also missing on some x86 IGPs */
356-
#ifndef __powerpc__
357-
NV_ERROR(drm, "Pointer to flat panel table invalid\n");
358-
#endif
354+
/* Most laptop cards lack an fp table. They use DDC. */
355+
NV_DEBUG(drm, "Pointer to flat panel table invalid\n");
359356
bios->digital_min_front_porch = 0x4b;
360357
return 0;
361358
}

‎drivers/gpu/drm/nouveau/nouveau_connector.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,7 @@ drm_conntype_from_dcb(enum dcb_connector_type dcb)
11841184
case DCB_CONNECTOR_HDMI_0 :
11851185
case DCB_CONNECTOR_HDMI_1 :
11861186
case DCB_CONNECTOR_HDMI_C : return DRM_MODE_CONNECTOR_HDMIA;
1187+
case DCB_CONNECTOR_WFD : return DRM_MODE_CONNECTOR_VIRTUAL;
11871188
default:
11881189
break;
11891190
}

‎drivers/gpu/drm/nouveau/nouveau_display.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,30 @@ nouveau_framebuffer_new(struct drm_device *dev,
231231
struct nouveau_bo *nvbo,
232232
struct nouveau_framebuffer **pfb)
233233
{
234+
struct nouveau_drm *drm = nouveau_drm(dev);
234235
struct nouveau_framebuffer *fb;
235236
int ret;
236237

238+
/* YUV overlays have special requirements pre-NV50 */
239+
if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
240+
241+
(mode_cmd->pixel_format == DRM_FORMAT_YUYV ||
242+
mode_cmd->pixel_format == DRM_FORMAT_UYVY ||
243+
mode_cmd->pixel_format == DRM_FORMAT_NV12 ||
244+
mode_cmd->pixel_format == DRM_FORMAT_NV21) &&
245+
(mode_cmd->pitches[0] & 0x3f || /* align 64 */
246+
mode_cmd->pitches[0] >= 0x10000 || /* at most 64k pitch */
247+
(mode_cmd->pitches[1] && /* pitches for planes must match */
248+
mode_cmd->pitches[0] != mode_cmd->pitches[1]))) {
249+
struct drm_format_name_buf format_name;
250+
DRM_DEBUG_KMS("Unsuitable framebuffer: format: %s; pitches: 0x%x\n 0x%x\n",
251+
drm_get_format_name(mode_cmd->pixel_format,
252+
&format_name),
253+
mode_cmd->pitches[0],
254+
mode_cmd->pitches[1]);
255+
return -EINVAL;
256+
}
257+
237258
if (!(fb = *pfb = kzalloc(sizeof(*fb), GFP_KERNEL)))
238259
return -ENOMEM;
239260

‎drivers/gpu/drm/nouveau/nouveau_drm.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -585,18 +585,18 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
585585
nouveau_led_suspend(dev);
586586

587587
if (dev->mode_config.num_crtc) {
588-
NV_INFO(drm, "suspending console...\n");
588+
NV_DEBUG(drm, "suspending console...\n");
589589
nouveau_fbcon_set_suspend(dev, 1);
590-
NV_INFO(drm, "suspending display...\n");
590+
NV_DEBUG(drm, "suspending display...\n");
591591
ret = nouveau_display_suspend(dev, runtime);
592592
if (ret)
593593
return ret;
594594
}
595595

596-
NV_INFO(drm, "evicting buffers...\n");
596+
NV_DEBUG(drm, "evicting buffers...\n");
597597
ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM);
598598

599-
NV_INFO(drm, "waiting for kernel channels to go idle...\n");
599+
NV_DEBUG(drm, "waiting for kernel channels to go idle...\n");
600600
if (drm->cechan) {
601601
ret = nouveau_channel_idle(drm->cechan);
602602
if (ret)
@@ -609,15 +609,15 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
609609
goto fail_display;
610610
}
611611

612-
NV_INFO(drm, "suspending fence...\n");
612+
NV_DEBUG(drm, "suspending fence...\n");
613613
if (drm->fence && nouveau_fence(drm)->suspend) {
614614
if (!nouveau_fence(drm)->suspend(drm)) {
615615
ret = -ENOMEM;
616616
goto fail_display;
617617
}
618618
}
619619

620-
NV_INFO(drm, "suspending object tree...\n");
620+
NV_DEBUG(drm, "suspending object tree...\n");
621621
ret = nvif_client_suspend(&drm->client.base);
622622
if (ret)
623623
goto fail_client;
@@ -630,7 +630,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
630630

631631
fail_display:
632632
if (dev->mode_config.num_crtc) {
633-
NV_INFO(drm, "resuming display...\n");
633+
NV_DEBUG(drm, "resuming display...\n");
634634
nouveau_display_resume(dev, runtime);
635635
}
636636
return ret;
@@ -641,19 +641,19 @@ nouveau_do_resume(struct drm_device *dev, bool runtime)
641641
{
642642
struct nouveau_drm *drm = nouveau_drm(dev);
643643

644-
NV_INFO(drm, "resuming object tree...\n");
644+
NV_DEBUG(drm, "resuming object tree...\n");
645645
nvif_client_resume(&drm->client.base);
646646

647-
NV_INFO(drm, "resuming fence...\n");
647+
NV_DEBUG(drm, "resuming fence...\n");
648648
if (drm->fence && nouveau_fence(drm)->resume)
649649
nouveau_fence(drm)->resume(drm);
650650

651651
nouveau_run_vbios_init(dev);
652652

653653
if (dev->mode_config.num_crtc) {
654-
NV_INFO(drm, "resuming display...\n");
654+
NV_DEBUG(drm, "resuming display...\n");
655655
nouveau_display_resume(dev, runtime);
656-
NV_INFO(drm, "resuming console...\n");
656+
NV_DEBUG(drm, "resuming console...\n");
657657
nouveau_fbcon_set_suspend(dev, 0);
658658
}
659659

‎drivers/gpu/drm/nouveau/nv50_display.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,7 +3141,7 @@ nv50_mstc_new(struct nv50_mstm *mstm, struct drm_dp_mst_port *port,
31413141
mstc->connector.funcs->reset(&mstc->connector);
31423142
nouveau_conn_attach_properties(&mstc->connector);
31433143

3144-
for (i = 0; i < ARRAY_SIZE(mstm->msto) && mstm->msto; i++)
3144+
for (i = 0; i < ARRAY_SIZE(mstm->msto) && mstm->msto[i]; i++)
31453145
drm_mode_connector_attach_encoder(&mstc->connector, &mstm->msto[i]->encoder);
31463146

31473147
drm_object_attach_property(&mstc->connector.base, dev->mode_config.path_property, 0);
@@ -4451,11 +4451,13 @@ nv50_display_create(struct drm_device *dev)
44514451

44524452
/* create crtc objects to represent the hw heads */
44534453
if (disp->disp->oclass >= GF110_DISP)
4454-
crtcs = nvif_rd32(&device->object, 0x022448);
4454+
crtcs = nvif_rd32(&device->object, 0x612004) & 0xf;
44554455
else
4456-
crtcs = 2;
4456+
crtcs = 0x3;
44574457

4458-
for (i = 0; i < crtcs; i++) {
4458+
for (i = 0; i < fls(crtcs); i++) {
4459+
if (!(crtcs & (1 << i)))
4460+
continue;
44594461
ret = nv50_head_create(dev, i);
44604462
if (ret)
44614463
goto out;

0 commit comments

Comments
 (0)