aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtl818x (follow)
AgeCommit message (Collapse)AuthorFilesLines
2014-03-31rtl8187: fix use after free on failure path in rtl8187_probe()Alexey Khoroshilov1-2/+2
If allocation of io_dmabuf fails, rtl8187_probe() calls usb_put_dev(udev) while usb_get_dev(udev) is not called yet. As a result refcnt is decremented incorrectly and usb_dev can be used after memory deallocation. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Acked-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-31rtl8180: don't use weird trick to access "far" registersAndrea Merello1-10/+4
In rtl8180/rtl8185/rtl8187se the register space is represented using packed structure type. Register are thus accessed using a pointer of this type. All registers are packed toghether, and only small gaps are present. However Rtl8187se has also some "sparse" registers, very far from the "main register block". It could be possible to access them by simply declare huge reserved blocks inside the register struct (and this causes NO memory waste). However, for various reasons, access to those "far" registers is done with special dedicated macros, without declaring them in the register struct. This is done in an intricate manner, that makes code less readable and caused static analisys tool to produce warnings. This patch keeps the "macro" mechanism, but it changes its implementation in a simplier and more straightforward way. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-31rtl8187: fix compile warningAndrea Merello1-1/+1
ANAPARAM3 register, defined in the rtl818x common register struct, is accessed as 16bit by rtl8187se and as 8bit by rtl8187b. Since I have no documentation about this, I can only stick to the reference code and to what is known to work. This issue has been addressed by a patch from Larry Finger that introduces an "union", in the register struct. In my last patch-set I applied it on the register struct, but I forget to update rtl8187 driver too. This patch does it. Suggested-by: Larry Finger <Larry.Finger@lwfinger.net> [ Original patch ] Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl818x: Update Kconfig for rtl8187seAndrea Merello1-2/+2
update description in Kconfig to state rtl8180 driver now supports also rtl8187se cards Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: enable rtl8187se supportAndrea Merello1-4/+35
Finally make rtl8187se works (hopefylly). This patch adds PCI ID for rtl8187, updates copyright notes and updates MODULE_DESCRIPTION. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: detect rtl8187se cardAndrea Merello1-2/+15
Add case to detect the rtl8187se card and its RF frontend. In this case set also accordingly mac80211 queue number. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add WMM parameters configuration for rtl8187seAndrea Merello2-2/+61
Introduce a new function to configure AC parameters for TX queues on rtl8187se cards, and hook it onto mac80211 in order to enable WMM support. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: make sure RTL818X_MSR_ENEDCA is set for rtl8187seAndrea Merello1-0/+4
MSR register for rtl8187se must always have ENEDCA flag set. Write it accordingly when updated on BSS change. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add ERP configuration for rtl8187seAndrea Merello1-6/+10
This patch adds ERP configuration support for rtl8187se to the existing ERP configuration function. It needs a different register offset and it must not apply rtl8185 workaround. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add rtl8187se HW initializationAndrea Merello1-9/+159
This patch adds few functions that initializes extra stuff that is present only in rtl8187se HW, and it modify the existing HW initialization function where necessary Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add RF code for rtl8225 zebra v4Andrea Merello4-1/+538
This patch introduce new RF code for rtl8225 zebra v4 radio frontend. This code contains a lot of black magic and it can work probably only with the radio embdedded in the rtl8187se single-chip. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: introduce functions for setting ANAPARAM 2 and 3 paramsAndrea Merello3-0/+42
rtl8180 has one register for analog converters setting ,rtl8185 has two and rtl8187se has three. Setting those registers require more than a simple write, and for one of them a function is already provided. This patch introduces functions for the other two. rtl8187se will use them. rtl8185 doesen't yet, but should Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add rtl8187se params to eeprom readingAndrea Merello2-1/+24
rtl8187se nees extra parameters to be read from the eeprom. This patch adds support for it Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: config carbus register for rtl8187seAndrea Merello1-7/+21
configuration of carbus-related registers is different for rtl8187se. Introduce a dedicated function that does it for all cards in the proper way Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add TX queue mapping and support for rtl8187seAndrea Merello2-6/+88
This patch adds tx queue mapping for rtl8187se and a long comment block about their usages. It adapts the TX function to use that map and it sets properly the TX descriptor rtl8187se-only fields Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: don't write MAR registers for rtl8187seAndrea Merello1-2/+7
MAR registers are not present in rtl8187se, and attempting to write to them must be avoided Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: introduce functions to enable/disable ints and add support for rtl8187seAndrea Merello1-3/+33
This patch introduces two dedicated functions for enabling and disabling ints. Support for rtl8187se is also added to them Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add ISR for rtl8187seAndrea Merello1-1/+56
rtl8187se has more queues and different ISR flags. This patch adds a separated ISR handler for rtl8187se Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: support for rtl8187se RX descriptorsAndrea Merello2-18/+57
Currently RX status descriptor and RX command descriptor are represented using the same struct type. This patch splits this by introducing different types for rx status and command descriptor. Doing this make it possible to handle rtl8187se RX descriptors easier. This patch do also this by adding specific cases where needed. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add basic rate configuration support for rtl8187seAndrea Merello1-1/+5
Basic rate configuration is a bit different for rtl8187se. Adding this also fixes the gcc warning introduced in last patch about unhandled case in switch. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add rtl8187se fields to TX descriptorAndrea Merello1-2/+14
This patch modifies the TX descriptor struct so it can work also for rtl8187se. Some reserved field is now meaningful, and where needed union is used. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: add rtl8187se chip typeAndrea Merello1-0/+1
Add back rtl8187se chip type to the enum for known chips. This causes unhandled switch/case warning that will be fixed in following patch Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl818x: add registers for rtl8187seAndrea Merello1-49/+217
Adds registers for rtl8187se to the rtl818x common struct Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: rationalize TX queuesAndrea Merello2-16/+49
On currently supported HW there are four TX queues (three for normal packets and one for beacons). The driver uses just one TX queue, and declare to mac80211 to support just one queue, but it allocates coherent memory for all queues. Furthermore the TX is code is written assumimg four queues exists, and even if we decide to enable more queues in future, its mapping rule to mac80211 is fixed. This means we have memory waste on rtl8180/rtl8185, and we have also not enough flexibility to add support for boards (rtl8187se) that will use more queues. This patch changes things in order to allocate coherent memory only for the queues effectively used and it make it possible to specify how to map hardware queues on mac80211 queues, that will be used by rtl8187se code as soon it will be merged. Note: even if the beacon queue is currently unused, this should change, so I kept it. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-27rtl8180: fix DMA register are written two timesAndrea Merello1-6/+0
Hw DMA registers are written in rtl8180_init_hw function. They are also written again just after calling rtl8180_init_hw. There is no point in doing this twice. Remove those redundant register writes from rtl8180_start. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-19rtl818x: remove unused conf_erp callback from RF ops structAndrea Merello1-1/+0
The ERP configuration is now done outside RF code in both rtl8180 and rtl8187 drivers. The conf_erp callback in common RF ops struct is now useless. Remove it. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-17rtl8180: move eeprom read stuff in a separate functionAndrea Merello2-58/+73
Eeprom read operations are mixed in the probe function. Make the code more readable and clean by extracting this code and moving it in a dedicated function. The variable eeprom_cck_table_adr, now useless, is here because it will be needed for rtl8187se support, that I hope to add soon. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-17rtl8180: make *IFS and CW tunable by mac80211, and set them in the proper placeAndrea Merello3-24/+83
SLOT, SIFS, DIFS, EIFS, CW and ACK-timeout registers are set in an RF-code callback and their values are fixed. This patch moves this off the rf-code, and introduce two new functions that calculate these values depending by slot time and CW values requested by mac80211. This seems to improve performances on my setup. Currently the ack and slot time values could be stored in a local variable, but this patch stores it in the driver "priv" structure because it will be useful for rtl8187se support that will be added (hopefully) soon. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-17rtl8180: support for BSS_CHANGED_BASIC_RATESAndrea Merello1-6/+45
Basic rates setting is done with hardcoded register write with fixed settings. This patch introduces a new function that makes it possible to configure basic rates and it add a check for mac80211 BSS_CHANGED_BASIC_RATES flag in order to eventually invoke that function when needed. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-17rtl8180: remove too-early-added rtl8187se enum valueAndrea Merello1-1/+0
While changing board-type variable to enum, I have added enum value for rtl8187se by mistake. This will causes gcc warnings with unhandled switch/cases. Remove it temporarily until I will push also rtl8187se changes. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-14rtl8180: prepare to handle more than two chip typesAndrea Merello2-15/+28
Currently a "r8185" integer variable is used as a boolean flag to indicate whether the card is a rtl8185 or not. Since now the driver supports only rtl8185 and rtl8180 cards, if "r8185" variable is zero then the card is implicitly assumed to be a rtl8180. Now I'm preparing to add support for a third card type (rtl8187se). This patch changes the "r8185" flag with an enum variable to explicitly indicate which card type we have. I'm submitting this this patch now, even if I still have to submit other patches that not pertain with rtl8187se support, because IMHO it's not worth rebasing them on the current code, using r8185 flag, and then changing them back again nearly immediately. BTW if someone feels I really should do this, please tell me.. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-04rtl818x: make sure TX descriptor writes are done before kicking DMAandrea merello1-0/+6
The TX descriptors are consumed by the HW using DMA. Even if in the driver code the TX descriptor writes appears before the HW "dma kick" register writes, the CPU may reorder them. If this happens, the TX may not happen at all becase the "valid" descriptor flag may have not been set yet. This patch adds a write memory barrier to ensures the TX descriptor is written before writing to the HW "dma kick" register. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-04rtl818x: Make sure the TX descriptor "valid" flag is written by lastandrea merello1-0/+5
The TX descriptors are consumed by the HW using DMA. Even if in the driver code the memory write that sets the "valid" flag appears after all other writes, the CPU may reorder writes, causing the HW to consider as valid a not-fully-written yet descriptor. This may cause HW incorrect behaviour. This can happen because (AFAIK) the HW may attempt DMA asynchronously without waiting to be kicked by the following register write. This patch adds a write memory barrier to enforce writes ordering. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-03-04Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirelessJohn W. Linville1-2/+8
Conflicts: drivers/net/wireless/ath/ath9k/recv.c drivers/net/wireless/mwifiex/pcie.c
2014-02-28rtl818x: add comments to explain few not obvious HW configs.andrea merello1-0/+12
Certain HW options (TX packet retry count, CW configuration and TX power configuration) can be specified in both the TX packet descriptor and also into HW "global" registers. The HW is thus configured to honour the global register or the TX descriptor field depending by the case. This patch adds few comments that hopefully clarify in which cases the driver uses one method and in which cases it uses the other. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-02-28rtl818x: make dev_alloc_skb() null pointer check to really workandrea merello1-3/+4
During driver initialization, some skbs are preallocated for RX. Currenly if the allocation fails, the driver's allocation routine exits immediatly but it will return zero (success) anyway. In this way the driver will continue initialization with buggy pointers around. This patch makes the driver's allocation routine to return an error value and to print a complaint message when skb allocation fails. In this way its caller will not go further, avoinding the driver to successfully load, and preventing dereferencing buggy pointers. An hint is thus printed about why the driver failed. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-02-28rtl818x: check for pci_map_single() success when initializing RX ringandrea merello1-0/+7
During initialization a number of RX skbs are allocated and mapped for DMA. Currently if pci_map_single() fails, it will result in passing to the HW a wrong DMA address (to write to!). This patch adds check for this condition and eventually causes the driver not to initialize, avoiding at least dangerous DMAs. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-02-28rtl818x: pci_iomap() should pair with pci_iounmap()andrea merello1-1/+1
Currently the driver uses pci_iomap() but iounmap() is called in the error path Change to use pci_iounmap() instead. Reported-by: Huqiu Liu <liuhq11@mails.tsinghua.edu.cn> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-02-28rtl818x: Explicitly enable contetion windowandrea merello1-0/+2
Currently the contention window enable/disable HW flag is not touched by the driver. This patch explicitly set it to the correct value to make sure contention window is enabled (AFAIK contention window must be enabled in most (if not all) cases. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-02-13rtl8187: fix regression on MIPS without coherent DMAStanislaw Gruszka1-2/+8
This patch fixes regression caused by commit a16dad77634 "MIPS: Fix potencial corruption". That commit fixes one corruption scenario in cost of adding another one, which actually start to cause crashes on Yeeloong laptop when rtl8187 driver is used. For correct DMA read operation on machines without DMA coherence, kernel have to invalidate cache, such it will refill later with new data that device wrote to memory, when that data is needed to process. We can only invalidate full cache line. Hence when cache line includes both dma buffer and some other data (written in cache, but not yet in main memory), the other data can not hit memory due to invalidation. That happen on rtl8187 where struct rtl8187_priv fields are located just before and after small buffers that are passed to USB layer and DMA is performed on them. To fix the problem we align buffers and reserve space after them to make them match cache line. This patch does not resolve all possible MIPS problems entirely, for that we have to assure that we always map cache aligned buffers for DMA, what can be complex or even not possible. But patch fixes visible and reproducible regression and seems other possible corruptions do not happen in practice, since Yeeloong laptop works stable without rtl8187 driver. Bug report: https://bugzilla.kernel.org/show_bug.cgi?id=54391 Reported-by: Petr Pisar <petr.pisar@atlas.cz> Bisected-by: Tom Li <biergaizi2009@gmail.com> Reported-and-tested-by: Tom Li <biergaizi2009@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl> Acked-by: Larry Finger <Larry.Finger@lwfinger.next> Acked-by: Hin-Tak Leung <htl10@users.sourceforge.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-02-13Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirelessJohn W. Linville1-3/+20
2014-02-12rtl818x: change misleading names for few register bit definitionsandrea merello3-16/+16
In rtl8180/rtl8187 drivers, few register bit definitions have names of form FOOBAR_SHIFT, suggesting they should be used as shift offset, for example reg |= (1 << ENABLE_FOO_SHIFT). However they are actually defined as (1 << x) and thus they are used (correctly) like reg |= ENABLE_FOO_SHIFT; This patch kills the misleading _SHIFT suffix. Signed-off-by: andrea merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-02-06rtl8180: Add error check for pci_map_single return value in TX pathandrea.merello1-0/+7
Orignal code will not detect a DMA mapping failure, causing the HW to attempt a DMA from an invalid address. This patch add the error check and eventually simply drops the TX packet if we can't map it for DMA. Signed-off-by: andrea merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-02-06rtl8180: Add error check for pci_map_single return value in RX pathandrea.merello1-3/+13
In original code the old RX DMA buffer is unmapped and processed and at the end of the isr a new buffer is mapped with pci_map_single and attached to the RX descriptor. If pci_map_single fails then the RX descriptor remains with no valid DMA buffer attached. In this condition the DMA will target where it shouldn't with obvious evil consequences. Simply avoiding re-arming the descriptor will prevent buggy DMA but it will result soon in RX stuck. This patch move the DMA mapping of the new buffer at the beginning of the ISR (and it adds error check for pci_map_single success/fail). If the DMA mapping fails then we do not unmap the old buffer and we re-arm the descriptor without processing it, with the old DMA buffer still attached. In this way we lose the currently RX-ed packet, but whenever next calls to pci_map_single will succeed again,then the RX process will go on without stuck. Signed-off-by: andrea merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-01-03wireless: delete non-required instances of include <linux/init.h>Paul Gortmaker7-7/+0
None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Acked-by: Larry Finger <Larry.Finger@lwfinger.net> Acked-by: Christian Lamparter <chunkeey@googlemail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2013-12-05rtl8187: Increase RX queue depthLarry Finger1-1/+1
Under heavy load, the relatively small number of RX queue entries are completely filled. With an increase from 16 to 32 entries, this condition rarely happens. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2013-09-26wireless: rtl818x: remove unnecessary pci_set_drvdata()Jingoo Han1-1/+0
The driver core clears the driver data to NULL after device_release or on probe failure. Thus, it is not needed to manually clear the device driver data to NULL. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2013-09-09rtl8187: fix use after free on failure path in rtl8187_init_urbs()Alexey Khoroshilov1-5/+10
In case of __dev_alloc_skb() failure rtl8187_init_urbs() calls usb_free_urb(entry) where 'entry' can points to urb allocated at the previous iteration. That means refcnt will be decremented incorrectly and the urb can be used after memory deallocation. The patch fixes the issue and implements error handling of init_urbs in rtl8187_start(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2013-08-26Update e-mail address for Andrea Merello (resubmit)Andrea Merello13-22/+22
A lot of files contain reference to my old e-mail address. Now I'm going not to read mail from it anymore, so update it with my current address everywhere. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
2013-03-25mac80211: Use a cfg80211_chan_def in ieee80211_hw_conf_chanKarl Beldan7-9/+13
Drivers that don't use chanctxes cannot perform VHT association because they still use a "backward compatibility" pair of {ieee80211_channel, nl80211_channel_type} in ieee80211_conf and ieee80211_local. Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com> [fix kernel-doc] Signed-off-by: Johannes Berg <johannes.berg@intel.com>