Commit 8602e624 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by Kalle Valo

brcmfmac: pass bus to the __brcmf_err() in pcie.c

This enables dev_err() usage (instead of pr_err()) in the __brcmf_err().
It makes error messages more meaningful and is important for debugging
errors/bugs on systems with multiple brcmfmac supported devices.

All bus files should follow & get updated similarly (soon).
Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 5cc898fb
...@@ -52,6 +52,7 @@ void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...); ...@@ -52,6 +52,7 @@ void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...);
/* Macro for error messages. When debugging / tracing the driver all error /* Macro for error messages. When debugging / tracing the driver all error
* messages are important to us. * messages are important to us.
*/ */
#ifndef brcmf_err
#define brcmf_err(fmt, ...) \ #define brcmf_err(fmt, ...) \
do { \ do { \
if (IS_ENABLED(CONFIG_BRCMDBG) || \ if (IS_ENABLED(CONFIG_BRCMDBG) || \
...@@ -59,6 +60,7 @@ void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...); ...@@ -59,6 +60,7 @@ void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...);
net_ratelimit()) \ net_ratelimit()) \
__brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\ __brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
} while (0) } while (0)
#endif
#if defined(DEBUG) || defined(CONFIG_BRCM_TRACING) #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
......
...@@ -30,6 +30,15 @@ ...@@ -30,6 +30,15 @@
#include <brcmu_wifi.h> #include <brcmu_wifi.h>
#include <brcm_hw_ids.h> #include <brcm_hw_ids.h>
/* Custom brcmf_err() that takes bus arg and passes it further */
#define brcmf_err(bus, fmt, ...) \
do { \
if (IS_ENABLED(CONFIG_BRCMDBG) || \
IS_ENABLED(CONFIG_BRCM_TRACING) || \
net_ratelimit()) \
__brcmf_err(bus, __func__, fmt, ##__VA_ARGS__); \
} while (0)
#include "debug.h" #include "debug.h"
#include "bus.h" #include "bus.h"
#include "commonring.h" #include "commonring.h"
...@@ -531,6 +540,7 @@ static void ...@@ -531,6 +540,7 @@ static void
brcmf_pcie_select_core(struct brcmf_pciedev_info *devinfo, u16 coreid) brcmf_pcie_select_core(struct brcmf_pciedev_info *devinfo, u16 coreid)
{ {
const struct pci_dev *pdev = devinfo->pdev; const struct pci_dev *pdev = devinfo->pdev;
struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
struct brcmf_core *core; struct brcmf_core *core;
u32 bar0_win; u32 bar0_win;
...@@ -548,7 +558,7 @@ brcmf_pcie_select_core(struct brcmf_pciedev_info *devinfo, u16 coreid) ...@@ -548,7 +558,7 @@ brcmf_pcie_select_core(struct brcmf_pciedev_info *devinfo, u16 coreid)
} }
} }
} else { } else {
brcmf_err("Unsupported core selected %x\n", coreid); brcmf_err(bus, "Unsupported core selected %x\n", coreid);
} }
} }
...@@ -848,9 +858,8 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg) ...@@ -848,9 +858,8 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg)
static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo) static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo)
{ {
struct pci_dev *pdev; struct pci_dev *pdev = devinfo->pdev;
struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
pdev = devinfo->pdev;
brcmf_pcie_intr_disable(devinfo); brcmf_pcie_intr_disable(devinfo);
...@@ -861,7 +870,7 @@ static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo) ...@@ -861,7 +870,7 @@ static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo)
brcmf_pcie_isr_thread, IRQF_SHARED, brcmf_pcie_isr_thread, IRQF_SHARED,
"brcmf_pcie_intr", devinfo)) { "brcmf_pcie_intr", devinfo)) {
pci_disable_msi(pdev); pci_disable_msi(pdev);
brcmf_err("Failed to request IRQ %d\n", pdev->irq); brcmf_err(bus, "Failed to request IRQ %d\n", pdev->irq);
return -EIO; return -EIO;
} }
devinfo->irq_allocated = true; devinfo->irq_allocated = true;
...@@ -871,15 +880,14 @@ static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo) ...@@ -871,15 +880,14 @@ static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo)
static void brcmf_pcie_release_irq(struct brcmf_pciedev_info *devinfo) static void brcmf_pcie_release_irq(struct brcmf_pciedev_info *devinfo)
{ {
struct pci_dev *pdev; struct pci_dev *pdev = devinfo->pdev;
struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
u32 status; u32 status;
u32 count; u32 count;
if (!devinfo->irq_allocated) if (!devinfo->irq_allocated)
return; return;
pdev = devinfo->pdev;
brcmf_pcie_intr_disable(devinfo); brcmf_pcie_intr_disable(devinfo);
free_irq(pdev->irq, devinfo); free_irq(pdev->irq, devinfo);
pci_disable_msi(pdev); pci_disable_msi(pdev);
...@@ -891,7 +899,7 @@ static void brcmf_pcie_release_irq(struct brcmf_pciedev_info *devinfo) ...@@ -891,7 +899,7 @@ static void brcmf_pcie_release_irq(struct brcmf_pciedev_info *devinfo)
count++; count++;
} }
if (devinfo->in_irq) if (devinfo->in_irq)
brcmf_err("Still in IRQ (processing) !!!\n"); brcmf_err(bus, "Still in IRQ (processing) !!!\n");
status = brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT); status = brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT);
brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT, status); brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT, status);
...@@ -1102,6 +1110,7 @@ static void brcmf_pcie_release_ringbuffers(struct brcmf_pciedev_info *devinfo) ...@@ -1102,6 +1110,7 @@ static void brcmf_pcie_release_ringbuffers(struct brcmf_pciedev_info *devinfo)
static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo) static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo)
{ {
struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
struct brcmf_pcie_ringbuf *ring; struct brcmf_pcie_ringbuf *ring;
struct brcmf_pcie_ringbuf *rings; struct brcmf_pcie_ringbuf *rings;
u32 d2h_w_idx_ptr; u32 d2h_w_idx_ptr;
...@@ -1254,7 +1263,7 @@ static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo) ...@@ -1254,7 +1263,7 @@ static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo)
return 0; return 0;
fail: fail:
brcmf_err("Allocating ring buffers failed\n"); brcmf_err(bus, "Allocating ring buffers failed\n");
brcmf_pcie_release_ringbuffers(devinfo); brcmf_pcie_release_ringbuffers(devinfo);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1277,6 +1286,7 @@ brcmf_pcie_release_scratchbuffers(struct brcmf_pciedev_info *devinfo) ...@@ -1277,6 +1286,7 @@ brcmf_pcie_release_scratchbuffers(struct brcmf_pciedev_info *devinfo)
static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo)
{ {
struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
u64 address; u64 address;
u32 addr; u32 addr;
...@@ -1316,7 +1326,7 @@ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) ...@@ -1316,7 +1326,7 @@ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo)
return 0; return 0;
fail: fail:
brcmf_err("Allocating scratch buffers failed\n"); brcmf_err(bus, "Allocating scratch buffers failed\n");
brcmf_pcie_release_scratchbuffers(devinfo); brcmf_pcie_release_scratchbuffers(devinfo);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1437,6 +1447,7 @@ static int ...@@ -1437,6 +1447,7 @@ static int
brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo,
u32 sharedram_addr) u32 sharedram_addr)
{ {
struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
struct brcmf_pcie_shared_info *shared; struct brcmf_pcie_shared_info *shared;
u32 addr; u32 addr;
...@@ -1448,7 +1459,8 @@ brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, ...@@ -1448,7 +1459,8 @@ brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo,
brcmf_dbg(PCIE, "PCIe protocol version %d\n", shared->version); brcmf_dbg(PCIE, "PCIe protocol version %d\n", shared->version);
if ((shared->version > BRCMF_PCIE_MAX_SHARED_VERSION) || if ((shared->version > BRCMF_PCIE_MAX_SHARED_VERSION) ||
(shared->version < BRCMF_PCIE_MIN_SHARED_VERSION)) { (shared->version < BRCMF_PCIE_MIN_SHARED_VERSION)) {
brcmf_err("Unsupported PCIE version %d\n", shared->version); brcmf_err(bus, "Unsupported PCIE version %d\n",
shared->version);
return -EINVAL; return -EINVAL;
} }
...@@ -1490,6 +1502,7 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo, ...@@ -1490,6 +1502,7 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
const struct firmware *fw, void *nvram, const struct firmware *fw, void *nvram,
u32 nvram_len) u32 nvram_len)
{ {
struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
u32 sharedram_addr; u32 sharedram_addr;
u32 sharedram_addr_written; u32 sharedram_addr_written;
u32 loop_counter; u32 loop_counter;
...@@ -1544,7 +1557,7 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo, ...@@ -1544,7 +1557,7 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
loop_counter--; loop_counter--;
} }
if (sharedram_addr == sharedram_addr_written) { if (sharedram_addr == sharedram_addr_written) {
brcmf_err("FW failed to initialize\n"); brcmf_err(bus, "FW failed to initialize\n");
return -ENODEV; return -ENODEV;
} }
brcmf_dbg(PCIE, "Shared RAM addr: 0x%08x\n", sharedram_addr); brcmf_dbg(PCIE, "Shared RAM addr: 0x%08x\n", sharedram_addr);
...@@ -1555,16 +1568,15 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo, ...@@ -1555,16 +1568,15 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo) static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
{ {
struct pci_dev *pdev; struct pci_dev *pdev = devinfo->pdev;
struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
int err; int err;
phys_addr_t bar0_addr, bar1_addr; phys_addr_t bar0_addr, bar1_addr;
ulong bar1_size; ulong bar1_size;
pdev = devinfo->pdev;
err = pci_enable_device(pdev); err = pci_enable_device(pdev);
if (err) { if (err) {
brcmf_err("pci_enable_device failed err=%d\n", err); brcmf_err(bus, "pci_enable_device failed err=%d\n", err);
return err; return err;
} }
...@@ -1577,7 +1589,7 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo) ...@@ -1577,7 +1589,7 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
/* read Bar-1 mapped memory range */ /* read Bar-1 mapped memory range */
bar1_size = pci_resource_len(pdev, 2); bar1_size = pci_resource_len(pdev, 2);
if ((bar1_size == 0) || (bar1_addr == 0)) { if ((bar1_size == 0) || (bar1_addr == 0)) {
brcmf_err("BAR1 Not enabled, device size=%ld, addr=%#016llx\n", brcmf_err(bus, "BAR1 Not enabled, device size=%ld, addr=%#016llx\n",
bar1_size, (unsigned long long)bar1_addr); bar1_size, (unsigned long long)bar1_addr);
return -EINVAL; return -EINVAL;
} }
...@@ -1586,7 +1598,7 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo) ...@@ -1586,7 +1598,7 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
devinfo->tcm = ioremap_nocache(bar1_addr, bar1_size); devinfo->tcm = ioremap_nocache(bar1_addr, bar1_size);
if (!devinfo->regs || !devinfo->tcm) { if (!devinfo->regs || !devinfo->tcm) {
brcmf_err("ioremap() failed (%p,%p)\n", devinfo->regs, brcmf_err(bus, "ioremap() failed (%p,%p)\n", devinfo->regs,
devinfo->tcm); devinfo->tcm);
return -EINVAL; return -EINVAL;
} }
...@@ -1873,7 +1885,7 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1873,7 +1885,7 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
kfree(bus->msgbuf); kfree(bus->msgbuf);
kfree(bus); kfree(bus);
fail: fail:
brcmf_err("failed %x:%x\n", pdev->vendor, pdev->device); brcmf_err(NULL, "failed %x:%x\n", pdev->vendor, pdev->device);
brcmf_pcie_release_resource(devinfo); brcmf_pcie_release_resource(devinfo);
if (devinfo->ci) if (devinfo->ci)
brcmf_chip_detach(devinfo->ci); brcmf_chip_detach(devinfo->ci);
...@@ -1947,7 +1959,7 @@ static int brcmf_pcie_pm_enter_D3(struct device *dev) ...@@ -1947,7 +1959,7 @@ static int brcmf_pcie_pm_enter_D3(struct device *dev)
wait_event_timeout(devinfo->mbdata_resp_wait, devinfo->mbdata_completed, wait_event_timeout(devinfo->mbdata_resp_wait, devinfo->mbdata_completed,
BRCMF_PCIE_MBDATA_TIMEOUT); BRCMF_PCIE_MBDATA_TIMEOUT);
if (!devinfo->mbdata_completed) { if (!devinfo->mbdata_completed) {
brcmf_err("Timeout on response for entering D3 substate\n"); brcmf_err(bus, "Timeout on response for entering D3 substate\n");
brcmf_bus_change_state(bus, BRCMF_BUS_UP); brcmf_bus_change_state(bus, BRCMF_BUS_UP);
return -EIO; return -EIO;
} }
...@@ -1993,7 +2005,7 @@ static int brcmf_pcie_pm_leave_D3(struct device *dev) ...@@ -1993,7 +2005,7 @@ static int brcmf_pcie_pm_leave_D3(struct device *dev)
err = brcmf_pcie_probe(pdev, NULL); err = brcmf_pcie_probe(pdev, NULL);
if (err) if (err)
brcmf_err("probe after resume failed, err=%d\n", err); brcmf_err(bus, "probe after resume failed, err=%d\n", err);
return err; return err;
} }
...@@ -2064,7 +2076,8 @@ void brcmf_pcie_register(void) ...@@ -2064,7 +2076,8 @@ void brcmf_pcie_register(void)
brcmf_dbg(PCIE, "Enter\n"); brcmf_dbg(PCIE, "Enter\n");
err = pci_register_driver(&brcmf_pciedrvr); err = pci_register_driver(&brcmf_pciedrvr);
if (err) if (err)
brcmf_err("PCIE driver registration failed, err=%d\n", err); brcmf_err(NULL, "PCIE driver registration failed, err=%d\n",
err);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment