From d44960d4242ece619e9877601ba90af19ef2afc0 Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Mon, 18 May 2020 17:11:31 +0300 Subject: [PATCH] gpu: nvgpu: add PDI reporting for GP10B (Linux) Read the T186 SoC PDI fuse registers to retrieve the per-device identifier for GP10B. Bug 2957580 Signed-off-by: Sami Kiminki Change-Id: Ie5031a005ca251636614d27c2dc77bddfce0ea21 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2350930 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/hal/init/hal_gp10b.c | 2 ++ drivers/gpu/nvgpu/include/nvgpu/fuse.h | 19 +++++++++++++++++++ drivers/gpu/nvgpu/os/linux/fuse.c | 19 +++++++++++++++++++ drivers/gpu/nvgpu/os/posix/fuse.c | 7 +++++++ 4 files changed, 47 insertions(+) diff --git a/drivers/gpu/nvgpu/hal/init/hal_gp10b.c b/drivers/gpu/nvgpu/hal/init/hal_gp10b.c index 9275bfd19..ac8d7ad61 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_gp10b.c +++ b/drivers/gpu/nvgpu/hal/init/hal_gp10b.c @@ -1217,6 +1217,8 @@ static const struct gpu_ops gp10b_ops = { .read_vin_cal_gain_offset_fuse = NULL, .read_gcplex_config_fuse = nvgpu_tegra_fuse_read_gcplex_config_fuse, + .read_per_device_identifier = + nvgpu_tegra_fuse_read_per_device_identifier, }, .top = { .device_info_parse_enum = gm20b_device_info_parse_enum, diff --git a/drivers/gpu/nvgpu/include/nvgpu/fuse.h b/drivers/gpu/nvgpu/include/nvgpu/fuse.h index 547758c97..e52f77e8c 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/fuse.h +++ b/drivers/gpu/nvgpu/include/nvgpu/fuse.h @@ -105,6 +105,18 @@ void nvgpu_tegra_fuse_write_opt_gpu_tpc1_disable(struct gk20a *g, u32 val); */ int nvgpu_tegra_fuse_read_gcplex_config_fuse(struct gk20a *g, u32 *val); +/** + * @brief - Reads the per-device identifier fuses. + * + * @param g [in] - GPU super structure. + * @param pdi [out] - Per-device identifier + * + * The per-device identifier fuses are FUSE_PDI0 and FUSE_PDI1. + * + * @return 0 on success + */ +int nvgpu_tegra_fuse_read_per_device_identifier(struct gk20a *g, u64 *pdi); + #else /* CONFIG_NVGPU_TEGRA_FUSE */ #ifdef CONFIG_NVGPU_NON_FUSA @@ -150,5 +162,12 @@ static inline int nvgpu_tegra_fuse_read_gcplex_config_fuse(struct gk20a *g, return 0; } +static inline int nvgpu_tegra_fuse_read_per_device_identifier(struct gk20a *g, u64 *pdi) +{ + *pdi = 0U; + + return 0; +} + #endif /* CONFIG_NVGPU_TEGRA_FUSE */ #endif /* NVGPU_FUSE_H */ diff --git a/drivers/gpu/nvgpu/os/linux/fuse.c b/drivers/gpu/nvgpu/os/linux/fuse.c index 3dc2013a7..ca2748d19 100644 --- a/drivers/gpu/nvgpu/os/linux/fuse.c +++ b/drivers/gpu/nvgpu/os/linux/fuse.c @@ -55,3 +55,22 @@ int nvgpu_tegra_fuse_read_reserved_calib(struct gk20a *g, u32 *val) { return tegra_fuse_readl(FUSE_RESERVED_CALIB0_0, val); } + +int nvgpu_tegra_fuse_read_per_device_identifier(struct gk20a *g, u64 *pdi) +{ + u32 lo = 0U; + u32 hi = 0U; + int err; + + err = tegra_fuse_readl(FUSE_PDI0, &lo); + if (err) + return err; + + err = tegra_fuse_readl(FUSE_PDI1, &hi); + if (err) + return err; + + *pdi = ((u64)lo) | (((u64)hi) << 32); + + return 0; +} diff --git a/drivers/gpu/nvgpu/os/posix/fuse.c b/drivers/gpu/nvgpu/os/posix/fuse.c index cab09f6ef..c97d9eb02 100644 --- a/drivers/gpu/nvgpu/os/posix/fuse.c +++ b/drivers/gpu/nvgpu/os/posix/fuse.c @@ -115,3 +115,10 @@ int nvgpu_tegra_fuse_read_reserved_calib(struct gk20a *g, u32 *val) return p->callbacks->tegra_fuse_readl(FUSE_RESERVED_CALIB0_0, val); } #endif + +int nvgpu_tegra_fuse_read_per_device_identifier(struct gk20a *g, u64 *pdi) +{ + *pdi = 0; + + return 0; +}