diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2022-06-01 20:46:28 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2022-07-27 09:05:47 +1000 |
commit | 79c453af55d9f1e85b906211ea4051364d28dcb4 (patch) | |
tree | fbd5497d397d166f893f13603c8c32a5ebce28a8 /drivers/gpu/drm/nouveau | |
parent | 1c6aab75ece7c1d450e4561cb2263403eeb7ae2f (diff) | |
download | linux-79c453af55d9f1e85b906211ea4051364d28dcb4.tar.bz2 |
drm/nouveau/disp: replace hda func pointer check with flag
Simpler, and less error-prone than a separate set of function pointers.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau')
17 files changed, 31 insertions, 168 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c index af5d35149412..43dc73abad61 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c @@ -109,7 +109,7 @@ g84_sor = { int g84_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&g84_sor, disp, SOR, id); + return nvkm_ior_new_(&g84_sor, disp, SOR, id, false); } static const struct nvkm_disp_mthd_list diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c index 5c9a769ff3bd..92feface3624 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c @@ -298,7 +298,7 @@ g94_sor = { static int g94_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&g94_sor, disp, SOR, id); + return nvkm_ior_new_(&g94_sor, disp, SOR, id, false); } int diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c index c693ad09fc83..9d008f090efe 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c @@ -84,7 +84,7 @@ ga102_sor_clock(struct nvkm_ior *sor) } static const struct nvkm_ior_func -ga102_sor_hda = { +ga102_sor = { .route = { .get = gm200_sor_route_get, .set = gm200_sor_route_set, @@ -114,40 +114,13 @@ ga102_sor_hda = { }, }; -static const struct nvkm_ior_func -ga102_sor = { - .route = { - .get = gm200_sor_route_get, - .set = gm200_sor_route_set, - }, - .state = gv100_sor_state, - .power = nv50_sor_power, - .clock = ga102_sor_clock, - .hdmi = { - .ctrl = gv100_sor_hdmi_ctrl, - .scdc = gm200_sor_hdmi_scdc, - }, - .dp = { - .lanes = { 0, 1, 2, 3 }, - .links = ga102_sor_dp_links, - .power = g94_sor_dp_power, - .pattern = gm107_sor_dp_pattern, - .drive = gm200_sor_dp_drive, - .vcpi = tu102_sor_dp_vcpi, - .audio = gv100_sor_dp_audio, - .audio_sym = gv100_sor_dp_audio_sym, - .watermark = gv100_sor_dp_watermark, - }, -}; - static int ga102_sor_new(struct nvkm_disp *disp, int id) { struct nvkm_device *device = disp->engine.subdev.device; u32 hda = nvkm_rd32(device, 0x08a15c); - if (hda & BIT(id)) - return nvkm_ior_new_(&ga102_sor_hda, disp, SOR, id); - return nvkm_ior_new_(&ga102_sor, disp, SOR, id); + + return nvkm_ior_new_(&ga102_sor, disp, SOR, id, hda & BIT(id)); } static const struct nvkm_disp_func diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c index 75b7b41d5727..e6ebc72ed6db 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c @@ -309,7 +309,7 @@ gf119_sor = { static int gf119_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&gf119_sor, disp, SOR, id); + return nvkm_ior_new_(&gf119_sor, disp, SOR, id, true); } int @@ -357,7 +357,7 @@ gf119_dac = { int gf119_dac_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&gf119_dac, disp, DAC, id); + return nvkm_ior_new_(&gf119_dac, disp, DAC, id, false); } int diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c index 1c9a5e0d1ddd..b562a4d8ad2f 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c @@ -116,7 +116,7 @@ gk104_sor = { int gk104_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&gk104_sor, disp, SOR, id); + return nvkm_ior_new_(&gk104_sor, disp, SOR, id, true); } static const struct nvkm_disp_mthd_list diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c index 301d7a9692c8..0b25999e0e25 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c @@ -81,7 +81,7 @@ gm107_sor = { static int gm107_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&gm107_sor, disp, SOR, id); + return nvkm_ior_new_(&gm107_sor, disp, SOR, id, true); } static const struct nvkm_disp_func diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c index c65d85b4299e..990f3782d0c3 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c @@ -110,7 +110,7 @@ gm200_sor_route_get(struct nvkm_outp *outp, int *link) } static const struct nvkm_ior_func -gm200_sor_hda = { +gm200_sor = { .route = { .get = gm200_sor_route_get, .set = gm200_sor_route_set, @@ -140,32 +140,6 @@ gm200_sor_hda = { }, }; -static const struct nvkm_ior_func -gm200_sor = { - .route = { - .get = gm200_sor_route_get, - .set = gm200_sor_route_set, - }, - .state = gf119_sor_state, - .power = nv50_sor_power, - .clock = gf119_sor_clock, - .hdmi = { - .ctrl = gk104_sor_hdmi_ctrl, - .scdc = gm200_sor_hdmi_scdc, - }, - .dp = { - .lanes = { 0, 1, 2, 3 }, - .links = gf119_sor_dp_links, - .power = g94_sor_dp_power, - .pattern = gm107_sor_dp_pattern, - .drive = gm200_sor_dp_drive, - .vcpi = gf119_sor_dp_vcpi, - .audio = gf119_sor_dp_audio, - .audio_sym = gf119_sor_dp_audio_sym, - .watermark = gf119_sor_dp_watermark, - }, -}; - static int gm200_sor_new(struct nvkm_disp *disp, int id) { @@ -175,10 +149,7 @@ gm200_sor_new(struct nvkm_disp *disp, int id) if (!((hda = nvkm_rd32(device, 0x08a15c)) & 0x40000000)) hda = nvkm_rd32(device, 0x101034); - if (hda & BIT(id)) - return nvkm_ior_new_(&gm200_sor_hda, disp, SOR, id); - - return nvkm_ior_new_(&gm200_sor, disp, SOR, id); + return nvkm_ior_new_(&gm200_sor, disp, SOR, id, hda & BIT(id)); } static const struct nvkm_disp_func diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c index 603b7188f1cf..beec3c8187a2 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c @@ -29,7 +29,7 @@ #include <nvif/class.h> static const struct nvkm_ior_func -gp100_sor_hda = { +gp100_sor = { .route = { .get = gm200_sor_route_get, .set = gm200_sor_route_set, @@ -59,32 +59,6 @@ gp100_sor_hda = { }, }; -static const struct nvkm_ior_func -gp100_sor = { - .route = { - .get = gm200_sor_route_get, - .set = gm200_sor_route_set, - }, - .state = gf119_sor_state, - .power = nv50_sor_power, - .clock = gf119_sor_clock, - .hdmi = { - .ctrl = gk104_sor_hdmi_ctrl, - .scdc = gm200_sor_hdmi_scdc, - }, - .dp = { - .lanes = { 0, 1, 2, 3 }, - .links = gf119_sor_dp_links, - .power = g94_sor_dp_power, - .pattern = gm107_sor_dp_pattern, - .drive = gm200_sor_dp_drive, - .vcpi = gf119_sor_dp_vcpi, - .audio = gf119_sor_dp_audio, - .audio_sym = gf119_sor_dp_audio_sym, - .watermark = gf119_sor_dp_watermark, - }, -}; - int gp100_sor_new(struct nvkm_disp *disp, int id) { @@ -94,9 +68,7 @@ gp100_sor_new(struct nvkm_disp *disp, int id) if (!((hda = nvkm_rd32(device, 0x08a15c)) & 0x40000000)) hda = nvkm_rd32(device, 0x10ebb0) >> 8; - if (hda & BIT(id)) - return nvkm_ior_new_(&gp100_sor_hda, disp, SOR, id); - return nvkm_ior_new_(&gp100_sor, disp, SOR, id); + return nvkm_ior_new_(&gp100_sor, disp, SOR, id, hda & BIT(id)); } static const struct nvkm_disp_func diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c index 98d99e1c01b2..72a4c28ccd18 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c @@ -168,7 +168,7 @@ gt215_sor = { static int gt215_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(>215_sor, disp, SOR, id); + return nvkm_ior_new_(>215_sor, disp, SOR, id, true); } static const struct nvkm_disp_func diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c index 18c40e398ea5..aac1cdbea160 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c @@ -165,7 +165,7 @@ gv100_sor_state(struct nvkm_ior *sor, struct nvkm_ior_state *state) } static const struct nvkm_ior_func -gv100_sor_hda = { +gv100_sor = { .route = { .get = gm200_sor_route_get, .set = gm200_sor_route_set, @@ -194,31 +194,6 @@ gv100_sor_hda = { }, }; -static const struct nvkm_ior_func -gv100_sor = { - .route = { - .get = gm200_sor_route_get, - .set = gm200_sor_route_set, - }, - .state = gv100_sor_state, - .power = nv50_sor_power, - .clock = gf119_sor_clock, - .hdmi = { - .ctrl = gv100_sor_hdmi_ctrl, - .scdc = gm200_sor_hdmi_scdc, - }, - .dp = { - .lanes = { 0, 1, 2, 3 }, - .links = gf119_sor_dp_links, - .power = g94_sor_dp_power, - .pattern = gm107_sor_dp_pattern, - .drive = gm200_sor_dp_drive, - .audio = gv100_sor_dp_audio, - .audio_sym = gv100_sor_dp_audio_sym, - .watermark = gv100_sor_dp_watermark, - }, -}; - static int gv100_sor_new(struct nvkm_disp *disp, int id) { @@ -228,10 +203,7 @@ gv100_sor_new(struct nvkm_disp *disp, int id) if (!((hda = nvkm_rd32(device, 0x08a15c)) & 0x40000000)) hda = nvkm_rd32(device, 0x118fb0) >> 8; - if (hda & BIT(id)) - return nvkm_ior_new_(&gv100_sor_hda, disp, SOR, id); - - return nvkm_ior_new_(&gv100_sor, disp, SOR, id); + return nvkm_ior_new_(&gv100_sor, disp, SOR, id, hda & BIT(id)); } int diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.c index 1963cc183b87..e420bf2e4330 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.c @@ -55,7 +55,7 @@ nvkm_ior_del(struct nvkm_ior **pior) int nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *disp, - enum nvkm_ior_type type, int id) + enum nvkm_ior_type type, int id, bool hda) { struct nvkm_ior *ior; if (!(ior = kzalloc(sizeof(*ior), GFP_KERNEL))) @@ -64,6 +64,7 @@ nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *disp, ior->disp = disp; ior->type = type; ior->id = id; + ior->hda = hda; snprintf(ior->name, sizeof(ior->name), "%s-%d", nvkm_ior_name[ior->type], ior->id); list_add_tail(&ior->head, &disp->iors); IOR_DBG(ior, "ctor"); diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h index a8bd12a6bbf9..d1e494e06c38 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h @@ -13,6 +13,7 @@ struct nvkm_ior { PIOR, } type; int id; + bool hda; char name[8]; struct list_head head; @@ -93,7 +94,7 @@ struct nvkm_ior_func { }; int nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *, - enum nvkm_ior_type type, int id); + enum nvkm_ior_type type, int id, bool hda); void nvkm_ior_del(struct nvkm_ior **); struct nvkm_ior *nvkm_ior_find(struct nvkm_disp *, enum nvkm_ior_type, int id); diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c index fb8bfb98c105..f0d23a66b782 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c @@ -49,7 +49,7 @@ mcp77_sor = { static int mcp77_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&mcp77_sor, disp, SOR, id); + return nvkm_ior_new_(&mcp77_sor, disp, SOR, id, false); } static const struct nvkm_disp_func diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c index 8b9e97665805..25a1934f6882 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c @@ -54,7 +54,7 @@ mcp89_sor = { static int mcp89_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&mcp89_sor, disp, SOR, id); + return nvkm_ior_new_(&mcp89_sor, disp, SOR, id, true); } static const struct nvkm_disp_func diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c index 1a3151528e7e..a50239d2077f 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c @@ -147,7 +147,7 @@ nv50_pior = { int nv50_pior_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&nv50_pior, disp, PIOR, id); + return nvkm_ior_new_(&nv50_pior, disp, PIOR, id, false); } int @@ -228,7 +228,7 @@ nv50_sor = { static int nv50_sor_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&nv50_sor, disp, SOR, id); + return nvkm_ior_new_(&nv50_sor, disp, SOR, id, false); } int @@ -324,7 +324,7 @@ nv50_dac = { int nv50_dac_new(struct nvkm_disp *disp, int id) { - return nvkm_ior_new_(&nv50_dac, disp, DAC, id); + return nvkm_ior_new_(&nv50_dac, disp, DAC, id, false); } int diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c index f527adc2e883..6094805fbd63 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c @@ -120,7 +120,7 @@ nvkm_outp_acquire_hda(struct nvkm_outp *outp, enum nvkm_ior_type type, /* Failing that, a completely unused OR is the next best thing. */ list_for_each_entry(ior, &outp->disp->iors, head) { - if (!ior->identity && !!ior->func->hda.hpd == hda && + if (!ior->identity && ior->hda == hda && !ior->asy.outp && ior->type == type && !ior->arm.outp && (ior->func->route.set || ior->id == __ffs(outp->info.or))) return nvkm_outp_acquire_ior(outp, user, ior); @@ -130,7 +130,7 @@ nvkm_outp_acquire_hda(struct nvkm_outp *outp, enum nvkm_ior_type type, * but will be released during the next modeset. */ list_for_each_entry(ior, &outp->disp->iors, head) { - if (!ior->identity && !!ior->func->hda.hpd == hda && + if (!ior->identity && ior->hda == hda && !ior->asy.outp && ior->type == type && (ior->func->route.set || ior->id == __ffs(outp->info.or))) return nvkm_outp_acquire_ior(outp, user, ior); @@ -181,7 +181,7 @@ nvkm_outp_acquire(struct nvkm_outp *outp, u8 user, bool hda) * * This warning is to make it obvious if that proves wrong. */ - WARN_ON(hda && !ior->func->hda.hpd); + WARN_ON(hda && !ior->hda); return nvkm_outp_acquire_ior(outp, user, ior); } } diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c index b9cd706f5451..febc9090632f 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c @@ -67,7 +67,7 @@ tu102_sor_dp_links(struct nvkm_ior *sor, struct nvkm_i2c_aux *aux) } static const struct nvkm_ior_func -tu102_sor_hda = { +tu102_sor = { .route = { .get = gm200_sor_route_get, .set = gm200_sor_route_set, @@ -97,40 +97,13 @@ tu102_sor_hda = { }, }; -static const struct nvkm_ior_func -tu102_sor = { - .route = { - .get = gm200_sor_route_get, - .set = gm200_sor_route_set, - }, - .state = gv100_sor_state, - .power = nv50_sor_power, - .clock = gf119_sor_clock, - .hdmi = { - .ctrl = gv100_sor_hdmi_ctrl, - .scdc = gm200_sor_hdmi_scdc, - }, - .dp = { - .lanes = { 0, 1, 2, 3 }, - .links = tu102_sor_dp_links, - .power = g94_sor_dp_power, - .pattern = gm107_sor_dp_pattern, - .drive = gm200_sor_dp_drive, - .vcpi = tu102_sor_dp_vcpi, - .audio = gv100_sor_dp_audio, - .audio_sym = gv100_sor_dp_audio_sym, - .watermark = gv100_sor_dp_watermark, - }, -}; - static int tu102_sor_new(struct nvkm_disp *disp, int id) { struct nvkm_device *device = disp->engine.subdev.device; u32 hda = nvkm_rd32(device, 0x08a15c); - if (hda & BIT(id)) - return nvkm_ior_new_(&tu102_sor_hda, disp, SOR, id); - return nvkm_ior_new_(&tu102_sor, disp, SOR, id); + + return nvkm_ior_new_(&tu102_sor, disp, SOR, id, hda & BIT(id)); } int |