Skip to content

Commit 67f35a4

Browse files
committed
Merge tag 'drm-misc-fixes-2023-10-05' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
Short summary of fixes pull: * test: Fix kunit release * panel-orientation: Add quirk for One Mix 25 * nouveau: * Report IB limit via getparams * Replace some magic numbers with constants * Clean up Signed-off-by: Dave Airlie <[email protected]> From: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20231005092632.GA17332@linux-uq9g
2 parents 62af738 + d59e75e commit 67f35a4

File tree

8 files changed

+72
-12
lines changed

8 files changed

+72
-12
lines changed

drivers/gpu/drm/drm_panel_orientation_quirks.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ static const struct drm_dmi_panel_orientation_data gpd_micropc = {
3838
.orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
3939
};
4040

41+
static const struct drm_dmi_panel_orientation_data gpd_onemix2s = {
42+
.width = 1200,
43+
.height = 1920,
44+
.bios_dates = (const char * const []){ "05/21/2018", "10/26/2018",
45+
"03/04/2019", NULL },
46+
.orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
47+
};
48+
4149
static const struct drm_dmi_panel_orientation_data gpd_pocket = {
4250
.width = 1200,
4351
.height = 1920,
@@ -401,6 +409,14 @@ static const struct dmi_system_id orientation_data[] = {
401409
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "LTH17"),
402410
},
403411
.driver_data = (void *)&lcd800x1280_rightside_up,
412+
}, { /* One Mix 2S (generic strings, also match on bios date) */
413+
.matches = {
414+
DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Default string"),
415+
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"),
416+
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Default string"),
417+
DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"),
418+
},
419+
.driver_data = (void *)&gpd_onemix2s,
404420
},
405421
{}
406422
};

drivers/gpu/drm/nouveau/nouveau_abi16.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "nouveau_drv.h"
3333
#include "nouveau_dma.h"
34+
#include "nouveau_exec.h"
3435
#include "nouveau_gem.h"
3536
#include "nouveau_chan.h"
3637
#include "nouveau_abi16.h"
@@ -183,6 +184,20 @@ nouveau_abi16_fini(struct nouveau_abi16 *abi16)
183184
cli->abi16 = NULL;
184185
}
185186

187+
static inline int
188+
getparam_dma_ib_max(struct nvif_device *device)
189+
{
190+
const struct nvif_mclass dmas[] = {
191+
{ NV03_CHANNEL_DMA, 0 },
192+
{ NV10_CHANNEL_DMA, 0 },
193+
{ NV17_CHANNEL_DMA, 0 },
194+
{ NV40_CHANNEL_DMA, 0 },
195+
{}
196+
};
197+
198+
return nvif_mclass(&device->object, dmas) < 0 ? NV50_DMA_IB_MAX : 0;
199+
}
200+
186201
int
187202
nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
188203
{
@@ -247,6 +262,12 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
247262
case NOUVEAU_GETPARAM_GRAPH_UNITS:
248263
getparam->value = nvkm_gr_units(gr);
249264
break;
265+
case NOUVEAU_GETPARAM_EXEC_PUSH_MAX: {
266+
int ib_max = getparam_dma_ib_max(device);
267+
268+
getparam->value = nouveau_exec_push_max_from_ib_max(ib_max);
269+
break;
270+
}
250271
default:
251272
NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param);
252273
return -EINVAL;

