1
0
Fork 0
Commit Graph

842 Commits (761cab513d5e9079ec8ace48ab05d84b0083653b)

Author SHA1 Message Date
Arnd Bergmann 87e6e1957c mt76: fix LED link time failure
[ Upstream commit d68f4e43a4 ]

The mt76_led_cleanup() function is called unconditionally, which
leads to a link error when CONFIG_LEDS is a loadable module or
disabled but mt76 is built-in:

drivers/net/wireless/mediatek/mt76/mac80211.o: In function `mt76_unregister_device':
mac80211.c:(.text+0x2ac): undefined reference to `led_classdev_unregister'

Use the same trick that is guarding the registration, using an
IS_ENABLED() check for the CONFIG_MT76_LEDS symbol that indicates
whether LEDs can be used or not.

Fixes: 36f7e2b2bb ("mt76: do not use devm API for led classdev")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-01 13:18:11 +02:00
Felix Fietkau 78344a4dc4 mt76: fix handling full tx queues in mt76_dma_tx_queue_skb_raw
[ Upstream commit 93eaec7625 ]

Fixes a theoretical issue where it could potentially overwrite an existing
descriptor entry (and leaking its skb)

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-01 13:17:34 +02:00
Felix Fietkau 9b42bfb06d mt76: clear skb pointers from rx aggregation reorder buffer during cleanup
[ Upstream commit 9379df2fd9 ]

During the cleanup of the aggregation session, a rx handler (or release timer)
on another CPU might still hold a pointer to the reorder buffer and could
attempt to release some packets.
Clearing pointers during cleanup avoids a theoretical use-after-free bug here.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-01 13:17:34 +02:00
Felix Fietkau 14bbbfbafe mt76: add missing locking around ampdu action
[ Upstream commit 1a817fa73c ]

This is needed primarily to avoid races in dealing with rx aggregation
related data structures

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-01 13:17:20 +02:00
Felix Fietkau 5eee23bc19 mt76: do not use devm API for led classdev
[ Upstream commit 36f7e2b2bb ]

With the devm API, the unregister happens after the device cleanup is done,
after which the struct mt76_dev which contains the led_cdev has already been
freed. This leads to a use-after-free bug that can crash the system.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-01 13:17:20 +02:00
Sean Wang 2bf9418b7b mt76: mt7615: fix potential memory leak in mcu message handler
[ Upstream commit 9248c08c3f ]

Fix potential memory leak in mcu message handler on error condition.

Fixes: 0e6a29e477 ("mt76: mt7615: add support to read temperature from mcu")
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-08-19 08:16:14 +02:00
Ryder Lee 5deaa24167 mt76: avoid rx reorder buffer overflow
[ Upstream commit 7c4f744d67 ]

Enlarge slot to support 11ax 256 BA (256 MPDUs in an AMPDU)

Signed-off-by: Chih-Min Chen <chih-min.chen@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-06-22 09:31:05 +02:00
Matthew Garrett 91e863ab82 mt76: mt76x02u: Add support for newer versions of the XBox One wifi adapter
commit b2934279c3 upstream.

The current version has a new USB ID and reports as an 0x7632 device.
Adding the IDs results in it working out of the box.

Signed-off-by: Matthew Garrett <mjg59@google.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-06-07 13:18:47 +02:00
Felix Fietkau 0201373462 mt76: fix array overflow on receiving too many fragments for a packet
commit b102f0c522 upstream.

If the hardware receives an oversized packet with too many rx fragments,
skb_shinfo(skb)->frags can overflow and corrupt memory of adjacent pages.
This becomes especially visible if it corrupts the freelist pointer of
a slab page.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-18 07:17:53 +01:00
Lorenzo Bianconi 0812e7de49 mt76: mt76u: rely on usb_interface instead of usb_dev
[ Upstream commit 80df01f4dc ]

