mirror of
git://nv-tegra.nvidia.com/linux-hwpm.git
synced 2025-12-22 17:30:40 +03:00
tegra: hwpm: fix kernel crash on TOT
Currently on TOT, stream buffer map functions results in kernel crash. The kernel crash is an effect of incorrect conditions in the mapping function. Fix the code logic to use correct kernel version conditions to use appropriate DMA buffer structures. Bug 3893741 Change-Id: I3888ec01fdb2025f6d9c3a22296ca9d1abbcadb0 Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> (cherry picked from commit 5a3476cfb6574eb5ace29801a4f428ce9d694ce9) Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2853211 Reviewed-by: Seema Khowala <seemaj@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
d782c9ee5b
commit
dd4f96e5c9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <os/linux/driver.h>
|
||||
|
||||
#if defined(CONFIG_TEGRA_HWPM_OOT)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||
#include <linux/module.h>
|
||||
MODULE_IMPORT_NS(DMA_BUF);
|
||||
#endif
|
||||
@@ -92,7 +92,7 @@ static int tegra_hwpm_dma_map_mem_bytes_buffer(struct tegra_soc_hwpm *hwpm,
|
||||
struct tegra_soc_hwpm_alloc_pma_stream *alloc_pma_stream)
|
||||
{
|
||||
struct tegra_hwpm_os_linux *hwpm_linux = NULL;
|
||||
#if defined(CONFIG_TEGRA_HWPM_OOT)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||
int err = 0;
|
||||
#endif
|
||||
|
||||
@@ -129,12 +129,11 @@ static int tegra_hwpm_dma_map_mem_bytes_buffer(struct tegra_soc_hwpm *hwpm,
|
||||
hwpm->mem_mgmt->mem_bytes_buf_va =
|
||||
sg_dma_address(hwpm->mem_mgmt->mem_bytes_sgt->sgl);
|
||||
|
||||
#if defined(CONFIG_TEGRA_HWPM_OOT)
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 10, 0)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||
/*
|
||||
* Kernel version beyond 5.10 introduces
|
||||
* dma_buf_map structure (called iosys_map in later versions).
|
||||
* The kernel Virtual address generated from dma_buf_vmap API
|
||||
* Kernel version 5.15 and above introduces dma_buf_map structure
|
||||
* (called iosys_map in versions later than 5.18).
|
||||
* The kernel virtual address generated from dma_buf_vmap API
|
||||
* is stored in mem_bytes_map, which is a dma_buf_map structure
|
||||
*/
|
||||
err = dma_buf_vmap(hwpm->mem_mgmt->mem_bytes_dma_buf,
|
||||
@@ -144,6 +143,7 @@ static int tegra_hwpm_dma_map_mem_bytes_buffer(struct tegra_soc_hwpm *hwpm,
|
||||
"Unable to map mem_bytes buffer into kernel VA space");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
hwpm->mem_mgmt->mem_bytes_kernel = hwpm->mem_mgmt->mem_bytes_map.vaddr;
|
||||
#else
|
||||
hwpm->mem_mgmt->mem_bytes_kernel =
|
||||
@@ -153,7 +153,6 @@ static int tegra_hwpm_dma_map_mem_bytes_buffer(struct tegra_soc_hwpm *hwpm,
|
||||
"Unable to map mem_bytes buffer into kernel VA space");
|
||||
return -ENOMEM;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
memset(hwpm->mem_mgmt->mem_bytes_kernel, 0, 32);
|
||||
@@ -188,14 +187,12 @@ static int tegra_hwpm_reset_stream_buf(struct tegra_soc_hwpm *hwpm)
|
||||
hwpm->mem_mgmt->stream_dma_buf = NULL;
|
||||
|
||||
if (hwpm->mem_mgmt->mem_bytes_kernel) {
|
||||
#if defined(CONFIG_TEGRA_HWPM_OOT)
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 10, 0)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||
dma_buf_vunmap(hwpm->mem_mgmt->mem_bytes_dma_buf,
|
||||
&hwpm->mem_mgmt->mem_bytes_map);
|
||||
#else
|
||||
dma_buf_vunmap(hwpm->mem_mgmt->mem_bytes_dma_buf,
|
||||
hwpm->mem_mgmt->mem_bytes_kernel);
|
||||
#endif
|
||||
#endif
|
||||
hwpm->mem_mgmt->mem_bytes_kernel = NULL;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -15,11 +15,11 @@
|
||||
#define TEGRA_HWPM_OS_LINUX_MEM_MGMT_UTILS_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#if defined(CONFIG_TEGRA_HWPM_OOT)
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
|
||||
#include <linux/iosys-map.h>
|
||||
#else
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||
#include <linux/dma-buf-map.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -46,10 +46,10 @@ struct tegra_hwpm_mem_mgmt {
|
||||
struct dma_buf *mem_bytes_dma_buf;
|
||||
struct dma_buf_attachment *mem_bytes_attach;
|
||||
void *mem_bytes_kernel;
|
||||
#if defined(CONFIG_TEGRA_HWPM_OOT)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
|
||||
struct iosys_map mem_bytes_map;
|
||||
#else
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||
struct dma_buf_map mem_bytes_map;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user