Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions drivers/net/wireless/apple/centauri/centauri_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct centauri_ipc {
struct list_head buffers;
struct pci_dev *function[3];
void __iomem *bar[3];
bool enabled[3];
struct cen_context control, alpha;
struct cen_buffer *secondary, *window, *cchi_rx, *cchi_tx, *debug_rx;
struct cen_buffer *alpha_log;
Expand Down Expand Up @@ -426,7 +427,7 @@ static int enumerate_functions(struct centauri *c)
{
struct centauri_ipc *ipc = c->ipc;
u16 control;
int i, cap;
int i, cap, ret;
dma_addr_t msi;

pci_lock_rescan_remove();
Expand All @@ -442,6 +443,14 @@ static int enumerate_functions(struct centauri *c)
return -ENODEV;
if (!(pci_resource_flags(ipc->function[i], 0) & IORESOURCE_MEM))
return -ENODEV;
if (i) {
device_lock(&ipc->function[i]->dev);
ret = pci_enable_device_mem(ipc->function[i]);
device_unlock(&ipc->function[i]->dev);
if (ret)
return ret;
ipc->enabled[i] = true;
}
ipc->bar[i] = pci_iomap(ipc->function[i], 0, 0);
if (!ipc->bar[i])
return -ENOMEM;
Expand Down Expand Up @@ -558,9 +567,11 @@ int centauri_start_ipc(struct centauri *c)
*/
bool centauri_beta_running(struct centauri *c)
{
void __iomem *bar = c->ipc ? c->ipc->bar[2] : NULL;
struct centauri_ipc *ipc = c->ipc;

return bar && readl(bar + 0x18) == 2 && !readl(bar);
if (!ipc || !ipc->enabled[2] || !ipc->bar[2])
return false;
return readl(ipc->bar[2] + 0x18) == 2 && !readl(ipc->bar[2]);
}

void centauri_free_ipc(struct centauri *c)
Expand Down Expand Up @@ -595,6 +606,11 @@ void centauri_free_ipc(struct centauri *c)
for (i = 0; i < 3; i++) {
if (ipc->bar[i])
pci_iounmap(ipc->function[i], ipc->bar[i]);
if (ipc->enabled[i]) {
device_lock(&ipc->function[i]->dev);
pci_disable_device(ipc->function[i]);
device_unlock(&ipc->function[i]->dev);
}
pci_dev_put(ipc->function[i]);
}
kfree(ipc);
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/wireless/apple/centauri/centauri_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,10 @@ static int centauri_resume(struct device *dev)

static DEFINE_SIMPLE_DEV_PM_OPS(centauri_pm_ops, centauri_suspend, centauri_resume);

/* 0x1903 is the Beta (Bluetooth) function: btcentauri claims it. This driver needs functions
* 0 and 1 (1 is enabled here, its BAR is used by the Wi-Fi code) and reaches function 2 only
* through config space and its struct device for DMA.
/* 0x1903 is the Beta (Bluetooth) function: btcentauri claims it. This driver binds functions
* 0 and 1 (1 is enabled here, its BAR is used by the Wi-Fi code) and enables function 2's
* memory space during IPC bootstrap so centauri_beta_running() can poll Beta's BAR0 safely
* even when btcentauri has not probed yet.
*/
static const struct pci_device_id centauri_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x1900), .driver_data = 0x8000 },
Expand Down
Loading