summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/cadence/macb_main.c
Commit message (Collapse)AuthorAgeFilesLines
* net: macb: Clean 64b dma addresses if they are not detectedMichal Simek2018-11-041-0/+1
| | | | | | | | | | | | | | | | [ Upstream commit e1e5d8a9fe737d94ccc0ccbaf0c97f69a8f3e000 ] Clear ADDR64 dma bit in DMACFG register in case that HW_DMA_CAP_64B is not detected on 64bit system. The issue was observed when bootloader(u-boot) does not check macb feature at DCFG6 register (DAW64_OFFSET) and enabling 64bit dma support by default. Then macb driver is reading DMACFG register back and only adding 64bit dma configuration but not cleaning it out. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
* net: macb: disable scatter-gather for macb on sama5d3Nicolas Ferre2018-10-181-0/+8
| | | | | | | | | | | | | [ Upstream commit eb4ed8e2d7fecb5f40db38e4498b9ee23cddf196 ] Create a new configuration for the sama5d3-macb new compatibility string. This configuration disables scatter-gather because we experienced lock down of the macb interface of this particular SoC under very high load. Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx()Jia-Ju Bai2018-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | [ Upstream commit 16fe10cf92783ed9ceb182d6ea2b8adf5e8ec1b8 ] The kernel module may sleep with holding a spinlock. The function call paths (from bottom to top) in Linux-4.16 are: [FUNC] usleep_range drivers/net/ethernet/cadence/macb_main.c, 648: usleep_range in macb_halt_tx drivers/net/ethernet/cadence/macb_main.c, 730: macb_halt_tx in macb_tx_error_task drivers/net/ethernet/cadence/macb_main.c, 721: _raw_spin_lock_irqsave in macb_tx_error_task To fix this bug, usleep_range() is replaced with udelay(). This bug is found by my static analysis tool DSAC. Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* net: macb: Fix regression breaking non-MDIO fixed-link PHYsAhmad Fatoum2018-09-151-10/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ Upstream commit ab5f11055fdf8dfc3ddbd89e8e3cc550de41d1d3 ] commit 739de9a1563a ("net: macb: Reorganize macb_mii bringup") broke initializing macb on the EVB-KSZ9477 eval board. There, of_mdiobus_register was called even for the fixed-link representing the RGMII-link to the switch with the result that the driver attempts to enumerate PHYs on a non-existent MDIO bus: libphy: MACB_mii_bus: probed mdio_bus f0028000.ethernet-ffffffff: fixed-link has invalid PHY address mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 0 [snip] mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 31 The "MDIO" bus registration succeeds regardless, having claimed the reset GPIO, and calling of_phy_register_fixed_link later on fails because it tries to claim the same GPIO: macb f0028000.ethernet: broken fixed-link specification Fix this by registering the fixed-link before calling mdiobus_register. Fixes: 739de9a1563a ("net: macb: Reorganize macb_mii bringup") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* net: macb: do not disable MDIO bus at open/close timeAnssi Hannula2018-09-151-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | [ Upstream commit 0da70f808029476001109b6cb076737bc04cea2e ] macb_reset_hw() is called from macb_close() and indirectly from macb_open(). macb_reset_hw() zeroes the NCR register, including the MPE (Management Port Enable) bit. This will prevent accessing any other PHYs for other Ethernet MACs on the MDIO bus, which remains registered at macb_reset_hw() time, until macb_init_hw() is called from macb_open() which sets the MPE bit again. I.e. currently the MDIO bus has a short disruption at open time and is disabled at close time until the interface is opened again. Fix that by only touching the RE and TE bits when enabling and disabling RX/TX. v2: Make macb_init_hw() NCR write a single statement. Fixes: 6c36a7074436 ("macb: Use generic PHY layer") Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* net: macb: Allocate valid memory for TX and RX BD prefetchHarini Katakam2018-07-071-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | GEM version in ZynqMP and most versions greater than r1p07 supports TX and RX BD prefetch. The number of BDs that can be prefetched is a HW configurable parameter. For ZynqMP, this parameter is 4. When GEM DMA is accessing the last BD in the ring, even before the BD is processed and the WRAP bit is noticed, it will have prefetched BDs outside the BD ring. These will not be processed but it is necessary to have accessible memory after the last BD. Especially in cases where SMMU is used, memory locations immediately after the last BD may not have translation tables triggering HRESP errors. Hence always allocate extra BDs to accommodate for prefetch. The value of tx/rx bd prefetch for any given SoC version is: 2 ^ (corresponding field in design config 10 register). (value of this field >= 1) Added a capability flag so that older IP versions that do not have DCFG10 or this prefetch capability are not affected. Signed-off-by: Harini Katakam <harini.katakam@xilinx.com> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Free RX ring for all queuesHarini Katakam2018-07-071-6/+5
| | | | | | | | | rx ring is allocated for all queues in macb_alloc_consistent. Free the same for all queues instead of just Q0. Signed-off-by: Harini Katakam <harini.katakam@xilinx.com> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: initialize bp->queues[0].bp for at91rm9200Alexandre Belloni2018-06-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | The macb driver currently crashes on at91rm9200 with the following trace: Unable to handle kernel NULL pointer dereference at virtual address 00000014 [...] [<c031da44>] (macb_rx_desc) from [<c031f2bc>] (at91ether_open+0x2e8/0x3f8) [<c031f2bc>] (at91ether_open) from [<c041e8d8>] (__dev_open+0x120/0x13c) [<c041e8d8>] (__dev_open) from [<c041ec08>] (__dev_change_flags+0x17c/0x1a8) [<c041ec08>] (__dev_change_flags) from [<c041ec4c>] (dev_change_flags+0x18/0x4c) [<c041ec4c>] (dev_change_flags) from [<c07a5f4c>] (ip_auto_config+0x220/0x10b0) [<c07a5f4c>] (ip_auto_config) from [<c000a4fc>] (do_one_initcall+0x78/0x18c) [<c000a4fc>] (do_one_initcall) from [<c0783e50>] (kernel_init_freeable+0x184/0x1c4) [<c0783e50>] (kernel_init_freeable) from [<c0574d70>] (kernel_init+0x8/0xe8) [<c0574d70>] (kernel_init) from [<c00090e0>] (ret_from_fork+0x14/0x34) Solve that by initializing bp->queues[0].bp in at91ether_init (as is done in macb_init). Fixes: ae1f2a56d273 ("net: macb: Added support for many RX queues") Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* drivers: net: Remove device_node checks with of_mdiobus_register()Florian Fainelli2018-05-161-9/+3
| | | | | | | | | | | | | | | | | | | A number of drivers have the following pattern: if (np) of_mdiobus_register() else mdiobus_register() which the implementation of of_mdiobus_register() now takes care of. Remove that pattern in drivers that strictly adhere to it. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Fugang Duan <fugang.duan@nxp.com> Reviewed-by: Antoine Tenart <antoine.tenart@bootlin.com> Reviewed-by: Jose Abreu <joabreu@synopsys.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Try to retrieve MAC addess from nvmem providerMike Looijmans2018-03-301-3/+9
| | | | | | | | | | Call of_get_nvmem_mac_address() to fetch the MAC address from an nvmem cell, if one is provided in the device tree. This allows the address to be stored in an I2C EEPROM device for example. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Add phy-handle DT supportBrad Mouring2018-03-161-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This optional binding (as described in the ethernet DT bindings doc) directs the netdev to the phydev to use. This is useful for a phy chip that has >1 phy in it, and two netdevs are using the same phy chip (i.e. the second mac's phy lives on the first mac's MDIO bus) The devicetree snippet would look something like this: ethernet@feedf00d { ... phy-handle = <&phy0> // the first netdev is physically wired to phy0 ... phy0: phy@0 { ... reg = <0x0> // MDIO address 0 ... } phy1: phy@1 { ... reg = <0x1> // MDIO address 1 ... } ... } ethernet@deadbeef { ... phy-handle = <&phy1> // tells the driver to use phy1 on the // first mac's mdio bus (it's wired thusly) ... } The work done to add the phy_node in the first place (dacdbb4dfc1a1: "net: macb: add fixed-link node support") will consume the device_node (if found). Signed-off-by: Brad Mouring <brad.mouring@ni.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Remove redundant poll irq assignmentBrad Mouring2018-03-161-4/+1
| | | | | | | | | | In phy_device's general probe, this device will already be set for phy register polling, rendering this code redundant. Signed-off-by: Brad Mouring <brad.mouring@ni.com> Suggested-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Reorganize macb_mii bringupBrad Mouring2018-03-161-38/+41
| | | | | | | | | | | | | The macb mii setup (mii_probe() and mii_init()) previously was somewhat interspersed, likely a result of organic growth and hacking. This change moves mii bus registration into mii_init and probing the bus for devices into mii_probe. Signed-off-by: Brad Mouring <brad.mouring@ni.com> Suggested-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Handle HRESP errorHarini Katakam2018-01-291-4/+55
| | | | | | | | | Handle HRESP error by doing a SW reset of RX and TX and re-initializing the descriptors, RX and TX queue pointers. Signed-off-by: Harini Katakam <harinik@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: change GFP_ATOMIC to GFP_KERNELJulia Cartwright2017-12-051-1/+1
| | | | | | | | | | | | Now that the rx_fs_lock is no longer held across allocation, it's safe to use GFP_KERNEL for allocating new entries. This reverts commit 81da3bf6e3f88 ("net: macb: change GFP_KERNEL to GFP_ATOMIC"). Cc: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Julia Cartwright <julia@ni.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: reduce scope of rx_fs_lock-protected regionsJulia Cartwright2017-12-051-5/+11
| | | | | | | | | | | | | | | | | | | | | Commit ae8223de3df5 ("net: macb: Added support for RX filtering") introduces a lock, rx_fs_lock which is intended to protect the list of rx_flow items and synchronize access to the hardware rx filtering registers. However, the region protected by this lock is overscoped, unnecessarily including things like slab allocation. Reduce this lock scope to only include operations which must be performed atomically: list traversal, addition, and removal, and hitting the macb filtering registers. This fixes the use of kmalloc w/ GFP_KERNEL in atomic context. Fixes: ae8223de3df5 ("net: macb: Added support for RX filtering") Cc: Rafal Ozieblo <rafalo@cadence.com> Cc: Julia Lawall <julia.lawall@lip6.fr> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Julia Cartwright <julia@ni.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: kill useless use of list_empty()Julia Cartwright2017-12-051-19/+12
| | | | | | | | | | | The list_for_each_entry() macro already handles the case where the list is empty (by not executing the loop body). It's not necessary to handle this case specially, so stop doing so. Cc: Rafal Ozieblo <rafalo@cadence.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Julia Cartwright <julia@ni.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* macb: Kill PHY reset codeSergei Shtylyov2017-12-051-21/+0
| | | | | | | | | | | With the phylib now being aware of the "reset-gpios" PHY node property, there should be no need to frob the PHY reset in this driver anymore... Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: change GFP_KERNEL to GFP_ATOMICJulia Lawall2017-12-051-1/+1
| | | | | | | | | | | | | Function gem_add_flow_filter called on line 2958 inside lock on line 2949 but uses GFP_KERNEL Generated by: scripts/coccinelle/locks/call_kern.cocci Fixes: ae8223de3df5 ("net: macb: Added support for RX filtering") CC: Rafal Ozieblo <rafalo@cadence.com> Signed-off-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Added support for RX filteringRafal Ozieblo2017-11-301-1/+335
| | | | | | | | This patch allows filtering received packets to different hardware queues (aka ntuple). Signed-off-by: Rafal Ozieblo <rafalo@cadence.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Added some queue statisticsRafal Ozieblo2017-11-301-3/+34
| | | | | | | | | | | | | Added statistics per queue: - qX_rx_packets - qX_rx_bytes - qX_rx_dropped - qX_tx_packets - qX_tx_bytes - qX_tx_dropped Signed-off-by: Rafal Ozieblo <rafalo@cadence.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Added support for many RX queuesRafal Ozieblo2017-11-301-131/+175
| | | | | | | | | To be able for packet reception on different RX queues some configuration has to be performed. This patch checks how many hardware queue does GEM support and initializes them. Signed-off-by: Rafal Ozieblo <rafalo@cadence.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: add of_node_put to error pathsMichael Grzeschik2017-11-111-0/+2
| | | | | | | | | We add the call of_node_put(bp->phy_node) to all associated error paths for memory clean up. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: add of_phy_deregister_fixed_link to error pathsMichael Grzeschik2017-11-111-0/+7
| | | | | | | | | We add the call of_phy_deregister_fixed_link to all associated error paths for memory clean up. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: remove redundant assignment to variable work_doneColin Ian King2017-11-011-2/+0
| | | | | | | | | | | | | Variable work_done is set to zero and this value is never read, instead it is set to another value a few statements later. Remove the redundant assignment. Cleans up clang warning: drivers/net/ethernet/cadence/macb_main.c:1221:2: warning: Value stored to 'work_done' is never read Signed-off-by: Colin Ian King <colin.king@canonical.com> Tested-by: Alexander Dahl <ada@thorsis.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* macb: Remove bogus reference to NETIF_F_UFO.David S. Miller2017-07-171-1/+1
| | | | | | | This driver doesn't actually support UFO explicitly yet it advertises this in netdev->features. Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Adding Support for Jumbo Frames up to 10240 Bytes in SAMA5D3vishnuvardhan2017-07-081-1/+2
| | | | | | | | | | | | | | | | | | | As per the SAMA5D3 device specification it supports Jumbo frames. But the suggested flag and length of bytes it supports was not updated in this driver config_structure. The maximum jumbo frames the device supports : 10240 bytes as per the device spec. While changing the MTU value greater than 1500, it threw error: sudo ifconfig eth1 mtu 9000 SIOCSIFMTU: Invalid argument Add this support to driver so that it works as expected and designed. Signed-off-by: vishnuvardhan <vardhanraj4143@gmail.com> [nicolas.ferre@microchip.com: modify slightly commit msg] Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: remove extraneous return when MACB_EXT_DESC is definedColin Ian King2017-07-051-1/+0
| | | | | | | | | | | | When macro MACB_EXT_DESC is defined we end up with two identical return statements and just one is sufficient. Remove the extra return. Detected by CoverityScan, CID#1449361 ("Structurally dead code") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: Add hardware PTP supportRafal Ozieblo2017-06-301-6/+84
| | | | | | | | | | | | | | | | | This patch is based on original Harini's patch and Andrei's patch, implemented in a separate file to ease the review/maintanance and integration with other platforms. This driver supports GEM-GXL: - Register ptp clock framework - Initialize PTP related registers - HW time stamp on the PTP Ethernet packets are received using the SO_TIMESTAMPING API. Time stamps are obtained from the dma buffer descriptors - add macb_ptp to compilation chain Signed-off-by: Rafal Ozieblo <rafalo@cadence.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: macb: macb.c changed to macb_main.cRafal Ozieblo2017-06-301-0/+3588
In case that macb is compiled as a module, macb.c has been renamed to macb_main.c to avoid naming confusion in Makefile. Signed-off-by: Rafal Ozieblo <rafalo@cadence.com> Signed-off-by: David S. Miller <davem@davemloft.net>