mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 11:37:06 +02:00
soc: qcom: altmode-glink: add ipc logging support
Add ipc logging support so that the essential log information can be stored and looked upon especially when dynamic_debug log filter is not set. This is useful for debugging. Change-Id: I33c8eb1733ab1ecc541abb86f4f351ce9c8ff394 Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
parent
aca05dabce
commit
55675aeb1b
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "altmode-glink: %s: " fmt, __func__
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#include <linux/debugfs.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/ipc_logging.h>
|
||||
#include <linux/ktime.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_platform.h>
|
||||
|
|
@ -27,10 +28,18 @@
|
|||
|
||||
#define MAX_NUM_PORTS 4
|
||||
|
||||
#define NUM_LOG_PAGES 10
|
||||
|
||||
#define IDR_KEY_GEN(svid, ind) (((svid) << 8) | (ind))
|
||||
#define IDR_KEY(client) \
|
||||
IDR_KEY_GEN((client)->data.svid, (client)->port_index)
|
||||
|
||||
#define altmode_dbg(fmt, ...) \
|
||||
do { \
|
||||
ipc_log_string(altmode_ipc_log, fmt, ##__VA_ARGS__); \
|
||||
pr_debug(fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
struct usbc_notify_ind_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u8 payload[NOTIFY_PAYLOAD_SIZE];
|
||||
|
|
@ -125,6 +134,7 @@ static LIST_HEAD(probe_notify_list);
|
|||
static DEFINE_MUTEX(notify_lock);
|
||||
|
||||
static void altmode_send_pan_ack(struct work_struct *work);
|
||||
static void *altmode_ipc_log;
|
||||
|
||||
static struct altmode_dev *to_altmode_device(struct device_node *amdev_node)
|
||||
{
|
||||
|
|
@ -462,7 +472,7 @@ static void altmode_send_pan_en(struct work_struct *work)
|
|||
}
|
||||
|
||||
atomic_set(&amdev->pan_en_sent, 1);
|
||||
pr_debug("Sent PAN EN\n");
|
||||
altmode_dbg("Sent PAN EN\n");
|
||||
}
|
||||
|
||||
static int altmode_send_ack(struct altmode_dev *amdev, u8 port_index)
|
||||
|
|
@ -479,7 +489,7 @@ static int altmode_send_ack(struct altmode_dev *amdev, u8 port_index)
|
|||
return rc;
|
||||
}
|
||||
|
||||
pr_debug("port %u: Sent PAN ACK\n", port_index);
|
||||
altmode_dbg("port %u: Sent PAN ACK\n", port_index);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -488,7 +498,7 @@ static void altmode_state_cb(void *priv, enum pmic_glink_state state)
|
|||
{
|
||||
struct altmode_dev *amdev = priv;
|
||||
|
||||
pr_debug("state: %d\n", state);
|
||||
altmode_dbg("state: %d\n", state);
|
||||
|
||||
switch (state) {
|
||||
case PMIC_GLINK_STATE_DOWN:
|
||||
|
|
@ -527,7 +537,7 @@ static int altmode_callback(void *priv, void *data, size_t len)
|
|||
struct altmode_client *amclient;
|
||||
u8 port_index;
|
||||
|
||||
pr_debug("len: %zu owner: %u type: %u opcode %04x\n", len, hdr->owner,
|
||||
altmode_dbg("len: %zu owner: %u type: %u opcode %04x\n", len, hdr->owner,
|
||||
hdr->type, hdr->opcode);
|
||||
|
||||
/*
|
||||
|
|
@ -544,7 +554,7 @@ static int altmode_callback(void *priv, void *data, size_t len)
|
|||
break;
|
||||
case USBC_NOTIFY_IND:
|
||||
if (len != sizeof(*notify_msg)) {
|
||||
pr_debug("Expected length %u, got: %zu\n",
|
||||
altmode_dbg("Expected length %u, got: %zu\n",
|
||||
sizeof(*notify_msg), len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -558,7 +568,7 @@ static int altmode_callback(void *priv, void *data, size_t len)
|
|||
mutex_unlock(&amdev->client_lock);
|
||||
|
||||
if (!amclient) {
|
||||
pr_debug("No client associated with SVID %#x port %u\n",
|
||||
altmode_dbg("No client associated with SVID %#x port %u\n",
|
||||
svid, port_index);
|
||||
amdev->ack_port_index = port_index;
|
||||
schedule_delayed_work(&amdev->send_pan_ack_work,
|
||||
|
|
@ -566,7 +576,7 @@ static int altmode_callback(void *priv, void *data, size_t len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
pr_debug("Payload: %*ph\n", NOTIFY_PAYLOAD_SIZE,
|
||||
altmode_dbg("Payload: %*ph\n", NOTIFY_PAYLOAD_SIZE,
|
||||
notify_msg->payload);
|
||||
|
||||
cancel_work_sync(&amclient->client_cb_work);
|
||||
|
|
@ -727,6 +737,10 @@ static int altmode_probe(struct platform_device *pdev)
|
|||
goto unreg_pmic_glink;
|
||||
}
|
||||
|
||||
altmode_ipc_log = ipc_log_context_create(NUM_LOG_PAGES, "altmode", 0);
|
||||
if (!altmode_ipc_log)
|
||||
dev_warn(dev, "Error in creating ipc_log_context\n");
|
||||
|
||||
altmode_notify_clients(amdev);
|
||||
|
||||
return 0;
|
||||
|
|
@ -765,6 +779,9 @@ static int altmode_remove(struct platform_device *pdev)
|
|||
list_del(&client->c_node);
|
||||
mutex_unlock(&amdev->client_lock);
|
||||
|
||||
ipc_log_context_destroy(altmode_ipc_log);
|
||||
altmode_ipc_log = NULL;
|
||||
|
||||
rc = pmic_glink_unregister_client(amdev->pgclient);
|
||||
if (rc < 0)
|
||||
dev_err(amdev->dev, "Error in pmic_glink de-registration: %d\n",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user