diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index c43330d4..fd74e667 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -88,7 +88,8 @@ struct tegra_drm_client_ops { struct drm_file *file); int (*get_streamid_offset)(struct tegra_drm_client *client, u32 *offset); int (*can_use_memory_ctx)(struct tegra_drm_client *client, bool *supported); - int (*has_job_timestamping)(struct tegra_drm_client *client, bool *supported); + int (*has_job_timestamping)(struct tegra_drm_client *client, bool *supported, + u32 *timestamp_shift); int (*skip_bl_swizzling)(struct tegra_drm_client *client, bool *skip); }; diff --git a/drivers/gpu/drm/tegra/nvdec.c b/drivers/gpu/drm/tegra/nvdec.c index 53571a17..fdb3ba92 100644 --- a/drivers/gpu/drm/tegra/nvdec.c +++ b/drivers/gpu/drm/tegra/nvdec.c @@ -714,11 +714,13 @@ static int nvdec_can_use_memory_ctx(struct tegra_drm_client *client, bool *suppo return 0; } -static int nvdec_has_job_timestamping(struct tegra_drm_client *client, bool *supported) +static int nvdec_has_job_timestamping(struct tegra_drm_client *client, bool *supported, + u32 *timestamp_shift) { struct nvdec *nvdec = to_nvdec(client); *supported = nvdec->config->supports_timestamping; + *timestamp_shift = 5; return 0; } diff --git a/drivers/gpu/drm/tegra/nvenc.c b/drivers/gpu/drm/tegra/nvenc.c index ca1b0e21..5dce335e 100644 --- a/drivers/gpu/drm/tegra/nvenc.c +++ b/drivers/gpu/drm/tegra/nvenc.c @@ -587,11 +587,13 @@ static int nvenc_can_use_memory_ctx(struct tegra_drm_client *client, bool *suppo return 0; } -static int nvenc_has_job_timestamping(struct tegra_drm_client *client, bool *supported) +static int nvenc_has_job_timestamping(struct tegra_drm_client *client, bool *supported, + u32 *timestamp_shift) { struct nvenc *nvenc = to_nvenc(client); *supported = nvenc->config->supports_timestamping; + *timestamp_shift = 5; return 0; } diff --git a/drivers/gpu/drm/tegra/nvjpg.c b/drivers/gpu/drm/tegra/nvjpg.c index f1361d97..a9ae7939 100644 --- a/drivers/gpu/drm/tegra/nvjpg.c +++ b/drivers/gpu/drm/tegra/nvjpg.c @@ -557,11 +557,13 @@ static int nvjpg_can_use_memory_ctx(struct tegra_drm_client *client, bool *suppo return 0; } -static int nvjpg_has_job_timestamping(struct tegra_drm_client *client, bool *supported) +static int nvjpg_has_job_timestamping(struct tegra_drm_client *client, bool *supported, + u32 *timestamp_shift) { struct nvjpg *nvjpg = to_nvjpg(client); *supported = nvjpg->config->supports_timestamping; + *timestamp_shift = 5; return 0; } diff --git a/drivers/gpu/drm/tegra/ofa.c b/drivers/gpu/drm/tegra/ofa.c index 5c9fe171..af59d698 100644 --- a/drivers/gpu/drm/tegra/ofa.c +++ b/drivers/gpu/drm/tegra/ofa.c @@ -511,9 +511,11 @@ static int ofa_can_use_memory_ctx(struct tegra_drm_client *client, bool *support return 0; } -static int ofa_has_job_timestamping(struct tegra_drm_client *client, bool *supported) +static int ofa_has_job_timestamping(struct tegra_drm_client *client, bool *supported, + u32 *timestamp_shift) { *supported = true; + *timestamp_shift = 5; return 0; } diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c index 47a86872..464800ff 100644 --- a/drivers/gpu/drm/tegra/submit.c +++ b/drivers/gpu/drm/tegra/submit.c @@ -538,9 +538,11 @@ static void release_job(struct host1x_job *job) if (IS_ENABLED(CONFIG_TRACING) && job_data->timestamps.virt) { u64 *timestamps = job_data->timestamps.virt; + u32 shift = job_data->timestamps.timestamp_shift; if (timestamps[0] != 0) - trace_job_timestamps(job_data->id, timestamps[0] >> 5, timestamps[1] >> 5); + trace_job_timestamps(job_data->id, timestamps[0] >> shift, + timestamps[1] >> shift); dma_free_coherent(job_data->timestamps.dev, 256, job_data->timestamps.virt, job_data->timestamps.iova); @@ -568,12 +570,14 @@ static int submit_init_profiling(struct tegra_drm_context *context, { struct device *mem_dev = tegra_drm_context_get_memory_device(context); bool has_timestamping = false; + u32 timestamp_shift; int err; if (!context->client->ops->has_job_timestamping) return 0; - err = context->client->ops->has_job_timestamping(context->client, &has_timestamping); + err = context->client->ops->has_job_timestamping(context->client, &has_timestamping, + ×tamp_shift); if (err) return err; @@ -586,6 +590,7 @@ static int submit_init_profiling(struct tegra_drm_context *context, return -ENOMEM; job_data->timestamps.dev = mem_dev; + job_data->timestamps.timestamp_shift = timestamp_shift; return 0; } diff --git a/drivers/gpu/drm/tegra/submit.h b/drivers/gpu/drm/tegra/submit.h index 9e67545b..d4df3749 100644 --- a/drivers/gpu/drm/tegra/submit.h +++ b/drivers/gpu/drm/tegra/submit.h @@ -18,6 +18,7 @@ struct tegra_drm_submit_data { struct device *dev; dma_addr_t iova; void *virt; + u32 timestamp_shift; } timestamps; }; diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index a41c9450..4c5e633a 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -65,6 +65,7 @@ struct vic_config { u32 actmon_active_borps; u32 actmon_active_weight; bool skip_bl_swizzling; + u32 timestamp_shift; }; struct vic { @@ -800,11 +801,13 @@ static int vic_can_use_memory_ctx(struct tegra_drm_client *client, bool *support return 0; } -static int vic_has_job_timestamping(struct tegra_drm_client *client, bool *supported) +static int vic_has_job_timestamping(struct tegra_drm_client *client, bool *supported, + u32 *timestamp_shift) { struct vic *vic = to_vic(client); *supported = vic->config->supports_timestamping; + *timestamp_shift = vic->config->timestamp_shift; return 0; } @@ -867,6 +870,7 @@ static const struct vic_config vic_t194_config = { .actmon_active_mask = 0x204c, .actmon_active_borps = 0x2050, .actmon_active_weight = 0x2054, + .timestamp_shift = 5, }; #define NVIDIA_TEGRA_234_VIC_FIRMWARE "nvidia/tegra234/vic.bin" @@ -881,6 +885,7 @@ static const struct vic_config vic_t234_config = { .actmon_active_mask = 0x204c, .actmon_active_borps = 0x2050, .actmon_active_weight = 0x2054, + .timestamp_shift = 5, }; #define NVIDIA_TEGRA_264_VIC_FIRMWARE "nvidia/tegra264/vic.bin" @@ -897,6 +902,7 @@ static const struct vic_config vic_t264_config = { .actmon_active_borps = 0x2250, .actmon_active_weight = 0x2254, .skip_bl_swizzling = true, + .timestamp_shift = 0, }; static const struct of_device_id tegra_vic_of_match[] = { diff --git a/drivers/gpu/drm/tegra/virt.c b/drivers/gpu/drm/tegra/virt.c index f38ea3ee..b3a2d430 100644 --- a/drivers/gpu/drm/tegra/virt.c +++ b/drivers/gpu/drm/tegra/virt.c @@ -133,9 +133,14 @@ static int virt_engine_can_use_memory_ctx(struct tegra_drm_client *client, bool return 0; } -static int virt_engine_has_job_timestamping(struct tegra_drm_client *client, bool *supported) +static int virt_engine_has_job_timestamping(struct tegra_drm_client *client, bool *supported, + u32 *timestamp_shift) { *supported = true; + *timestamp_shift = 5; + + if (of_machine_is_compatible("nvidia,tegra264")) + *timestamp_shift = 0; return 0; }