drm/nouveau/i2c: fix number of aux event slots
Subsystems (3)
PATCH 1/3 drm/nouveau/i2c: fix number of aux event slots
From: Ben Skeggs <[email protected]>
This was completely bogus before, using maximum DCB device index rather than maximum AUX ID to size the buffer that stores event refcounts.
*Pretty* unlikely to have been an actual problem on most configurations, that is, unless you've got one of the rare boards that have off-chip DP.
There, it'll likely crash.
--- drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h | 4 ++-- drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h +2 -2
@@ -16,7 +16,7 @@ struct nvkm_i2c_bus {const struct nvkm_i2c_bus_func *func;struct nvkm_i2c_pad *pad;#define NVKM_I2C_BUS_CCB (n)/* 'n' is ccb index */ (n) -#define NVKM_I2C_BUS_EXT (n)/* 'n' is dcb external encoder type */ ((n) + 0x100) +#define NVKM_I2C_BUS_EXT (n)/* 'n' is dcb external encoder type */ ((n) + 0x10)#define NVKM_I2C_BUS_PRI /* ccb primary comm. port */ -1#define NVKM_I2C_BUS_SEC /* ccb secondary comm. port */ -2int id;
@@ -38,7 +38,7 @@ struct nvkm_i2c_aux {const struct nvkm_i2c_aux_func *func;struct nvkm_i2c_pad *pad;#define NVKM_I2C_AUX_CCB (n)/* 'n' is ccb index */ (n) -#define NVKM_I2C_AUX_EXT (n)/* 'n' is dcb external encoder type */ ((n) + 0x100) +#define NVKM_I2C_AUX_EXT (n)/* 'n' is dcb external encoder type */ ((n) + 0x10)int id;struct mutex mutex;
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c +9 -2
@@ -260,10 +260,11 @@ nvkm_i2c_new_(const struct nvkm_i2c_func *func, struct nvkm_device *device, {struct nvkm_bios *bios = device->bios;struct nvkm_i2c *i2c; +struct nvkm_i2c_aux *aux;struct dcb_i2c_entry ccbE;struct dcb_output dcbE;u8 ver, hdr; -int ret, i; +int ret, i, ids;if (!(i2c = *pi2c =kzalloc (sizeof (*i2c),GFP_KERNEL )))return -ENOMEM ;
@@ -406,5 +407,11 @@ nvkm_i2c_new_(const struct nvkm_i2c_func *func, struct nvkm_device *device, } } -return nvkm_event_init (&nvkm_i2c_intr_func, &i2c->subdev,4 , i, &i2c->event); + ids =0 ; +list_for_each_entry (aux, &i2c->aux, head) + ids =max (ids, aux->id +1 ); +if (!ids) +return 0 ; + +return nvkm_event_init (&nvkm_i2c_intr_func, &i2c->subdev,4 , ids, &i2c->event); }
Signature · 1 line
2.41.0
PATCH 2/3 drm/nouveau/disp: PIOR DP uses GPIO for HPD, not PMGR AUX interrupts
From: Ben Skeggs <[email protected]>
Fixes crash on boards with ANX9805 TMDS/DP encoders.
--- .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c +18 -9
@@ -81,20 +81,29 @@ nvkm_uconn_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_return -ENOSYS ;list_for_each_entry (outp, &conn->disp->outps, head) { -if (outp->info.connector == conn->index && outp->dp.aux) { -if (args->v0.types &NVIF_CONN_EVENT_V0_PLUG ) bits |=NVKM_I2C_PLUG ; -if (args->v0.types &NVIF_CONN_EVENT_V0_UNPLUG ) bits |=NVKM_I2C_UNPLUG ; -if (args->v0.types &NVIF_CONN_EVENT_V0_IRQ ) bits |=NVKM_I2C_IRQ ; +if (outp->info.connector == conn->index) +break ; + } -return nvkm_uevent_add (uevent, &device->i2c->event, outp->dp.aux->id, bits, - nvkm_uconn_uevent_aux); - } +if (&outp->head == &conn->disp->outps) +return -EINVAL ; + +if (outp->dp.aux && !outp->info.location) { +if (args->v0.types &NVIF_CONN_EVENT_V0_PLUG ) bits |=NVKM_I2C_PLUG ; +if (args->v0.types &NVIF_CONN_EVENT_V0_UNPLUG ) bits |=NVKM_I2C_UNPLUG ; +if (args->v0.types &NVIF_CONN_EVENT_V0_IRQ ) bits |=NVKM_I2C_IRQ ; + +return nvkm_uevent_add (uevent, &device->i2c->event, outp->dp.aux->id, bits, + nvkm_uconn_uevent_aux); }if (args->v0.types &NVIF_CONN_EVENT_V0_PLUG ) bits |=NVKM_GPIO_HI ;if (args->v0.types &NVIF_CONN_EVENT_V0_UNPLUG ) bits |=NVKM_GPIO_LO ; -if (args->v0.types &NVIF_CONN_EVENT_V0_IRQ ) -return -EINVAL ; +if (args->v0.types &NVIF_CONN_EVENT_V0_IRQ ) { +/* TODO: support DP IRQ on ANX9805 and remove this hack. */ +if (!outp->info.location) +return -EINVAL ; + }return nvkm_uevent_add (uevent, &device->gpio->event, conn->info.hpd, bits, nvkm_uconn_uevent_gpio);
Signature · 1 line
2.41.0
Re: [Nouveau] [PATCH 2/3] drm/nouveau/disp: PIOR DP uses GPIO for HPD, not PMGR AUX interrupts
Quoted 54 lines · Ben Skeggs
From: Ben Skeggs <[email protected]>
Fixes crash on boards with ANX9805 TMDS/DP encoders.
Signed-off-by Ben Skeggs <[email protected]>--- .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c +18
-10@@ -81,20 +81,29 @@ nvkm_uconn_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_return -ENOSYS ;list_for_each_entry (outp, &conn->disp->outps, head) { -if (outp->info.connector == conn->index && outp->dp.aux) { -if (args->v0.types &NVIF_CONN_EVENT_V0_PLUG ) bits |=NVKM_I2C_PLUG ; -if (args->v0.types &NVIF_CONN_EVENT_V0_UNPLUG ) bits |=NVKM_I2C_UNPLUG ; -if (args->v0.types &NVIF_CONN_EVENT_V0_IRQ ) bits |=NVKM_I2C_IRQ ; +if (outp->info.connector == conn->index) +break ; + } -return nvkm_uevent_add (uevent, &device->i2c->event, outp->dp.aux->id, bits, - nvkm_uconn_uevent_aux); - } +if (&outp->head == &conn->disp->outps) +return -EINVAL ; + +if (outp->dp.aux && !outp->info.location) { +if (args->v0.types &NVIF_CONN_EVENT_V0_PLUG ) bits |=NVKM_I2C_PLUG ; +if (args->v0.types &NVIF_CONN_EVENT_V0_UNPLUG ) bits |=NVKM_I2C_UNPLUG ; +if (args->v0.types &NVIF_CONN_EVENT_V0_IRQ ) bits |=NVKM_I2C_IRQ ; + +return nvkm_uevent_add (uevent, &device->i2c->event, outp->dp.aux->id, bits, + nvkm_uconn_uevent_aux); }if (args->v0.types &NVIF_CONN_EVENT_V0_PLUG ) bits |=NVKM_GPIO_HI ;if (args->v0.types &NVIF_CONN_EVENT_V0_UNPLUG ) bits |=NVKM_GPIO_LO ; -if (args->v0.types &NVIF_CONN_EVENT_V0_IRQ ) -return -EINVAL ; +if (args->v0.types &NVIF_CONN_EVENT_V0_IRQ ) { +/* TODO: support DP IRQ on ANX9805 and remove this hack. */ +if (!outp->info.location) +return -EINVAL ; + }return nvkm_uevent_add (uevent, &device->gpio->event, conn->info.hpd, bits, nvkm_uconn_uevent_gpio); --
Quoted 2 lines
2.41.0
PATCH 3/3 drm/nouveau/kms/nv50-: init hpd_irq_lock for PIOR DP
In reply to Ben SkeggsFrom: Ben Skeggs <[email protected]>
Fixes OOPS on boards with ANX9805 DP encoders.
--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/nouveau/dispnv50/disp.c +4 -0
@@ -1873,6 +1873,8 @@ nv50_pior_destroy(struct drm_encoder *encoder)nvif_outp_dtor (&nv_encoder->outp);drm_encoder_cleanup (encoder); + +mutex_destroy (&nv_encoder->dp.hpd_irq_lock);kfree (encoder); }
@@ -1917,6 +1919,8 @@ nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe) nv_encoder->i2c = ddc; nv_encoder->aux = aux; +mutex_init (&nv_encoder->dp.hpd_irq_lock); + encoder =to_drm_encoder (nv_encoder); encoder->possible_crtcs = dcbe->heads; encoder->possible_clones =0 ;
Signature · 1 line
2.41.0
Re: [Nouveau] [PATCH 3/3] drm/nouveau/kms/nv50-: init hpd_irq_lock for PIOR DP
Quoted 33 lines · Ben Skeggs
From: Ben Skeggs <[email protected]>
Fixes OOPS on boards with ANX9805 DP encoders.
Signed-off-by Ben Skeggs <[email protected]>--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/nouveau/dispnv50/disp.c +4
-1@@ -1873,6 +1873,8 @@ nv50_pior_destroy(struct drm_encoder *encoder)nvif_outp_dtor (&nv_encoder->outp);drm_encoder_cleanup (encoder); + +mutex_destroy (&nv_encoder->dp.hpd_irq_lock);kfree (encoder); }@@ -1917,6 +1919,8 @@ nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe) nv_encoder->i2c = ddc; nv_encoder->aux = aux; +mutex_init (&nv_encoder->dp.hpd_irq_lock); + encoder =to_drm_encoder (nv_encoder); encoder->possible_crtcs = dcbe->heads; encoder->possible_clones =0 ; --
Quoted 2 lines
2.41.0
Quoted 70 lines · Ben Skeggs
From: Ben Skeggs <[email protected]>
This was completely bogus before, using maximum DCB device index rather than maximum AUX ID to size the buffer that stores event refcounts.
*Pretty* unlikely to have been an actual problem on most configurations, that is, unless you've got one of the rare boards that have off-chip DP.
There, it'll likely crash.
Signed-off-by Ben Skeggs <[email protected]>--- drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h | 4 ++-- drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-)drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h +2
-2@@ -16,7 +16,7 @@ struct nvkm_i2c_bus {const struct nvkm_i2c_bus_func *func;struct nvkm_i2c_pad *pad;#define NVKM_I2C_BUS_CCB (n)/* 'n' is ccb index */ (n) -#define NVKM_I2C_BUS_EXT (n)/* 'n' is dcb external encoder type */ ((n) + 0x100) +#define NVKM_I2C_BUS_EXT (n)/* 'n' is dcb external encoder type */ ((n) + 0x10)#define NVKM_I2C_BUS_PRI /* ccb primary comm. port */ -1#define NVKM_I2C_BUS_SEC /* ccb secondary comm. port */ -2int id;@@ -38,7 +38,7 @@ struct nvkm_i2c_aux {const struct nvkm_i2c_aux_func *func;struct nvkm_i2c_pad *pad;#define NVKM_I2C_AUX_CCB (n)/* 'n' is ccb index */ (n) -#define NVKM_I2C_AUX_EXT (n)/* 'n' is dcb external encoder type */ ((n) + 0x100) +#define NVKM_I2C_AUX_EXT (n)/* 'n' is dcb external encoder type */ ((n) + 0x10)int id;struct mutex mutex;drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c +9
-3@@ -260,10 +260,11 @@ nvkm_i2c_new_(const struct nvkm_i2c_func *func, struct nvkm_device *device, {struct nvkm_bios *bios = device->bios;struct nvkm_i2c *i2c; +struct nvkm_i2c_aux *aux;struct dcb_i2c_entry ccbE;struct dcb_output dcbE;u8 ver, hdr; -int ret, i; +int ret, i, ids;if (!(i2c = *pi2c =kzalloc (sizeof (*i2c),GFP_KERNEL )))return -ENOMEM ;@@ -406,5 +407,11 @@ nvkm_i2c_new_(const struct nvkm_i2c_func *func, struct nvkm_device *device, } } -return nvkm_event_init (&nvkm_i2c_intr_func, &i2c->subdev,4 , i, &i2c->event); + ids =0 ; +list_for_each_entry (aux, &i2c->aux, head) + ids =max (ids, aux->id +1 ); +if (!ids) +return 0 ; + +return nvkm_event_init (&nvkm_i2c_intr_func, &i2c->subdev,4 , ids, &i2c->event); } --
Quoted 2 lines
2.41.0