misc: mods: update from Perforce to 4.20

Change-Id: I7ea45fb5aa393372299648e326e81ecf62913b40
Signed-off-by: Chris Dragan <kdragan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2955034
Reviewed-by: Lael Jones <lajones@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Chris Dragan
2023-08-10 14:54:09 -07:00
committed by mobile promotions
parent 6f90c6d858
commit 1a3e4521c8
7 changed files with 100 additions and 107 deletions

View File

@@ -100,4 +100,13 @@
# define MODS_HAS_FB_SET_SUSPEND 1 # define MODS_HAS_FB_SET_SUSPEND 1
#endif #endif
#ifndef IS_BUILTIN
# define IS_BUILTIN(c) 0
#endif
#if (defined(CONFIG_ARM_FFA_TRANSPORT) && defined(ALLOW_ARM_FFA_TRANSPORT_AS_MODULE)) || \
IS_BUILTIN(CONFIG_ARM_FFA_TRANSPORT)
# define MODS_HAS_ARM_FFA
#endif
#endif /* _MODS_CONFIG_H_ */ #endif /* _MODS_CONFIG_H_ */

View File

@@ -12,10 +12,6 @@
static struct dentry *mods_debugfs_dir; static struct dentry *mods_debugfs_dir;
#ifdef CONFIG_ARCH_TEGRA_19x_SOC
#include "mods_ras.h"
#endif
#if defined(MODS_HAS_TEGRA) && defined(CONFIG_TEGRA_KFUSE) #if defined(MODS_HAS_TEGRA) && defined(CONFIG_TEGRA_KFUSE)
#include <soc/tegra/kfuse.h> #include <soc/tegra/kfuse.h>
#endif #endif
@@ -76,40 +72,20 @@ static int mods_mi_set(void *data, u64 val)
return 0; return 0;
} }
#ifdef CONFIG_ARCH_TEGRA_19x_SOC
static int mods_set_err_sel(void *data, u64 val)
{
set_err_sel(val);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(mods_err_sel_fops, 0, mods_set_err_sel, "%llu\n");
static int mods_set_err_ctrl(void *data, u64 val)
{
set_err_ctrl(val);
return 0;
}
static int mods_get_err_ctrl(void *data, u64 *val)
{
*val = get_err_ctrl();
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(mods_err_ctrl_fops, mods_get_err_ctrl,
mods_set_err_ctrl, "%llu\n");
static int mods_enable_cpu_core_reporting(void *data, u64 val)
{
enable_cpu_core_reporting(val);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(mods_enable_cpu_fops, 0, mods_enable_cpu_core_reporting,
"%llu\n");
#endif
DEFINE_SIMPLE_ATTRIBUTE(mods_mi_fops, mods_mi_get, mods_mi_set, "%llu\n"); DEFINE_SIMPLE_ATTRIBUTE(mods_mi_fops, mods_mi_get, mods_mi_set, "%llu\n");
static int mods_ffa_get(void *data, u64 *val)
{
#if defined(MODS_HAS_ARM_FFA)
*val = 1ULL;
#else
*val = 0ULL;
#endif
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(mods_ffa_fops, mods_ffa_get, NULL, "%llu\n");
void mods_remove_debugfs(void) void mods_remove_debugfs(void)
{ {
debugfs_remove_recursive(mods_debugfs_dir); debugfs_remove_recursive(mods_debugfs_dir);
@@ -118,9 +94,6 @@ void mods_remove_debugfs(void)
int mods_create_debugfs(struct miscdevice *modsdev) int mods_create_debugfs(struct miscdevice *modsdev)
{ {
#ifdef CONFIG_ARCH_TEGRA_19x_SOC
struct dentry *ras_debugfs_entry;
#endif
struct dentry *retval; struct dentry *retval;
int err = 0; int err = 0;
@@ -131,36 +104,6 @@ int mods_create_debugfs(struct miscdevice *modsdev)
goto remove_out; goto remove_out;
} }
#ifdef CONFIG_ARCH_TEGRA_19x_SOC
if (of_find_node_by_name(NULL, "carmel_ras")) {
ras_debugfs_entry = debugfs_create_dir("ras", mods_debugfs_dir);
if (IS_ERR(ras_debugfs_entry)) {
err = -EIO;
goto remove_out;
}
retval = debugfs_create_file("err_sel", 0644,
ras_debugfs_entry, 0, &mods_err_sel_fops);
if (IS_ERR(retval)) {
err = -EIO;
goto remove_out;
}
retval = debugfs_create_file("err_ctrl", 0644,
ras_debugfs_entry, 0, &mods_err_ctrl_fops);
if (IS_ERR(retval)) {
err = -EIO;
goto remove_out;
}
retval = debugfs_create_file("ccplex_config", 0644,
ras_debugfs_entry, 0, &mods_enable_cpu_fops);
if (IS_ERR(retval)) {
err = -EIO;
goto remove_out;
}
}
#endif
retval = debugfs_create_file("debug", 0644, retval = debugfs_create_file("debug", 0644,
mods_debugfs_dir, NULL, &mods_debug_fops); mods_debugfs_dir, NULL, &mods_debug_fops);
if (IS_ERR(retval)) { if (IS_ERR(retval)) {
@@ -175,6 +118,13 @@ int mods_create_debugfs(struct miscdevice *modsdev)
goto remove_out; goto remove_out;
} }
retval = debugfs_create_file("ffa", 0444,
mods_debugfs_dir, NULL, &mods_ffa_fops);
if (IS_ERR(retval)) {
err = -EIO;
goto remove_out;
}
#if defined(MODS_HAS_TEGRA) && defined(CONFIG_TEGRA_KFUSE) #if defined(MODS_HAS_TEGRA) && defined(CONFIG_TEGRA_KFUSE)
retval = debugfs_create_file("kfuse_data", 0444, retval = debugfs_create_file("kfuse_data", 0444,
mods_debugfs_dir, NULL, &mods_kfuse_fops); mods_debugfs_dir, NULL, &mods_kfuse_fops);

View File

@@ -677,7 +677,7 @@ int esc_mods_invoke_optee_ta(struct mods_client *client,
#endif #endif
/* MODS SP call */ /* MODS SP call */
#if defined(CONFIG_ARM_FFA_TRANSPORT) #if defined(MODS_HAS_ARM_FFA)
int esc_mods_arm_ffa_cmd(struct mods_client *client, int esc_mods_arm_ffa_cmd(struct mods_client *client,
struct MODS_FFA_PARAMS *p); struct MODS_FFA_PARAMS *p);
#endif #endif
@@ -722,7 +722,7 @@ int mods_bpmpipc_init(struct mods_client *client,
void mods_bpmpipc_cleanup(void); void mods_bpmpipc_cleanup(void);
#endif #endif
#if defined(CONFIG_ARM_FFA_TRANSPORT) #if defined(MODS_HAS_ARM_FFA)
int mods_ffa_abi_register(void); int mods_ffa_abi_register(void);
void mods_ffa_abi_unregister(void); void mods_ffa_abi_unregister(void);
#endif #endif

View File

@@ -787,8 +787,8 @@ static int mods_allocate_irqs(struct mods_client *client,
flags); flags);
/* Determine if the device supports requested interrupt type */ /* Determine if the device supports requested interrupt type */
if (irq_type == MODS_IRQ_TYPE_MSI) {
#ifdef CONFIG_PCI_MSI #ifdef CONFIG_PCI_MSI
if (irq_type == MODS_IRQ_TYPE_MSI) {
if (pci_find_capability(dev, PCI_CAP_ID_MSI) == 0) { if (pci_find_capability(dev, PCI_CAP_ID_MSI) == 0) {
cl_error("dev %04x:%02x:%02x.%x does not support MSI\n", cl_error("dev %04x:%02x:%02x.%x does not support MSI\n",
pci_domain_nr(dev->bus), pci_domain_nr(dev->bus),
@@ -798,13 +798,11 @@ static int mods_allocate_irqs(struct mods_client *client,
LOG_EXT(); LOG_EXT();
return -ENOENT; return -ENOENT;
} }
#else
cl_error("the kernel does not support MSI\n");
LOG_EXT();
return -EINVAL;
#endif
} else if (irq_type == MODS_IRQ_TYPE_MSIX) { } else if (irq_type == MODS_IRQ_TYPE_MSIX) {
#ifdef CONFIG_PCI_MSI #ifdef MODS_HAS_MSIX_RANGE
int cnt;
#endif
if (pci_find_capability(dev, PCI_CAP_ID_MSIX) == 0) { if (pci_find_capability(dev, PCI_CAP_ID_MSIX) == 0) {
cl_error( cl_error(
"dev %04x:%02x:%02x.%x does not support MSI-X\n", "dev %04x:%02x:%02x.%x does not support MSI-X\n",
@@ -815,12 +813,38 @@ static int mods_allocate_irqs(struct mods_client *client,
LOG_EXT(); LOG_EXT();
return -ENOENT; return -ENOENT;
} }
#else
cl_error("the kernel does not support MSI-X\n"); #ifdef MODS_HAS_MSIX_RANGE
cnt = pci_msix_vec_count(dev);
if (cnt < 0) {
cl_error("MSI-X is not available on dev %04x:%02x:%02x.%x\n",
pci_domain_nr(dev->bus),
dev->bus->number,
PCI_SLOT(dev->devfn),
PCI_FUNC(dev->devfn));
LOG_EXT();
return cnt;
}
if (nvecs > (u32)cnt) {
cl_error("cannot allocate %u MSI-X vectors on dev %04x:%02x:%02x.%x, only %d supported\n",
nvecs,
pci_domain_nr(dev->bus),
dev->bus->number,
PCI_SLOT(dev->devfn),
PCI_FUNC(dev->devfn),
cnt);
LOG_EXT(); LOG_EXT();
return -EINVAL; return -EINVAL;
}
#endif #endif
} }
#else
if (irq_type == MODS_IRQ_TYPE_MSI || irq_type == MODS_IRQ_TYPE_MSIX) {
cl_error("the kernel does not support MSI\n");
LOG_EXT();
return -EINVAL;
}
#endif
/* Enable device on the PCI bus */ /* Enable device on the PCI bus */
err = mods_enable_device(client, dev, &dpriv); err = mods_enable_device(client, dev, &dpriv);
@@ -864,14 +888,14 @@ static int mods_allocate_irqs(struct mods_client *client,
dpriv->nvecs = 1; dpriv->nvecs = 1;
} else if (irq_type == MODS_IRQ_TYPE_MSIX) { } else if (irq_type == MODS_IRQ_TYPE_MSIX) {
struct msix_entry *entries; struct msix_entry *entries;
int i = 0, cnt = 1; int i;
int cnt;
entries = kcalloc(nvecs, sizeof(struct msix_entry), entries = kcalloc(nvecs, sizeof(struct msix_entry),
GFP_KERNEL | __GFP_NORETRY); GFP_KERNEL | __GFP_NORETRY);
if (!entries) { if (!entries) {
cl_error("could not allocate %d MSI-X entries\n", cl_error("could not allocate memory\n");
nvecs);
LOG_EXT(); LOG_EXT();
return -ENOMEM; return -ENOMEM;
} }
@@ -884,17 +908,19 @@ static int mods_allocate_irqs(struct mods_client *client,
cnt = pci_enable_msix_range(dev, entries, nvecs, nvecs); cnt = pci_enable_msix_range(dev, entries, nvecs, nvecs);
if (cnt < 0) { if (cnt < 0) {
/* returns number of interrupts allocated cl_error("failed to allocate %u MSI-X vectors on dev %04x:%02x:%02x.%x\n",
* < 0 indicates a failure. nvecs,
*/ pci_domain_nr(dev->bus),
cl_error( dev->bus->number,
"could not allocate the requested number of MSI-X vectors=%d return=%d!\n", PCI_SLOT(dev->devfn),
nvecs, cnt); PCI_FUNC(dev->devfn));
kfree(entries); kfree(entries);
atomic_dec(&client->num_allocs); atomic_dec(&client->num_allocs);
LOG_EXT(); LOG_EXT();
return cnt; return cnt;
} }
nvecs = (u32)cnt;
#else #else
cnt = pci_enable_msix(dev, entries, nvecs); cnt = pci_enable_msix(dev, entries, nvecs);
@@ -904,9 +930,12 @@ static int mods_allocate_irqs(struct mods_client *client,
* exceeding the number of irqs or MSI-X * exceeding the number of irqs or MSI-X
* vectors available * vectors available
*/ */
cl_error( cl_error("failed to allocate %u MSI-X vectors on dev %04x:%02x:%02x.%x\n",
"could not allocate the requested number of MSI-X vectors=%d return=%d!\n", nvecs,
nvecs, cnt); pci_domain_nr(dev->bus),
dev->bus->number,
PCI_SLOT(dev->devfn),
PCI_FUNC(dev->devfn));
kfree(entries); kfree(entries);
atomic_dec(&client->num_allocs); atomic_dec(&client->num_allocs);
LOG_EXT(); LOG_EXT();

View File

@@ -24,10 +24,6 @@
# include <asm/msr.h> # include <asm/msr.h>
#endif #endif
#ifndef IS_BUILTIN
# define IS_BUILTIN(c) 0
#endif
/*********************************************************************** /***********************************************************************
* mods_krnl_* functions, driver interfaces called by the Linux kernel * * mods_krnl_* functions, driver interfaces called by the Linux kernel *
***********************************************************************/ ***********************************************************************/
@@ -548,7 +544,7 @@ static int __init mods_init_module(void)
#endif #endif
#endif #endif
#if IS_BUILTIN(CONFIG_ARM_FFA_TRANSPORT) #if defined(MODS_HAS_ARM_FFA)
rc = mods_ffa_abi_register(); rc = mods_ffa_abi_register();
if (rc < 0) if (rc < 0)
mods_warning_printk("error on mods_ffa_abi_register returned %d\n", rc); mods_warning_printk("error on mods_ffa_abi_register returned %d\n", rc);
@@ -599,7 +595,7 @@ static void __exit mods_exit_module(void)
mods_shutdown_clock_api(); mods_shutdown_clock_api();
#endif #endif
#if IS_BUILTIN(CONFIG_ARM_FFA_TRANSPORT) #if defined(MODS_HAS_ARM_FFA)
mods_ffa_abi_unregister(); mods_ffa_abi_unregister();
#endif #endif
mods_info_printk("driver unloaded\n"); mods_info_printk("driver unloaded\n");
@@ -2753,11 +2749,14 @@ static long mods_krnl_ioctl(struct file *fp,
#endif #endif
#if IS_BUILTIN(CONFIG_ARM_FFA_TRANSPORT)
case MODS_ESC_FFA_CMD: case MODS_ESC_FFA_CMD:
#if defined(MODS_HAS_ARM_FFA)
MODS_IOCTL(MODS_ESC_FFA_CMD, esc_mods_arm_ffa_cmd, MODS_FFA_PARAMS); MODS_IOCTL(MODS_ESC_FFA_CMD, esc_mods_arm_ffa_cmd, MODS_FFA_PARAMS);
break; #else
cl_debug(DEBUG_IOCTL, "ioctl(MODS_ESC_FFA_CMD is not supported)\n");
err = -EINVAL;
#endif #endif
break;
case MODS_ESC_ACQUIRE_ACCESS_TOKEN: case MODS_ESC_ACQUIRE_ACCESS_TOKEN:
MODS_IOCTL(MODS_ESC_ACQUIRE_ACCESS_TOKEN, MODS_IOCTL(MODS_ESC_ACQUIRE_ACCESS_TOKEN,

View File

@@ -551,6 +551,9 @@ static int restore_cache_one_chunk(struct page *p_page, u8 order)
if (likely(!final_err)) if (likely(!final_err))
final_err = err; final_err = err;
/* Avoid superficial lockups */
cond_resched();
} }
return final_err; return final_err;
@@ -2479,6 +2482,7 @@ static void clear_contiguous_cache(struct mods_client *client,
asm volatile("dc civac, %0" : : "r" (cur) : "memory"); asm volatile("dc civac, %0" : : "r" (cur) : "memory");
/* Avoid superficial lockups */ /* Avoid superficial lockups */
if (!(cur & ((1U << 16) - 1U)))
cond_resched(); cond_resched();
} while (cur += d_size, cur < end); } while (cur += d_size, cur < end);
asm volatile("dsb sy" : : : "memory"); asm volatile("dsb sy" : : : "memory");

View File

@@ -8,7 +8,7 @@
/* Driver version */ /* Driver version */
#define MODS_DRIVER_VERSION_MAJOR 4 #define MODS_DRIVER_VERSION_MAJOR 4
#define MODS_DRIVER_VERSION_MINOR 17 #define MODS_DRIVER_VERSION_MINOR 20
#define MODS_DRIVER_VERSION ((MODS_DRIVER_VERSION_MAJOR << 8) | \ #define MODS_DRIVER_VERSION ((MODS_DRIVER_VERSION_MAJOR << 8) | \
((MODS_DRIVER_VERSION_MINOR / 10) << 4) | \ ((MODS_DRIVER_VERSION_MINOR / 10) << 4) | \
(MODS_DRIVER_VERSION_MINOR % 10)) (MODS_DRIVER_VERSION_MINOR % 10))
@@ -2007,8 +2007,10 @@ struct MODS_BPMP_UPHY_LANE_EOM_SCAN_PARAMS {
#define MODS_ESC_DEVICE_ALLOC_PAGES MODSIO(WR, 45, MODS_DEVICE_ALLOC_PAGES) #define MODS_ESC_DEVICE_ALLOC_PAGES MODSIO(WR, 45, MODS_DEVICE_ALLOC_PAGES)
/* Deprecated */ /* Deprecated */
#define MODS_ESC_DEVICE_NUMA_INFO MODSIO(WR, 46, MODS_DEVICE_NUMA_INFO) #define MODS_ESC_DEVICE_NUMA_INFO MODSIO(WR, 46, MODS_DEVICE_NUMA_INFO)
/* Deprecated */
#define MODS_ESC_TEGRA_DC_CONFIG_POSSIBLE MODSIO(WR, 47, \ #define MODS_ESC_TEGRA_DC_CONFIG_POSSIBLE MODSIO(WR, 47, \
MODS_TEGRA_DC_CONFIG_POSSIBLE) MODS_TEGRA_DC_CONFIG_POSSIBLE)
/* Deprecated */
#define MODS_ESC_TEGRA_DC_SETUP_SD MODSIO(W, 48, MODS_TEGRA_DC_SETUP_SD) #define MODS_ESC_TEGRA_DC_SETUP_SD MODSIO(W, 48, MODS_TEGRA_DC_SETUP_SD)
#define MODS_ESC_DMABUF_GET_PHYSICAL_ADDRESS MODSIO(WR, 49, \ #define MODS_ESC_DMABUF_GET_PHYSICAL_ADDRESS MODSIO(WR, 49, \
MODS_DMABUF_GET_PHYSICAL_ADDRESS) MODS_DMABUF_GET_PHYSICAL_ADDRESS)