cnss2: Use CONFIG_IPC_LOGGING to protect MSM IPC logging APIs

This makes sure CNSS2 driver is able to work in non-MSM platforms
which do not have IPC logging feature.

Change-Id: I4c8fe3eb45e38fd106f47c28f0e4da82b0bdf76f
Signed-off-by: Yue Ma <yuem@codeaurora.org>
This commit is contained in:
Yue Ma 2020-12-04 14:06:03 -08:00
commit a7ae359deb
3 changed files with 67 additions and 21 deletions

View file

@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */
#include <linux/err.h>
#include <linux/seq_file.h>
@ -11,8 +11,10 @@
#define MMIO_REG_ACCESS_MEM_TYPE 0xFF
#if IS_ENABLED(CONFIG_IPC_LOGGING)
void *cnss_ipc_log_context;
void *cnss_ipc_log_long_context;
#endif
static int cnss_pin_connect_show(struct seq_file *s, void *data)
{
@ -872,7 +874,8 @@ void cnss_debugfs_destroy(struct cnss_plat_data *plat_priv)
}
#endif
int cnss_debug_init(void)
#if IS_ENABLED(CONFIG_IPC_LOGGING)
static int cnss_ipc_logging_init(void)
{
cnss_ipc_log_context = ipc_log_context_create(CNSS_IPC_LOG_PAGES,
"cnss", 0);
@ -892,7 +895,7 @@ int cnss_debug_init(void)
return 0;
}
void cnss_debug_deinit(void)
static void cnss_ipc_logging_deinit(void)
{
if (cnss_ipc_log_long_context) {
ipc_log_context_destroy(cnss_ipc_log_long_context);
@ -904,3 +907,17 @@ void cnss_debug_deinit(void)
cnss_ipc_log_context = NULL;
}
}
#else
static int cnss_ipc_logging_init(void) { return 0; }
static void cnss_ipc_logging_deinit(void) {}
#endif
int cnss_debug_init(void)
{
return cnss_ipc_logging_init();
}
void cnss_debug_deinit(void)
{
cnss_ipc_logging_deinit();
}

View file

@ -1,12 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */
#ifndef _CNSS_DEBUG_H
#define _CNSS_DEBUG_H
#if IS_ENABLED(CONFIG_IPC_LOGGING)
#include <linux/ipc_logging.h>
#endif
#include <linux/printk.h>
#if IS_ENABLED(CONFIG_IPC_LOGGING)
#define CNSS_IPC_LOG_PAGES 32
extern void *cnss_ipc_log_context;
@ -17,6 +20,10 @@ extern void *cnss_ipc_log_long_context;
#define cnss_ipc_log_long_string(_x...) \
ipc_log_string(cnss_ipc_log_long_context, _x)
#else
#define cnss_ipc_log_string(_x...)
#define cnss_ipc_log_long_string(_x...)
#endif
#define cnss_pr_err(_fmt, ...) do { \
printk("%scnss: " _fmt, KERN_ERR, ##__VA_ARGS__); \

View file

@ -4914,6 +4914,42 @@ static int cnss_mhi_bw_scale(struct mhi_controller *mhi_ctrl,
return 0;
}
#if IS_ENABLED(CONFIG_IPC_LOGGING)
static int cnss_pci_mhi_ipc_logging_init(struct cnss_pci_data *pci_priv)
{
struct mhi_controller *mhi_ctrl = pci_priv->mhi_ctrl;
mhi_ctrl->log_buf = ipc_log_context_create(CNSS_IPC_LOG_PAGES,
"cnss-mhi", 0);
if (!mhi_ctrl->log_buf)
cnss_pr_err("Unable to create CNSS MHI IPC log context\n");
mhi_ctrl->cntrl_log_buf = ipc_log_context_create(CNSS_IPC_LOG_PAGES,
"cnss-mhi-cntrl", 0);
if (!mhi_ctrl->cntrl_log_buf)
cnss_pr_err("Unable to create CNSS MHICNTRL IPC log context\n");
return 0;
}
static void cnss_pci_mhi_ipc_logging_deinit(struct cnss_pci_data *pci_priv)
{
struct mhi_controller *mhi_ctrl = pci_priv->mhi_ctrl;
if (mhi_ctrl->log_buf)
ipc_log_context_destroy(mhi_ctrl->log_buf);
if (mhi_ctrl->cntrl_log_buf)
ipc_log_context_destroy(mhi_ctrl->cntrl_log_buf);
}
#else
static int cnss_pci_mhi_ipc_logging_init(struct cnss_pci_data *pci_priv)
{
return 0;
}
static void cnss_pci_mhi_ipc_logging_deinit(struct cnss_pci_data *pci_priv) {}
#endif
static int cnss_pci_register_mhi(struct cnss_pci_data *pci_priv)
{
int ret = 0;
@ -4978,15 +5014,7 @@ static int cnss_pci_register_mhi(struct cnss_pci_data *pci_priv)
mhi_ctrl->fbc_download = true;
mhi_ctrl->rddm_supported = true;
mhi_ctrl->log_buf = ipc_log_context_create(CNSS_IPC_LOG_PAGES,
"cnss-mhi", 0);
if (!mhi_ctrl->log_buf)
cnss_pr_err("Unable to create CNSS MHI IPC log context\n");
mhi_ctrl->cntrl_log_buf = ipc_log_context_create(CNSS_IPC_LOG_PAGES,
"cnss-mhi-cntrl", 0);
if (!mhi_ctrl->cntrl_log_buf)
cnss_pr_err("Unable to create CNSS MHICNTRL IPC log context\n");
cnss_pci_mhi_ipc_logging_init(pci_priv);
ret = of_register_mhi_controller(mhi_ctrl);
if (ret) {
@ -5003,10 +5031,7 @@ static int cnss_pci_register_mhi(struct cnss_pci_data *pci_priv)
unreg_mhi:
mhi_unregister_mhi_controller(mhi_ctrl);
destroy_ipc:
if (mhi_ctrl->log_buf)
ipc_log_context_destroy(mhi_ctrl->log_buf);
if (mhi_ctrl->cntrl_log_buf)
ipc_log_context_destroy(mhi_ctrl->cntrl_log_buf);
cnss_pci_mhi_ipc_logging_deinit(pci_priv);
kfree(mhi_ctrl->irq);
free_mhi_ctrl:
mhi_free_controller(mhi_ctrl);
@ -5022,10 +5047,7 @@ static void cnss_pci_unregister_mhi(struct cnss_pci_data *pci_priv)
return;
mhi_unregister_mhi_controller(mhi_ctrl);
if (mhi_ctrl->log_buf)
ipc_log_context_destroy(mhi_ctrl->log_buf);
if (mhi_ctrl->cntrl_log_buf)
ipc_log_context_destroy(mhi_ctrl->cntrl_log_buf);
cnss_pci_mhi_ipc_logging_deinit(pci_priv);
kfree(mhi_ctrl->irq);
mhi_free_controller(mhi_ctrl);
}