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
3 changes: 2 additions & 1 deletion Documentation/networking/device_drivers/wifi/mt7932-neo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ performance policy.
``mt7932_bt_pcie`` defers its probe until ``mt7932-fullmac`` is bound to
function 0, so the Bluetooth firmware always starts after the Wi-Fi firmware,
as in the tested sequence, however the drivers are loaded. Bluetooth therefore
stays unbound while the Wi-Fi driver is missing or has failed. A device link
stays unbound while the Wi-Fi driver is missing or has failed, including when
a failed Wi-Fi function stays bound to keep DMA it could not stop. A device link
makes the driver core unbind Bluetooth before Wi-Fi; unloading
``mt7932_bt_pcie`` does not affect Wi-Fi. The probe rejects a function that is
not cold, which is what now prevents a reprobe after a failed or uncertain
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,7 @@ F: Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml
F: Documentation/devicetree/bindings/soc/apple/apple,pmp.yaml
F: drivers/pmdomain/apple/pmp-report.c
F: drivers/soc/apple/pmp.rs
F: include/linux/mt7932.h
F: include/linux/soc/apple/pmp-report.h
F: Documentation/devicetree/bindings/chosen/apple,dcp-rtkit-quiesced.yaml
F: Documentation/devicetree/bindings/display/apple,dcp.yaml
Expand Down
11 changes: 6 additions & 5 deletions drivers/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ config BT_MTK7932_PCIE
tristate "J700 MT7932 PCIe Bluetooth transport"
depends on BT && PCI && ARCH_APPLE && IOMMU_DMA
depends on !KEXEC_CORE
depends on MT7932_FULLMAC != n
depends on MT7932_FULLMAC
select FW_LOADER
help
Support the J700 Bluetooth PCIe function with locally installed firmware
and calibration. The function is probed once the Wi-Fi function is
bound to the mt7932-fullmac driver; the enable=0 parameter leaves it
unbound. Both functions appear before the root filesystem is mounted
and read their firmware when probed, so say M, like the Wi-Fi driver.
and calibration. The function is probed once the Wi-Fi function has
initialized under the mt7932-fullmac driver; the enable=0 parameter
leaves it unbound. Both functions appear before the root filesystem
is mounted and read their firmware when probed, so say M, like the
Wi-Fi driver.
System suspend uses the firmware sleep handshake and preserves DMA
storage. Hibernation and automatic firmware recovery are unsupported.
Removal drains the PCI function before releasing device-visible memory;
Expand Down
5 changes: 5 additions & 0 deletions drivers/bluetooth/mt7932_bt_pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/iommu.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/mt7932.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/overflow.h>
Expand Down Expand Up @@ -1050,6 +1051,10 @@ static int bt7932_wait_for_wifi(struct pci_dev *pdev)
strcmp(dev_driver_string(&wifi->dev), "mt7932-fullmac"))
ret = dev_err_probe(&pdev->dev, -EPROBE_DEFER,
"waiting for the Wi-Fi function\n");
/* Initialization ends before the Wi-Fi probe returns. */
else if (!mt7932_fullmac_ready(wifi))
ret = dev_err_probe(&pdev->dev, -ENODEV,
"the Wi-Fi function failed to initialize\n");
else if (!device_link_add(&pdev->dev, &wifi->dev, DL_FLAG_AUTOREMOVE_CONSUMER))
ret = -EINVAL;
pci_dev_put(wifi);
Expand Down
24 changes: 24 additions & 0 deletions drivers/net/wireless/mediatek/mt7932/mt7932.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Clean-room contract: NEO_MT7932_DOWNLOAD_AND_NIC_CAP_CONTRACT.md.
* All addresses here are BAR0 offsets, never chip/CPU physical addresses.
*/
#include <linux/mt7932.h>
#include "mt7932.h"

static int mt_ring_alloc(struct mt7932 *m, struct mt7932_ring *q,
Expand Down Expand Up @@ -1251,6 +1252,8 @@ static int mt_probe(struct pci_dev *pdev, const struct pci_device_id *id)
ret = mt_reset_retained(&m);
if (!ret)
ret = mt_register_regulatory_gate(m);
if (!ret)
WRITE_ONCE(m->ready, true);
retain:
if (ret) {
int error = ret;
Expand Down Expand Up @@ -1293,6 +1296,27 @@ static struct pci_driver mt_driver = {
.shutdown = mt_shutdown,
.driver.suppress_bind_attrs = true,
};

/**
* mt7932_fullmac_ready() - check that the Wi-Fi function is up
* @pdev: function 0 of the radio
*
* A Wi-Fi function whose initialization failed stays bound when its DMA
* could not be stopped, so being bound does not mean its firmware runs.
*
* Return: true if @pdev is bound to this driver and finished initialization.
*/
bool mt7932_fullmac_ready(struct pci_dev *pdev)
{
struct mt7932 *m;

if (!device_is_bound(&pdev->dev) || pdev->dev.driver != &mt_driver.driver)
return false;
m = pci_get_drvdata(pdev);
return m && READ_ONCE(m->ready);
}
EXPORT_SYMBOL_GPL(mt7932_fullmac_ready);

module_pci_driver(mt_driver);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("J700 MT7932 firmware-owned cfg80211 station driver");
2 changes: 2 additions & 0 deletions drivers/net/wireless/mediatek/mt7932/mt7932.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ struct mt7932 {
u64 interrupts, packets;
bool running;
bool stopping;
/* Probe finished initialization; the Bluetooth function may start. */
bool ready;
bool irq_requested, vectors_allocated, wiphy_registered;
bool dma_owned;
struct completion reset_retry;
Expand Down
14 changes: 14 additions & 0 deletions include/linux/mt7932.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Interface between the functions of the J700 MT7932 radio.
*/
#ifndef __LINUX_MT7932_H
#define __LINUX_MT7932_H

#include <linux/types.h>

struct pci_dev;

bool mt7932_fullmac_ready(struct pci_dev *pdev);

#endif /* __LINUX_MT7932_H */