mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: Use conftest to handle kernel version differences
Instead of relying on kernel version to determine if the 'dev' member of the 'struct class' is const, add a compile time test to the conftest.sh script to determine this at compile time for the kernel being used. This is beneficial for working with 3rd party Linux kernels that may have back-ported upstream changes into their kernel and so the kernel version checks do not work. Bug 4119327 Change-Id: I5b3c886fa4bac7560c2c26534bed9f495d57195b Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2986637 (cherry picked from commit f9d48796dc2a292bb02a90677774a5568f9f1651) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2990696 Reviewed-by: Ankur Kishore <ankkishore@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
0fa5fc1583
commit
f2afbafcfd
@@ -16,6 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NVIDIA_CONFTEST)
|
||||||
|
#include <nvidia/conftest.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <linux/file.h>
|
#include <linux/file.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
||||||
@@ -222,10 +226,10 @@ static char *nvgpu_devnode(const char *cdev_name)
|
|||||||
return kasprintf(GFP_KERNEL, "nvhost-%s-gpu", cdev_name);
|
return kasprintf(GFP_KERNEL, "nvhost-%s-gpu", cdev_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
|
#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) /* Linux v6.2 */
|
||||||
static char *nvgpu_pci_devnode(struct device *dev, umode_t *mode)
|
|
||||||
#else
|
|
||||||
static char *nvgpu_pci_devnode(const struct device *dev, umode_t *mode)
|
static char *nvgpu_pci_devnode(const struct device *dev, umode_t *mode)
|
||||||
|
#else
|
||||||
|
static char *nvgpu_pci_devnode(struct device *dev, umode_t *mode)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Special case to maintain legacy names */
|
/* Special case to maintain legacy names */
|
||||||
@@ -238,39 +242,39 @@ static char *nvgpu_pci_devnode(const struct device *dev, umode_t *mode)
|
|||||||
dev_name(dev->parent), dev_name(dev));
|
dev_name(dev->parent), dev_name(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
|
#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) /* Linux v6.2 */
|
||||||
static char *nvgpu_devnode_v2(struct device *dev, umode_t *mode)
|
|
||||||
#else
|
|
||||||
static char *nvgpu_devnode_v2(const struct device *dev, umode_t *mode)
|
static char *nvgpu_devnode_v2(const struct device *dev, umode_t *mode)
|
||||||
|
#else
|
||||||
|
static char *nvgpu_devnode_v2(struct device *dev, umode_t *mode)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return kasprintf(GFP_KERNEL, "nvgpu/igpu0/%s", dev_name(dev));
|
return kasprintf(GFP_KERNEL, "nvgpu/igpu0/%s", dev_name(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
|
#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) /* Linux v6.2 */
|
||||||
static char *nvgpu_pci_devnode_v2(struct device *dev, umode_t *mode)
|
|
||||||
#else
|
|
||||||
static char *nvgpu_pci_devnode_v2(const struct device *dev, umode_t *mode)
|
static char *nvgpu_pci_devnode_v2(const struct device *dev, umode_t *mode)
|
||||||
|
#else
|
||||||
|
static char *nvgpu_pci_devnode_v2(struct device *dev, umode_t *mode)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return kasprintf(GFP_KERNEL, "nvgpu/dgpu-%s/%s",
|
return kasprintf(GFP_KERNEL, "nvgpu/dgpu-%s/%s",
|
||||||
dev_name(dev->parent), dev_name(dev));
|
dev_name(dev->parent), dev_name(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
|
#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) /* Linux v6.2 */
|
||||||
static char *nvgpu_pci_igpu_devnode_v2(struct device *dev, umode_t *mode)
|
|
||||||
#else
|
|
||||||
static char *nvgpu_pci_igpu_devnode_v2(const struct device *dev, umode_t *mode)
|
static char *nvgpu_pci_igpu_devnode_v2(const struct device *dev, umode_t *mode)
|
||||||
|
#else
|
||||||
|
static char *nvgpu_pci_igpu_devnode_v2(struct device *dev, umode_t *mode)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return kasprintf(GFP_KERNEL, "nvgpu/igpu-%s/%s",
|
return kasprintf(GFP_KERNEL, "nvgpu/igpu-%s/%s",
|
||||||
dev_name(dev->parent), dev_name(dev));
|
dev_name(dev->parent), dev_name(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
|
#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) /* Linux v6.2 */
|
||||||
static char *nvgpu_mig_fgpu_devnode(struct device *dev, umode_t *mode)
|
|
||||||
#else
|
|
||||||
static char *nvgpu_mig_fgpu_devnode(const struct device *dev, umode_t *mode)
|
static char *nvgpu_mig_fgpu_devnode(const struct device *dev, umode_t *mode)
|
||||||
|
#else
|
||||||
|
static char *nvgpu_mig_fgpu_devnode(struct device *dev, umode_t *mode)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
struct nvgpu_cdev_class_priv_data *priv_data;
|
struct nvgpu_cdev_class_priv_data *priv_data;
|
||||||
|
|||||||
Reference in New Issue
Block a user