usb drivers are supposed to communicate using usb_interface instead
mt76x{0,2}u is now registering through usb_device. Fix it by passing
usb_intf device to mt76_alloc_device routine.

Fixes: 112f980ac8 ("mt76usb: use usb_dev private data")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-By: Zero_Chaos <sidhayn@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-26 10:01:08 +01:00
Lorenzo Bianconi 1de9dd61f0 mt76: mt76u: fix endpoint definition order
commit 23cb16d2cc upstream.

Even if they are not currently used fix BK/BE endpoint definition order.

Fixes: b40b15e152 ("mt76: add usb support to mt76 layer")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-26 10:01:01 +01:00
Lorenzo Bianconi 44a9b673a7 mt76: fix possible out-of-bound access in mt7615_fill_txs/mt7603_fill_txs
[ Upstream commit e8b970c8e3 ]

Fix possible out-of-bound access of status rates array in
mt7615_fill_txs/mt7603_fill_txs routines

Fixes: c5211e997e ("mt76: mt7603: rework and fix tx status reporting")
Fixes: 4af81f02b4 ("mt76: mt7615: sync with mt7603 rate control changes")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-12-31 16:45:43 +01:00
Lorenzo Bianconi 7bd0650be6 mt76: dma: fix buffer unmap with non-linear skbs
mt76 dma layer is supposed to unmap skb data buffers while keep txwi
mapped on hw dma ring. At the moment mt76 wrongly unmap txwi or does
not unmap data fragments in even positions for non-linear skbs. This
issue may result in hw hangs with A-MSDU if the system relies on IOMMU
or SWIOTLB. Fix this behaviour properly unmapping data fragments on
non-linear skbs.

Fixes: 17f1de56df ("mt76: add common code shared between multiple chipsets")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-30 16:59:48 +02:00
Lorenzo Bianconi f37f055035 mt76: mt76x2e: disable pcie_aspm by default
On same device (e.g. U7612E-H1) PCIE_ASPM causes continuous mcu hangs and
instability. Since mt76x2 series does not manage PCIE PS states, first we
try to disable ASPM using pci_disable_link_state. If it fails, we will
disable PCIE PS configuring PCI registers.
This patch has been successfully tested on U7612E-H1 mini-pice card

Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-30 16:59:46 +02:00
Lorenzo Bianconi 9d4d0d06bb mt76: mt7615: fix mt7615 firmware path definitions
mt7615 patch/n9/cr4 firmwares are available in mediatek folder in
linux-firmware repository. Because of this mt7615 won't work on regular
distributions like Ubuntu. Fix path definitions.  Moreover remove useless
firmware name pointers and use definitions directly

Fixes: 04b8e65922 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
Cc: stable@vger.kernel.org
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-09-24 17:45:30 +03:00
David S. Miller aa2eaa8c27 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Minor overlapping changes in the btusb and ixgbe drivers.

Signed-off-by: David S. Miller <davem@davemloft.net>
2019-09-15 14:17:27 +02:00
Lorenzo Bianconi 0e6a29e477 mt76: mt7615: add support to read temperature from mcu
Introduce debugfs entry to read device temperature and related cmu
command. Introduce mt7615_mcu_parse_response to parse mcu response
messages and refactor mt7615_mcu_msg_send routine

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 18:14:15 +02:00
Lorenzo Bianconi 373a9a13ba mt76: mt7615: introduce mt7615_txwi_to_txp utility routine
Introduce mt7615_txwi_to_txp utility routine to convert mt76_txwi_cache
into mt7615_txp and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 18:14:14 +02:00
YueHaibing 4c49c09947 mt76: mt7603: use devm_platform_ioremap_resource() to simplify code
Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 18:14:13 +02:00
Stanislaw Gruszka 0c168e1084 mt76: mt76x0: remove unneeded return value on set channel
We allways return 0 from mt76x0_phy_set_channel(), no need to pass
return value upward.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 18:14:12 +02:00
Stanislaw Gruszka 187617c55c mt76: mt76x0: remove redundant chandef copy
We set dev->mt76.chandef in mt76_set_channel() already.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 18:14:11 +02:00
Stanislaw Gruszka ef836a71ae mt76: make mt76_rx_convert static
mt76_rx_convert() not need to be exported any longer.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 18:14:10 +02:00
Felix Fietkau 04824da920 mt76: remove offchannel check in tx scheduling
tx queues are already disabled by mac80211 during scanning or other
off-channel activity. There is no need to repeat the check in mt76,
since scheduled queues are selected by mac80211 as well.

