devfreq: nvhost_podgov: fix build issue for K519+

Since K519+, frequency table and max_state information is stored in the
devfreq struct directly, not in the devfreq_dev_profile struct. Use
nvidia conftest to conditionally build the governor and choose the
correct data structure for accessing the information.

Kernel build won't complain anything when build the governor, but when
the devfreq driver (e.g. nvgpu) trying to add the devfreq device
with the nvhost_pogdov governor, it will fail to add the devfreq
device since the frequency table information is NULL in the
devfreq_dev_profile and the governor use the wrong information.

Bug 4883576

Change-Id: I885bc4ceac885eea5644416b6eacefbbea523a2b
Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3229870
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
This commit is contained in:
Johnny Liu
2024-10-15 02:29:15 +00:00
committed by Jon Hunter
parent a2c75bcda2
commit d21ee3b3a8

View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2012-2023, NVIDIA CORPORATION. All rights reserved.
* SPDX-FileCopyrightText: Copyright (c) 2012-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
/*
@@ -13,6 +13,8 @@
*
*/
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/clk/tegra.h>
#include <linux/debugfs.h>
@@ -113,15 +115,21 @@ static void get_freq_range(struct devfreq *devfreq,
unsigned long *min_freq,
unsigned long *max_freq)
{
#if defined(NV_DEVFREQ_HAS_FREQ_TABLE)
unsigned long *freq_table = devfreq->freq_table;
unsigned int max_state = devfreq->max_state;
#else
unsigned long *freq_table = devfreq->profile->freq_table;
unsigned int max_state = devfreq->profile->max_state;
#endif
lockdep_assert_held(&devfreq->lock);
if (freq_table[0] < freq_table[devfreq->profile->max_state - 1]) {
if (freq_table[0] < freq_table[max_state - 1]) {
*min_freq = freq_table[0];
*max_freq = freq_table[devfreq->profile->max_state - 1];
*max_freq = freq_table[max_state - 1];
} else {
*min_freq = freq_table[devfreq->profile->max_state - 1];
*min_freq = freq_table[max_state - 1];
*max_freq = freq_table[0];
}
@@ -767,8 +775,13 @@ static int nvhost_pod_init(struct devfreq *df)
if (sysfs_create_file(&df->dev.parent->kobj, &attr->attr))
goto err_create_user_sysfs_entry;
#if defined(NV_DEVFREQ_HAS_FREQ_TABLE)
podgov->freq_count = df->max_state;
podgov->freqlist = df->freq_table;
#else
podgov->freq_count = df->profile->max_state;
podgov->freqlist = df->profile->freq_table;
#endif
if (!podgov->freq_count || !podgov->freqlist)
goto err_get_freqs;