Skip to content

Commit

Permalink
qtnfmac: fix core attach error path in pcie backend
Browse files Browse the repository at this point in the history
Report that firmware is up and running only for successful firmware
download. Simplify qtnf_pcie_fw_boot_done: modify error path so that
no need to pass firmware dowload result to this function. Finally,
do not create debugfs entries if firmware download succeeded,
but core attach failed.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  • Loading branch information
Sergey Matyukevich authored and Kalle Valo committed Apr 4, 2019
1 parent 93eeab2 commit ae1946b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 39 deletions.
25 changes: 8 additions & 17 deletions drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,32 +128,23 @@ static int qtnf_dbg_shm_stats(struct seq_file *s, void *data)
return 0;
}

void qtnf_pcie_fw_boot_done(struct qtnf_bus *bus, bool boot_success)
int qtnf_pcie_fw_boot_done(struct qtnf_bus *bus)
{
struct qtnf_pcie_bus_priv *priv = get_bus_priv(bus);
struct pci_dev *pdev = priv->pdev;
int ret;

if (boot_success) {
bus->fw_state = QTNF_FW_STATE_FW_DNLD_DONE;

ret = qtnf_core_attach(bus);
if (ret) {
pr_err("failed to attach core\n");
boot_success = false;
}
}

if (boot_success) {
bus->fw_state = QTNF_FW_STATE_FW_DNLD_DONE;
ret = qtnf_core_attach(bus);
if (ret) {
pr_err("failed to attach core\n");
bus->fw_state = QTNF_FW_STATE_DETACHED;
} else {
qtnf_debugfs_init(bus, DRV_NAME);
qtnf_debugfs_add_entry(bus, "mps", qtnf_dbg_mps_show);
qtnf_debugfs_add_entry(bus, "msi_enabled", qtnf_dbg_msi_show);
qtnf_debugfs_add_entry(bus, "shm_stats", qtnf_dbg_shm_stats);
} else {
bus->fw_state = QTNF_FW_STATE_DETACHED;
}

put_device(&pdev->dev);
return ret;
}

static void qtnf_tune_pcie_mps(struct pci_dev *pdev)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/quantenna/qtnfmac/pcie/pcie_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct qtnf_pcie_bus_priv {

int qtnf_pcie_control_tx(struct qtnf_bus *bus, struct sk_buff *skb);
int qtnf_pcie_alloc_skb_array(struct qtnf_pcie_bus_priv *priv);
void qtnf_pcie_fw_boot_done(struct qtnf_bus *bus, bool boot_success);
int qtnf_pcie_fw_boot_done(struct qtnf_bus *bus);
void qtnf_pcie_init_shm_ipc(struct qtnf_pcie_bus_priv *priv,
struct qtnf_shm_ipc_region __iomem *ipc_tx_reg,
struct qtnf_shm_ipc_region __iomem *ipc_rx_reg,
Expand Down
23 changes: 11 additions & 12 deletions drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,12 +980,11 @@ static void qtnf_pearl_fw_work_handler(struct work_struct *work)
{
struct qtnf_bus *bus = container_of(work, struct qtnf_bus, fw_work);
struct qtnf_pcie_pearl_state *ps = (void *)get_bus_priv(bus);
u32 state = QTN_RC_FW_LOADRDY | QTN_RC_FW_QLINK;
const char *fwname = QTN_PCI_PEARL_FW_NAME;
struct pci_dev *pdev = ps->base.pdev;
const struct firmware *fw;
int ret;
u32 state = QTN_RC_FW_LOADRDY | QTN_RC_FW_QLINK;
const char *fwname = QTN_PCI_PEARL_FW_NAME;
bool fw_boot_success = false;

if (ps->base.flashboot) {
state |= QTN_RC_FW_FLASHBOOT;
Expand Down Expand Up @@ -1031,23 +1030,23 @@ static void qtnf_pearl_fw_work_handler(struct work_struct *work)
goto fw_load_exit;
}

pr_info("firmware is up and running\n");

if (qtnf_poll_state(&ps->bda->bda_ep_state,
QTN_EP_FW_QLINK_DONE, QTN_FW_QLINK_TIMEOUT_MS)) {
pr_err("firmware runtime failure\n");
goto fw_load_exit;
}

fw_boot_success = true;
pr_info("firmware is up and running\n");

fw_load_exit:
qtnf_pcie_fw_boot_done(bus, fw_boot_success);
ret = qtnf_pcie_fw_boot_done(bus);
if (ret)
goto fw_load_exit;

if (fw_boot_success) {
qtnf_debugfs_add_entry(bus, "hdp_stats", qtnf_dbg_hdp_stats);
qtnf_debugfs_add_entry(bus, "irq_stats", qtnf_dbg_irq_stats);
}
qtnf_debugfs_add_entry(bus, "hdp_stats", qtnf_dbg_hdp_stats);
qtnf_debugfs_add_entry(bus, "irq_stats", qtnf_dbg_irq_stats);

fw_load_exit:
put_device(&pdev->dev);
}

static void qtnf_pearl_reclaim_tasklet_fn(unsigned long data)
Expand Down
23 changes: 14 additions & 9 deletions drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,9 @@ static void qtnf_topaz_fw_work_handler(struct work_struct *work)
{
struct qtnf_bus *bus = container_of(work, struct qtnf_bus, fw_work);
struct qtnf_pcie_topaz_state *ts = (void *)get_bus_priv(bus);
int ret;
int bootloader_needed = readl(&ts->bda->bda_flags) & QTN_BDA_XMIT_UBOOT;
struct pci_dev *pdev = ts->base.pdev;
int ret;

qtnf_set_state(&ts->bda->bda_bootstate, QTN_BDA_FW_TARGET_BOOT);

Expand Down Expand Up @@ -1073,19 +1074,23 @@ static void qtnf_topaz_fw_work_handler(struct work_struct *work)
}
}

ret = qtnf_post_init_ep(ts);
if (ret) {
pr_err("FW runtime failure\n");
goto fw_load_exit;
}

pr_info("firmware is up and running\n");

ret = qtnf_post_init_ep(ts);
ret = qtnf_pcie_fw_boot_done(bus);
if (ret)
pr_err("FW runtime failure\n");
goto fw_load_exit;

fw_load_exit:
qtnf_pcie_fw_boot_done(bus, ret ? false : true);
qtnf_debugfs_add_entry(bus, "pkt_stats", qtnf_dbg_pkt_stats);
qtnf_debugfs_add_entry(bus, "irq_stats", qtnf_dbg_irq_stats);

if (ret == 0) {
qtnf_debugfs_add_entry(bus, "pkt_stats", qtnf_dbg_pkt_stats);
qtnf_debugfs_add_entry(bus, "irq_stats", qtnf_dbg_irq_stats);
}
fw_load_exit:
put_device(&pdev->dev);
}

static void qtnf_reclaim_tasklet_fn(unsigned long data)
Expand Down

0 comments on commit ae1946b

Please sign in to comment.