Signed-off-by: Balakrishna Bandi <b.balakrishna@globaledgesoft.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:32 +02:00
Felix Fietkau e3ca8fa0ca mt76: do not send BAR frame on tx aggregation flush stop
There is no need to send a BAR frame after stopping aggregation, and doing
so could lead to sending class 3 frames after deauthentication from an AP

Signed-off-by: Balakrishna Bandi <b.balakrishna@globaledgesoft.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:32 +02:00
Felix Fietkau 58bab0d42f mt76: stop rx aggregation on station removal
Fixes use-after-free issues on forced station removal during hardware restart
on MT76x02

Fixes: aee5b8cf24 ("mt76: implement A-MPDU rx reordering in the driver code")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:32 +02:00
Felix Fietkau 5a90107d79 mt76: dma: reset q->rx_head on rx reset
Fixes rx of the first frame if a fragmented rx was interrupted by the reset

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:32 +02:00
Felix Fietkau 55bbbefd84 mt76: mt7615: apply calibration-free data from OTP
MT7615 chips usually come pre-calibrated, even when used on embedded boards.
In that case, the on-flash EEPROM data needs to be merged with some data
from OTP ROM.
Run this merge if the external EEPROM data is valid and OTP has valid fields.

Tested-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:32 +02:00
Lorenzo Bianconi 8b8ab5c235 mt76: add default implementation for mt76_sw_scan/mt76_sw_scan_complete
Introduce a default implementation for mt76_sw_scan and
mt76_sw_scan_complete in mt76 module and remove duplicated code
since most of the drivers share the same implementation

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:32 +02:00
Ryder Lee 13381dcdb3 mt76: fix some checkpatch warnings
This fixes the following checkpatch warnings:
CHECK: Alignment should match open parenthesis
CHECK: No space is necessary after a cast

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:32 +02:00
Lorenzo Bianconi 01cfc1b454 mt76: mt7615: add BIP_CMAC_128 cipher support
Refactor mt7615_mac_wtbl_set_key and introduce
the following routines in order to configure wtbl entries
and properly add hw support to BIP_CMAC_128 cipher:
- mt7615_mac_wtbl_update_cipher
- mt7615_mac_wtbl_update_pk
- mt7615_mac_wtbl_update_key

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:32 +02:00
Lorenzo Bianconi 7f7d19c3bc mt76: mt7603: remove unnecessary mcu queue initialization
Remove unnecessary mcu queue initialization in mt7603_dma_init since it
has been already done in mt76_mmio_init

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi c325c9c779 mt76: move mt76_tx_tasklet in mt76 module
Move mt76{15,03}_tx_tasklet in mt76_alloc_device in order to be used as
default tx_tasklet initialization. Remove duplicated code in
mt7603/mt7615 drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi 863c15a14e mt76: mt7615: enable survey support
Introduce channel survey support for mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi fc98e670ad mt76: mt7603: move survey_time in mt76_dev
Move survey_time field in mt76_dev in order to be reused adding survey
support to mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi 168aea24f4 mt76: mt76x02u: enable survey support
Introduce channel survey support for mt76x2u and mt76x0u drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi f110d1d51d mt76: mt76x02u: enable multi-vif support
Enable multi-interface support for mt76x02u driver. For the moment
allow max two concurrent interfaces in order to preserve enough room
for ps traffic since we are using beacon slots for it.
I have successfully tested the following configuration:
- AP + STA
- AP0 + AP1

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi d5160d867f mt76: mt76x02: do not copy beacon skb in mt76x02_mac_set_beacon_enable
Do not copy beacon skb in mt76x02_mac_set_beacon_enable for usb devices
since it will be done in mt76x02_update_beacon_iter. Moreover squash
mt76x02_mac_set_beacon_enable and __mt76x02_mac_set_beacon_enable since
the latter is run just by mt76x02_mac_set_beacon_enable

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi 1920a0cc03 mt76: mt76x02: introduce mt76x02_pre_tbtt_enable and mt76x02_beacon_enable macros
Improve code readability introducing mt76x02_pre_tbtt_enable and
mt76x02_beacon_enable utility macros

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi 49de79ad9a mt76: mt7615: add Smart Carrier Sense support
Introduce Smart Carrier Sense support in order to tune device
sensitivity according to RTS error rate and False CCA reported by the
radio

