Some lil nitpicks
On Wed, 2026-07-15 at 01:14 +0400, Mohamed Ahmed wrote:
> + case NVKM_GSP_RUSD_ROWREMAP_HIST_MAX ...
> NVKM_GSP_RUSD_ROWREMAP_FAILURE: {
> + RUSD_MEM_ROW_REMAP remap;
> +
> + ret = r570_rusd_read_section(gsp,
> + offsetof(NV00DE_SHARED_DATA,
> memRowRemap),
> + sizeof(remap), &remap);
> + if (ret)
> + return ret;
> +
> + switch (item) {
> + case NVKM_GSP_RUSD_ROWREMAP_HIST_MAX:
> + *val = remap.info.histogramMax;
> + break;
> + case NVKM_GSP_RUSD_ROWREMAP_HIST_HIGH:
> + *val = remap.info.histogramHigh;
> + break;
> + case NVKM_GSP_RUSD_ROWREMAP_HIST_PARTIAL:
> + *val = remap.info.histogramPartial;
> + break;
> + case NVKM_GSP_RUSD_ROWREMAP_HIST_LOW:
> + *val = remap.info.histogramLow;
> + break;
> + case NVKM_GSP_RUSD_ROWREMAP_HIST_NONE:
> + *val = remap.info.histogramNone;
> + break;
> + case NVKM_GSP_RUSD_ROWREMAP_CORRECTABLE:
> + *val = remap.info.correctableRows;
> + break;
> + case NVKM_GSP_RUSD_ROWREMAP_UNCORRECTABLE:
> + *val = remap.info.uncorrectableRows;
> + break;
> + case NVKM_GSP_RUSD_ROWREMAP_PENDING:
> + *val = remap.info.isPending;
> + break;
> + default: /* NVKM_GSP_RUSD_ROWREMAP_FAILURE */
> + *val = remap.info.hasFailureOccurred;
> + break;
Maybe this should be an explicit case instead of default, so we can
drm_WARN_ON_ONCE unknown values?
> + }
> + return 0;
> + }
> + case NVKM_GSP_RUSD_PCIE_GEN ...
> NVKM_GSP_RUSD_PCIE_UNSUPPORTED_REQUESTS: {
> + RUSD_PCIE_DATA pcie;
> +
> + int idx = item - NVKM_GSP_RUSD_PCIE_GEN;
> +
> + ret = r570_rusd_read_section(gsp,
> + offsetof(NV00DE_SHARED_DATA,
> pciBusData),
> + sizeof(pcie), &pcie);
> + if (ret)
> + return ret;
> +
> + *val = pcie.info.data[idx];
> + return 0;
> + }
> + default:
> + return -EINVAL;
> + }
> +
> + /* A reading of 0 mW is indistinguishable from "not supported on this
> + * board" (e.g. module power on Ampere/Hopper).
> + */
> + if (!mw)
> + return -ENODATA;
> +
> + *val = (s64)mw * 1000;
> + return 0;
> +}
> +
> +const struct nvkm_rm_api_rusd
> +r570_rusd = {
> + .init = r570_rusd_init,
> + .resume = r570_rusd_resume,
> + .read = r570_rusd_read,
> +};
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h
> b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h
> index a9af94adf9ef..1338b4a88f95 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h
> @@ -130,6 +130,12 @@ struct nvkm_rm_api {
> void (*fini)(struct r535_gr *);
> } scrubber;
> } *gr;
> +
> + const struct nvkm_rm_api_rusd {
> + int (*init)(struct nvkm_gsp *);
> + void (*resume)(struct nvkm_gsp *);
> + int (*read)(struct nvkm_gsp *, enum nvkm_gsp_rusd_item, s64 *);
> + } *rusd;
> };
>
> extern const struct nvkm_rm_impl r535_rm_tu102;
> @@ -188,4 +194,5 @@ extern const struct nvkm_rm_api_gr r570_gr;
> int r570_gr_gpc_mask(struct nvkm_gsp *, u32 *mask);
> int r570_gr_tpc_mask(struct nvkm_gsp *, int gpc, u32 *mask);
> extern const struct nvkm_rm_api_engine r570_ofa;
> +extern const struct nvkm_rm_api_rusd r570_rusd;
> #endif