drivers/gpu/drm/nouveau/nouveau_chan.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,7 @@ static int
257257
nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool priv, u64 runm,
258258
struct nouveau_channel **pchan)
259259
{
260-
static const struct {
261-
s32 oclass;
262-
int version;
263-
} hosts[] = {
260+
const struct nvif_mclass hosts[] = {
264261
{ AMPERE_CHANNEL_GPFIFO_B, 0 },
265262
{ AMPERE_CHANNEL_GPFIFO_A, 0 },
266263
{ TURING_CHANNEL_GPFIFO_A, 0 },
@@ -443,9 +440,11 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
443440
}
444441

445442
/* initialise dma tracking parameters */
446-
switch (chan->user.oclass & 0x00ff) {
447-
case 0x006b:
448-
case 0x006e:
443+
switch (chan->user.oclass) {
444+
case NV03_CHANNEL_DMA:
445+
case NV10_CHANNEL_DMA:
446+
case NV17_CHANNEL_DMA:
447+
case NV40_CHANNEL_DMA:
449448
chan->user_put = 0x40;
450449
chan->user_get = 0x44;
451450
chan->dma.max = (0x10000 / 4) - 2;
@@ -455,7 +454,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
455454
chan->user_get = 0x44;
456455
chan->user_get_hi = 0x60;
457456
chan->dma.ib_base = 0x10000 / 4;
458-
chan->dma.ib_max = (0x02000 / 8) - 1;
457+
chan->dma.ib_max = NV50_DMA_IB_MAX;
459458
chan->dma.ib_put = 0;
460459
chan->dma.ib_free = chan->dma.ib_max - chan->dma.ib_put;
461460
chan->dma.max = chan->dma.ib_base;

drivers/gpu/drm/nouveau/nouveau_dma.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ void nv50_dma_push(struct nouveau_channel *, u64 addr, u32 length,
4949
/* Maximum push buffer size. */
5050
#define NV50_DMA_PUSH_MAX_LENGTH 0x7fffff
5151

52+
/* Maximum IBs per ring. */
53+
#define NV50_DMA_IB_MAX ((0x02000 / 8) - 1)
54+
5255
/* Object handles - for stuff that's doesn't use handle == oclass. */
5356
enum {
5457
NvDmaFB = 0x80000002,

drivers/gpu/drm/nouveau/nouveau_exec.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ nouveau_exec_ioctl_exec(struct drm_device *dev,
379379
struct nouveau_channel *chan = NULL;
380380
struct nouveau_exec_job_args args = {};
381381
struct drm_nouveau_exec *req = data;
382-
int ret = 0;
382+
int push_max, ret = 0;
383383

384384
if (unlikely(!abi16))
385385
return -ENOMEM;
@@ -404,9 +404,10 @@ nouveau_exec_ioctl_exec(struct drm_device *dev,
404404
if (!chan->dma.ib_max)
405405
return nouveau_abi16_put(abi16, -ENOSYS);
406406

407-
if (unlikely(req->push_count > NOUVEAU_GEM_MAX_PUSH)) {
407+
push_max = nouveau_exec_push_max_from_ib_max(chan->dma.ib_max);
408+
if (unlikely(req->push_count > push_max)) {
408409
NV_PRINTK(err, cli, "pushbuf push count exceeds limit: %d max %d\n",
409-
req->push_count, NOUVEAU_GEM_MAX_PUSH);
410+
req->push_count, push_max);
410411
return nouveau_abi16_put(abi16, -EINVAL);
411412
}
412413

drivers/gpu/drm/nouveau/nouveau_exec.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@ int nouveau_exec_job_init(struct nouveau_exec_job **job,
5151
int nouveau_exec_ioctl_exec(struct drm_device *dev, void *data,
5252
struct drm_file *file_priv);
5353

54+
static inline unsigned int
55+
nouveau_exec_push_max_from_ib_max(int ib_max)
56+
{
57+
/* Limit the number of IBs per job to half the size of the ring in order
58+
* to avoid the ring running dry between submissions and preserve one
59+
* more slot for the job's HW fence.
60+
*/
61+
return ib_max > 1 ? ib_max / 2 - 1 : 0;
62+
}
63+
5464
#endif

drivers/gpu/drm/tests/drm_kunit_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void drm_kunit_helper_free_device(struct kunit *test, struct device *dev)
118118

119119
kunit_release_action(test,
120120
kunit_action_platform_driver_unregister,
121-
pdev);
121+
&fake_platform_driver);
122122
}
123123
EXPORT_SYMBOL_GPL(drm_kunit_helper_free_device);
124124

include/uapi/drm/nouveau_drm.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ extern "C" {
4444
#define NOUVEAU_GETPARAM_PTIMER_TIME 14
4545
#define NOUVEAU_GETPARAM_HAS_BO_USAGE 15
4646
#define NOUVEAU_GETPARAM_HAS_PAGEFLIP 16
47+
48+
/**
49+
* @NOUVEAU_GETPARAM_EXEC_PUSH_MAX
50+
*
51+
* Query the maximum amount of IBs that can be pushed through a single
52+
* &drm_nouveau_exec structure and hence a single &DRM_IOCTL_NOUVEAU_EXEC
53+
* ioctl().
54+
*/
55+
#define NOUVEAU_GETPARAM_EXEC_PUSH_MAX 17
56+
4757
struct drm_nouveau_getparam {
4858
__u64 param;
4959
__u64 value;

0 commit comments

Comments
 (0)