Tested-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Lorenzo Bianconi 7fe9654152 mt76: mt7615: rework locking scheme for mt7615_set_channel
As already done for mt7603 driver, move mt76.mutex lock inside
mt7615_set_channel since we need to grab mt76.mutex in mt7615_mac_work.
This is a preliminary patch to add Smart Carrier Sense (SCS) support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Ryder Lee 0e3d677750 mt76: switch to SPDX tag instead of verbose boilerplate text
No functional change intended.

Add SPDX identifiers to all remaining files in /mt76.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Ryder Lee ff97c52a3a mt76: mt76x02: fix some checkpatch warnings
This fixes the following checkpatch warnings:

ERROR: code indent should use tabs where possible
CHECK: Alignment should match open parenthesis
CHECK: No space is necessary after a cast
CHECK: Please don't use multiple blank lines
CHECK: Avoid precedence issues in macro
WARNING: Statements should start on a tabstop
WARNING: Unnecessary space before function pointer arguments

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Ryder Lee 0dacf9d3ab mt76: mt7615: fix some checkpatch warnings
This fixes the following checkpatch warnings:

WARNING: Improper SPDX comment style
Fix blank lines.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:31 +02:00
Ryder Lee 7f17b86a04 mt76: mt7603: fix some checkpatch warnings
This fixes the following checkpatch warnings:

WARNING: Improper SPDX comment style
CHECK: No space is necessary after a cast

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:30 +02:00
Ryder Lee 06413abe55 mt76: Add paragraphs to describe the config symbols fully
Update the help text to fix a checkpatch warning:

WARNING: please write a paragraph that describes the config symbol fully

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:30 +02:00
Ryder Lee 4f8a4f17fb mt76: mt7615: update cw_min/max related settings
Add default values of cw_min/max and use fls() for configuration.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:30 +02:00
Ryder Lee 49f1132cdb mt76: mt7615: add 4 WMM sets support
Hardware supports 4 sets of WMM that should be put to good use.
And fix incorrect queue mapping in mt7615_conf_tx().

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:30 +02:00
Lorenzo Bianconi 5e814e71a2 mt76: mt7603: fix watchdog rescheduling in mt7603_set_channel
Convert MT7603_WATCHDOG_TIME in jiffies rescheduling watchdog delayed
work

Fixes: c8846e1015 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:30 +02:00
Lorenzo Bianconi 457d19c71a mt76: mt7615: fix MT7615_WATCHDOG_TIME definition
Express watchdog timeout in jiffies since it is used directly in
ieee80211_queue_delayed_work

Fixes: 04b8e65922 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:30 +02:00
Lorenzo Bianconi 35e4ebeaac mt76: introduce mt76_mmio_read_copy routine
Add mt76_mmio_read_copy routine and the related function pointer in
mt76_bus_ops data structure. mt76_mmio_read_copy will be used to add
BIP_CMAC_128 cipher hw support to mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-09-05 17:42:30 +02:00