Skip to content

Commit 752a281

Browse files
Ben Skeggskarolherbst
authored andcommitted
drm/nouveau/i2c: fix number of aux event slots
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. Cc: stable@vger.kernel.org # 6.4+ Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Reviewed-by: Karol Herbst <kherbst@redhat.com> Signed-off-by: Karol Herbst <kherbst@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230719044051.6975-1-skeggsb@gmail.com
1 parent 05abb3b commit 752a281

File tree

2 files changed

+11
-4
lines changed
  • drivers/gpu/drm/nouveau

2 files changed

+11
-4
lines changed

drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct nvkm_i2c_bus {
1616
const struct nvkm_i2c_bus_func *func;
1717
struct nvkm_i2c_pad *pad;
1818
#define NVKM_I2C_BUS_CCB(n) /* 'n' is ccb index */ (n)
19-
#define NVKM_I2C_BUS_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x100)
19+
#define NVKM_I2C_BUS_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x10)
2020
#define NVKM_I2C_BUS_PRI /* ccb primary comm. port */ -1
2121
#define NVKM_I2C_BUS_SEC /* ccb secondary comm. port */ -2
2222
int id;
@@ -38,7 +38,7 @@ struct nvkm_i2c_aux {
3838
const struct nvkm_i2c_aux_func *func;
3939
struct nvkm_i2c_pad *pad;
4040
#define NVKM_I2C_AUX_CCB(n) /* 'n' is ccb index */ (n)
41-
#define NVKM_I2C_AUX_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x100)
41+
#define NVKM_I2C_AUX_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x10)
4242
int id;
4343

4444
struct mutex mutex;

drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,11 @@ nvkm_i2c_new_(const struct nvkm_i2c_func *func, struct nvkm_device *device,
260260
{
261261
struct nvkm_bios *bios = device->bios;
262262
struct nvkm_i2c *i2c;
263+
struct nvkm_i2c_aux *aux;
263264
struct dcb_i2c_entry ccbE;
264265
struct dcb_output dcbE;
265266
u8 ver, hdr;
266-
int ret, i;
267+
int ret, i, ids;
267268

268269
if (!(i2c = *pi2c = kzalloc(sizeof(*i2c), GFP_KERNEL)))
269270
return -ENOMEM;
@@ -406,5 +407,11 @@ nvkm_i2c_new_(const struct nvkm_i2c_func *func, struct nvkm_device *device,
406407
}
407408
}
408409

409-
return nvkm_event_init(&nvkm_i2c_intr_func, &i2c->subdev, 4, i, &i2c->event);
410+
ids = 0;
411+
list_for_each_entry(aux, &i2c->aux, head)
412+
ids = max(ids, aux->id + 1);
413+
if (!ids)
414+
return 0;
415+
416+
return nvkm_event_init(&nvkm_i2c_intr_func, &i2c->subdev, 4, ids, &i2c->event);
410417
}

0 commit comments

Comments
 (0)