[<prev] [next>] [day] [month] [year] [list]
Message-ID:
<MEYP282MB2697CCD2C2C4CD0F5CB6146FBB08A@MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM>
Date: Thu, 3 Aug 2023 10:58:01 +0800
From: Jinjian Song <songjinjian@...mail.com>
To: netdev@...r.kernel.org
Cc: kuba@...nel.org,
davem@...emloft.net,
johannes@...solutions.net,
ryazanov.s.a@...il.com,
loic.poulain@...aro.org,
ilpo.jarvinen@...ux.intel.com,
ricardo.martinez@...ux.intel.com,
chiranjeevi.rapolu@...ux.intel.com,
haijun.liu@...iatek.com,
edumazet@...gle.com,
pabeni@...hat.com,
chandrashekar.devegowda@...el.com,
m.chetan.kumar@...ux.intel.com,
linuxwwan@...el.com,
linuxwwan_5g@...el.com,
soumya.prakash.mishra@...el.com,
jesse.brandeburg@...el.com,
danielwinkler@...gle.com,
Jinjian Song <jinjian.song@...ocom.com>
Subject: [net-next 5/6] net: wwan: t7xx: Adds sysfs attribute of modem event
From: Jinjian Song <jinjian.song@...ocom.com>
Adds support for t7xx wwan device firmware flashing & coredump collection
using devlink.
Provides sysfs attribute on user space to query the event from modem
about flashing/coredump/reset.
Base on the v5 patch version of follow series:
'net: wwan: t7xx: fw flashing & coredump support'
(https://patchwork.kernel.org/project/netdevbpf/patch/fc8bbb0b66a5ff3a489ea9857d79b374508090ef.1674307425.git.m.chetan.kumar@linux.intel.com/)
Signed-off-by: Jinjian Song <jinjian.song@...ocom.com>
---
drivers/net/wwan/t7xx/t7xx_modem_ops.c | 1 +
drivers/net/wwan/t7xx/t7xx_pci.c | 62 ++++++++++++++++++++++
drivers/net/wwan/t7xx/t7xx_pci.h | 17 ++++++
drivers/net/wwan/t7xx/t7xx_port_devlink.c | 14 +++++
drivers/net/wwan/t7xx/t7xx_port_devlink.h | 1 +
drivers/net/wwan/t7xx/t7xx_state_monitor.c | 7 +++
6 files changed, 102 insertions(+)
diff --git a/drivers/net/wwan/t7xx/t7xx_modem_ops.c b/drivers/net/wwan/t7xx/t7xx_modem_ops.c
index cbd65aa48721..4de75874f1b5 100644
--- a/drivers/net/wwan/t7xx/t7xx_modem_ops.c
+++ b/drivers/net/wwan/t7xx/t7xx_modem_ops.c
@@ -192,6 +192,7 @@ static irqreturn_t t7xx_rgu_isr_thread(int irq, void *data)
{
struct t7xx_pci_dev *t7xx_dev = data;
+ atomic_set(&t7xx_dev->event, T7XX_RESET);
msleep(RGU_RESET_DELAY_MS);
t7xx_reset_device_via_pmic(t7xx_dev);
return IRQ_HANDLED;
diff --git a/drivers/net/wwan/t7xx/t7xx_pci.c b/drivers/net/wwan/t7xx/t7xx_pci.c
index 5e9b954f39ce..f1723c02376e 100644
--- a/drivers/net/wwan/t7xx/t7xx_pci.c
+++ b/drivers/net/wwan/t7xx/t7xx_pci.c
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2021, MediaTek Inc.
* Copyright (c) 2021-2022, Intel Corporation.
+ * Copyright (c) 2023, Fibocom Wireless Inc.
*
* Authors:
* Haijun Liu <haijun.liu@...iatek.com>
@@ -14,6 +15,7 @@
* Chiranjeevi Rapolu <chiranjeevi.rapolu@...el.com>
* Eliot Lee <eliot.lee@...el.com>
* Moises Veleta <moises.veleta@...el.com>
+ * Jinjian Song <jinjian.song@...ocom.com>
*/
#include <linux/atomic.h>
@@ -60,6 +62,57 @@ enum t7xx_pm_state {
MTK_PM_RESUMED,
};
+static ssize_t t7xx_event_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ enum t7xx_event event = T7XX_UNKNOWN;
+ struct pci_dev *pdev;
+ struct t7xx_pci_dev *t7xx_dev;
+
+ pdev = to_pci_dev(dev);
+ t7xx_dev = pci_get_drvdata(pdev);
+ if (!t7xx_dev)
+ return -ENODEV;
+
+ event = atomic_read(&t7xx_dev->event);
+ if (event == T7XX_READY) {
+ return sprintf(buf, "T7XX_MODEM_READY\n");
+ } else if (event == T7XX_RESET) {
+ return sprintf(buf, "T7XX_RESET\n");
+ } else if (event == T7XX_FASTBOOT_DL_MODE) {
+ return sprintf(buf, "T7XX_MODEM_FASTBOOT_DL_MODE\n");
+ } else if (event == T7XX_FLASH_SUCCESS) {
+ return sprintf(buf, "T7XX_FLASHING_SUCCESS\n");
+ } else if (event == T7XX_FLASH_FAILURE) {
+ return sprintf(buf, "T7XX_FLASHING_FAILURE\n");
+ } else if (event == T7XX_FASTBOOT_DUMP_MODE) {
+ return sprintf(buf, "T7XX_MODEM_FASTBOOT_DUMP_MODE\n");
+ } else if (event == T7XX_MRDUMP_READY) {
+ return sprintf(buf, "T7XX_MRDUMP_READY size:%zu\n",
+ t7xx_dev->dl->regions[T7XX_MRDUMP_INDEX].info->dump_size);
+ } else if (event == T7XX_LKDUMP_READY) {
+ return sprintf(buf, "T7XX_LKDUMP_READY size:%zu\n",
+ t7xx_dev->dl->regions[T7XX_LKDUMP_INDEX].info->dump_size);
+ } else if (event == T7XX_MRDUMP_DISCARD) {
+ return sprintf(buf, "T7XX_MRDUMP_DISCARDED\n");
+ } else if (event == T7XX_LKDUMP_DISCARD) {
+ return sprintf(buf, "T7XX_LKDUMP_DISCARDED\n");
+ }
+
+ return sprintf(buf, "T7XX_UNKNOWN\n");
+}
+
+static DEVICE_ATTR_RO(t7xx_event);
+
+static struct attribute *t7xx_event_attr[] = {
+ &dev_attr_t7xx_event.attr,
+ NULL
+};
+
+static const struct attribute_group t7xx_event_attribute_group = {
+ .attrs = t7xx_event_attr,
+};
+
static void t7xx_dev_set_sleep_capability(struct t7xx_pci_dev *t7xx_dev, bool enable)
{
void __iomem *ctrl_reg = IREG_BASE(t7xx_dev) + T7XX_PCIE_MISC_CTRL;
@@ -734,8 +787,17 @@ static int t7xx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
t7xx_pcie_mac_interrupts_dis(t7xx_dev);
+ ret = sysfs_create_group(&t7xx_dev->pdev->dev.kobj,
+ &t7xx_event_attribute_group);
+ if (ret) {
+ t7xx_md_exit(t7xx_dev);
+ goto err_devlink_unregister;
+ }
+
ret = t7xx_interrupt_init(t7xx_dev);
if (ret) {
+ sysfs_remove_group(&t7xx_dev->pdev->dev.kobj,
+ &t7xx_event_attribute_group);
t7xx_md_exit(t7xx_dev);
goto err_devlink_unregister;
}
diff --git a/drivers/net/wwan/t7xx/t7xx_pci.h b/drivers/net/wwan/t7xx/t7xx_pci.h
index 6777581cd540..0d82f9e99243 100644
--- a/drivers/net/wwan/t7xx/t7xx_pci.h
+++ b/drivers/net/wwan/t7xx/t7xx_pci.h
@@ -2,6 +2,7 @@
*
* Copyright (c) 2021, MediaTek Inc.
* Copyright (c) 2021-2022, Intel Corporation.
+ * Copyright (c) 2023, Fibocom Wireless Inc.
*
* Authors:
* Haijun Liu <haijun.liu@...iatek.com>
@@ -12,6 +13,7 @@
* Amir Hanania <amir.hanania@...el.com>
* Chiranjeevi Rapolu <chiranjeevi.rapolu@...el.com>
* Moises Veleta <moises.veleta@...el.com>
+ * Jinjian Song <jinjian.song@...ocom.com>
*/
#ifndef __T7XX_PCI_H__
@@ -84,6 +86,7 @@ struct t7xx_pci_dev {
struct dentry *debugfs_dir;
#endif
struct t7xx_devlink *dl;
+ atomic_t event;
};
enum t7xx_pm_id {
@@ -115,6 +118,20 @@ struct md_pm_entity {
void *entity_param;
};
+enum t7xx_event {
+ T7XX_UNKNOWN,
+ T7XX_READY,
+ T7XX_RESET,
+ T7XX_FASTBOOT_DL_MODE,
+ T7XX_FLASH_SUCCESS,
+ T7XX_FLASH_FAILURE,
+ T7XX_FASTBOOT_DUMP_MODE,
+ T7XX_MRDUMP_READY,
+ T7XX_LKDUMP_READY,
+ T7XX_MRDUMP_DISCARD,
+ T7XX_LKDUMP_DISCARD,
+};
+
void t7xx_pci_disable_sleep(struct t7xx_pci_dev *t7xx_dev);
void t7xx_pci_enable_sleep(struct t7xx_pci_dev *t7xx_dev);
int t7xx_pci_sleep_disable_complete(struct t7xx_pci_dev *t7xx_dev);
diff --git a/drivers/net/wwan/t7xx/t7xx_port_devlink.c b/drivers/net/wwan/t7xx/t7xx_port_devlink.c
index 0949809aa219..5d2c81a29ab5 100644
--- a/drivers/net/wwan/t7xx/t7xx_port_devlink.c
+++ b/drivers/net/wwan/t7xx/t7xx_port_devlink.c
@@ -246,11 +246,14 @@ static int t7xx_devlink_fb_get_core(struct t7xx_port *port)
continue;
} else if (!strcmp(mcmd, T7XX_FB_RESP_MRDUMP_DONE)) {
dev_dbg(port->dev, "%s! size:%zd\n", T7XX_FB_RESP_MRDUMP_DONE, offset_dlen);
+ dl->regions[T7XX_MRDUMP_INDEX].info->dump_size = offset_dlen;
+ atomic_set(&port->t7xx_dev->event, T7XX_MRDUMP_READY);
clear_bit(T7XX_MRDUMP_STATUS, &dl->status);
return 0;
}
dev_err(port->dev, "getcore protocol error (read len %05d, response %s)\n",
clen, mcmd);
+ atomic_set(&port->t7xx_dev->event, T7XX_MRDUMP_DISCARD);
ret = -EPROTO;
goto free_mem;
}
@@ -293,6 +296,7 @@ static int t7xx_devlink_fb_dump_log(struct t7xx_port *port)
if (datasize > lkdump_region->info->size) {
dev_err(port->dev, "lkdump size is more than %dKB. Discarded!\n",
T7XX_LKDUMP_SIZE / 1024);
+ atomic_set(&port->t7xx_dev->event, T7XX_LKDUMP_DISCARD);
ret = -EFBIG;
goto err_clear_bit;
}
@@ -317,6 +321,8 @@ static int t7xx_devlink_fb_dump_log(struct t7xx_port *port)
}
dev_dbg(port->dev, "LKDUMP DONE! size:%zd\n", offset);
+ lkdump_region->info->dump_size = offset;
+ atomic_set(&port->t7xx_dev->event, T7XX_LKDUMP_READY);
clear_bit(T7XX_LKDUMP_STATUS, &dl->status);
return t7xx_devlink_fb_handle_response(port, NULL);
@@ -360,6 +366,10 @@ static int t7xx_devlink_flash_update(struct devlink *devlink,
sprintf(flash_status, "%s %s", "flashing", !ret ? "success" : "failure");
devlink_flash_update_status_notify(devlink, flash_status, params->component, 0, 0);
+ if (ret)
+ atomic_set(&port->t7xx_dev->event, T7XX_FLASH_FAILURE);
+ else
+ atomic_set(&port->t7xx_dev->event, T7XX_FLASH_SUCCESS);
clear_bit(T7XX_FLASH_STATUS, &dl->status);
err_out:
@@ -414,9 +424,13 @@ static int t7xx_devlink_reload_up(struct devlink *devlink,
u32 *actions_performed,
struct netlink_ext_ack *extack)
{
+ struct t7xx_devlink *dl = devlink_priv(devlink);
+
*actions_performed = BIT(action);
switch (action) {
case DEVLINK_RELOAD_ACTION_DRIVER_REINIT:
+ atomic_set(&dl->t7xx_dev->event, T7XX_RESET);
+ return 0;
case DEVLINK_RELOAD_ACTION_FW_ACTIVATE:
return 0;
default:
diff --git a/drivers/net/wwan/t7xx/t7xx_port_devlink.h b/drivers/net/wwan/t7xx/t7xx_port_devlink.h
index e01845b4f2aa..f5442a7f3431 100644
--- a/drivers/net/wwan/t7xx/t7xx_port_devlink.h
+++ b/drivers/net/wwan/t7xx/t7xx_port_devlink.h
@@ -57,6 +57,7 @@ enum t7xx_regions {
struct t7xx_devlink_region_info {
const char *name;
size_t size;
+ size_t dump_size;
};
struct t7xx_devlink_region {
diff --git a/drivers/net/wwan/t7xx/t7xx_state_monitor.c b/drivers/net/wwan/t7xx/t7xx_state_monitor.c
index 500dadaddb30..db76bc6fe660 100644
--- a/drivers/net/wwan/t7xx/t7xx_state_monitor.c
+++ b/drivers/net/wwan/t7xx/t7xx_state_monitor.c
@@ -249,6 +249,12 @@ static void t7xx_lk_stage_event_handling(struct t7xx_fsm_ctl *ctl, unsigned int
port->port_conf->ops->enable_chl(port);
t7xx_cldma_start(md_ctrl);
+
+ if (lk_event == LK_EVENT_CREATE_POST_DL_PORT)
+ atomic_set(&md->t7xx_dev->event, T7XX_FASTBOOT_DL_MODE);
+ else
+ atomic_set(&md->t7xx_dev->event, T7XX_FASTBOOT_DUMP_MODE);
+
break;
default:
@@ -332,6 +338,7 @@ static void fsm_routine_ready(struct t7xx_fsm_ctl *ctl)
ctl->curr_state = FSM_STATE_READY;
t7xx_fsm_broadcast_ready_state(ctl);
+ atomic_set(&md->t7xx_dev->event, T7XX_READY);
t7xx_md_event_notify(md, FSM_READY);
}
--
2.34.1
Powered by blists - more mailing lists