Skip to contentSkip to conversation

net: emac: emac gigabit ethernet controller driver

PATCH Superseded Timur Tabi 4 participants 8 messages Jun 14, 2016 – Jun 20, 2016

Subsystems (5)

v5 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH v5 1/1 net: emac: emac gigabit ethernet controller driver

Add supports for ethernet controller HW on Qualcomm Technologies, Inc. SoC. This driver supports the following features:
1) Checksum offload.
2) Interrupt coalescing support.
3) SGMII phy.
4) phylib interface for external phy

Based on original work by
Niranjana Vishwanathapura <[email protected]> Gilad Avidov <[email protected]>

---

v5:
- changed author to Timur, added MAINTAINERS entry
- use phylib, replacing internal phy code
- added support for EMAC internal SGMII v2
- fix ~DIS_INT warning
- update DT bindings, including removing unused properties
- removed interrupt handler for internal sgmii
- removed link status check handler/state (replaced with phylib)
- removed periodic timer handler (replaced with phylib)
- removed power management code (will be rewritten later)
- external phy is now required, not optional
- removed redundant EMAC_STATUS_DOWN status flag
- removed redundant link status and speed variables
- removed redundant status bits (vlan strip, promiscuous, loopback, etc)
- removed useless watchdog status
- removed command-line parameters
- cleaned up probe messages
- removed redundant params from emac_sgmii_link_init()
- always call netdev_completed_queue() (per review comment)
- fix emac_napi_rtx() (per review comment)
- removed max_ints loop in interrupt handler
- removed redundant mutex around phy read/write calls
- added lock for reading emac status (per review comment)
- generate random MAC address if it can't be read from firmware
- replace EMAC_DMA_ADDR_HI/LO with upper/lower_32_bits
- don't test return value from platform_get_resource (per review comment)
- use net_warn_ratelimited (per review comment)
- don't set the dma masks (will be set by DT or IORT code)
- remove unused emac_tx_tpd_ts_save()
- removed redundant local MTU variable

v4:
- add missing ipv6 header file
- correct compatible string
- fix spacing in emac_reg_write arrays
- drop unnecessary cell-index property
- remove unsupported DT properties from docs
- remove GPIO initialization and update docs

v3:
- remove most of the memory barriers by using the non xxx_relaxed() api.
- remove RSS and WOL support.
- correct comments from physical address to dma address.
- rearrange structs to make them packed.
- replace polling loops with readl_poll_timeout().
- remove unnecessary wrapper functions from phy layer.
- add blank line before return statements.
- set to null clocks after clk_put().
- use module_platform_driver() and dma_set_mask_and_coherent()
- replace long hex bitmasks with BIT() macro.

v2:
- replace hw bit fields to macros with bitwise operations.
- change all iterators to unsized types (int)
- some minor code flow improvements.
- change return type to void for functions which return value is never used.
- replace instance of xxxxl_relaxed() io followed by mb() with a readl()/writel().

 .../devicetree/bindings/net/qcom-emac.txt          |   66 +
 MAINTAINERS                                        |    6 +
 drivers/net/ethernet/qualcomm/Kconfig              |   11 +
 drivers/net/ethernet/qualcomm/Makefile             |    2 +
 drivers/net/ethernet/qualcomm/emac/Makefile        |    7 +
 drivers/net/ethernet/qualcomm/emac/emac-mac.c      | 1674 ++++++++++++++++++++
 drivers/net/ethernet/qualcomm/emac/emac-mac.h      |  284 ++++
 drivers/net/ethernet/qualcomm/emac/emac-phy.c      |  211 +++
 drivers/net/ethernet/qualcomm/emac/emac-phy.h      |   32 +
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c    |  699 ++++++++
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.h    |   24 +
 drivers/net/ethernet/qualcomm/emac/emac.c          |  798 ++++++++++
 drivers/net/ethernet/qualcomm/emac/emac.h          |  370 +++++
 13 files changed, 4184 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom-emac.txt
 create mode 100644 drivers/net/ethernet/qualcomm/emac/Makefile
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-mac.c
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-mac.h
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-phy.c
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-phy.h
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii.h
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac.c
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac.h
Documentation/devicetree/bindings/net/qcom-emac.txt new file +66 -0
new file mode 100644
index 0000000..e48a9b9
@@ -0,0 +1,66 @@
+Qualcomm EMAC Gigabit Ethernet Controller
+
+Required properties:
+- compatible : Should be "qcom,fsm9900-emac".
+- reg : Offset and length of the register regions for the device
+- reg-names : Register region names referenced in 'reg' above.
+	Required register resource entries are:
+	"base"   : EMAC controller base register block.
+	"csr"    : EMAC wrapper register block.
+	"sgmii"  : EMAC SGMII PHY register block.
+	Optional register resource entries are:
+	"ptp"    : EMAC PTP (1588) register block.
+- interrupts : Interrupt numbers used by this controller
+- interrupt-names : Interrupt resource names referenced in 'interrupts' above.
+	Required interrupt resource entries are:
+	"emac_core0"   : EMAC core0 interrupt.
+	"sgmii_irq"   : EMAC SGMII interrupt.
+- mac-address               : The 6-byte MAC address. If present, it is the
+			      default MAC address.
+
+Optional properties:
+The external phy child node:
+- compatible : Should be "qcom,fsm9900-emac-phy".
+- reg : The phy address
+
+Example:
+soc {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	emac0: qcom,emac@feb20000 {
+		compatible = "qcom,fsm9900-emac";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg-names = "base", "csr", "ptp", "sgmii";
+		reg =   <0xfeb20000 0x10000>,
+			<0xfeb36000 0x1000>,
+			<0xfeb3c000 0x4000>,
+			<0xfeb38000 0x400>;
+		dma-ranges = <0 0 0xffffffff>;
+		interrupt-parent = <&emac0>;
+		#interrupt-cells = <1>;
+		interrupts = <0 1>;
+		interrupt-map-mask = <0xffffffff>;
+		interrupt-map = <0 &intc 0 76 0
+				 1 &intc 0 80 0>;
+		interrupt-names = "emac_core0", "sgmii_irq";
+		phy0: ethernet-phy@0 {
+			compatible = "qcom,fsm9900-emac-phy";
+			reg = <0>;
+		}
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&mdio_pins_a>;
+	};
+
+	tlmm: pinctrl@fd510000 {
+		compatible = "qcom,fsm9900-pinctrl";
+
+		mdio_pins_a: mdio {
+			state {
+				pins = "gpio123", "gpio124";
+				function = "mdio";
+			};
+		};
+	};
MAINTAINERS +6 -0
index 6ee06ea..e53f3a6 100644
@@ -8974,6 +8974,12 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
 S:	Supported
 F:	drivers/net/wireless/ath/ath10k/
 
+QUALCOMM EMAC GIGABIT ETHERNET DRIVER
+M:	Timur Tabi <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/net/ethernet/qualcomm/emac/
+
 QUALCOMM HEXAGON ARCHITECTURE
 M:	Richard Kuo <[email protected]>
 L:	[email protected]
drivers/net/ethernet/qualcomm/Kconfig +11 -0
index a76e380..85b599f 100644
@@ -24,4 +24,15 @@ config QCA7000
 	  To compile this driver as a module, choose M here. The module
 	  will be called qcaspi.
 
+config QCOM_EMAC
+	tristate "Qualcomm Technologies, Inc. EMAC Gigabit Ethernet support"
+	select CRC32
+	---help---
+	  This driver supports the Qualcomm Technologies, Inc. Gigabit
+	  Ethernet Media Access Controller (EMAC). The controller
+	  supports IEEE 802.3-2002, half-duplex mode at 10/100 Mb/s,
+	  full-duplex mode at 10/100/1000Mb/s, Wake On LAN (WOL) for
+	  low power, Receive-Side Scaling (RSS), and IEEE 1588-2008
+	  Precision Clock Synchronization Protocol.
+
 endif # NET_VENDOR_QUALCOMM
drivers/net/ethernet/qualcomm/Makefile +2 -0
index 9da2d75..1b3a0ce 100644
@@ -4,3 +4,5 @@
 
 obj-$(CONFIG_QCA7000) += qcaspi.o
 qcaspi-objs := qca_spi.o qca_framing.o qca_7k.o qca_debug.o
+
+obj-$(CONFIG_QCOM_EMAC) += emac/
drivers/net/ethernet/qualcomm/emac/Makefile new file +7 -0
new file mode 100644
index 0000000..01ee144
@@ -0,0 +1,7 @@
+#
+# Makefile for the Qualcomm Technologies, Inc. EMAC Gigabit Ethernet driver
+#
+
+obj-$(CONFIG_QCOM_EMAC) += qcom-emac.o
+
+qcom-emac-objs := emac.o emac-mac.o emac-phy.o emac-sgmii.o
drivers/net/ethernet/qualcomm/emac/emac-mac.c new file +1674 -0

1,674 lines not on this page · raw message

drivers/net/ethernet/qualcomm/emac/emac-mac.h new file +284 -0

284 lines not on this page · raw message

drivers/net/ethernet/qualcomm/emac/emac-phy.c new file +211 -0

211 lines not on this page · raw message

drivers/net/ethernet/qualcomm/emac/emac-phy.h new file +32 -0
new file mode 100644
index 0000000..03e2b74
@@ -0,0 +1,32 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 and
+* only version 2 as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+
+#ifndef _EMAC_PHY_H_
+#define _EMAC_PHY_H_
+
+/* emac_phy
+ * @base register file base address space.
+ * @digital per-lane digital block
+ * @version the internal phy version
+ */
+struct emac_phy {
+	void __iomem			*base;
+	void __iomem			*digital;
+
+	unsigned int			version;
+};
+
+struct emac_adapter;
+
+int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt);
+
+#endif /* _EMAC_PHY_H_ */
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c new file +699 -0

694 lines not on this page · raw message

drivers/net/ethernet/qualcomm/emac/emac-sgmii.h new file +24 -0
new file mode 100644
index 0000000..cd7db9f

Lines of this file are not shown. View the raw message.

drivers/net/ethernet/qualcomm/emac/emac.c new file +798 -0

798 lines not on this page · raw message

drivers/net/ethernet/qualcomm/emac/emac.h new file +370 -0

370 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

Part of the diff is not shown here. View the raw message.

maintainer
#1 lore raw

From: Timur Tabi <[email protected]>
Date: Tue, 14 Jun 2016 17:22:35 -0500

drivers/net/ethernet/qualcomm/emac/emac-mac.c line 702

Quoted 7 lines
drivers/net/ethernet/qualcomm/emac/emac-mac.c new file +7 -0
+/* Free all descriptors of given receive queue */
+static void emac_rx_q_free_descs(struct emac_adapter *adpt)
+{
+	struct emac_rx_queue *rx_q = &adpt->rx_q;
+	struct device *dev = adpt->netdev->dev.parent;
+	size_t size;
+	int i;

Please always order local variable declarations from longest to shortest line.

Audit your entire driver for this issue, thanks.

author
#2 lore raw
Quoted 4 lines · David Miller

Please always order local variable declarations from longest to shortest line.

Audit your entire driver for this issue, thanks.

I will fix this in v6.

Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
maintainer
#3 lore raw
In reply to Timur Tabi
Quoted 127 lines · Timur Tabi

Add supports for ethernet controller HW on Qualcomm Technologies, Inc. SoC. This driver supports the following features:
1) Checksum offload.
2) Interrupt coalescing support.
3) SGMII phy.
4) phylib interface for external phy

Based on original work by
Niranjana Vishwanathapura <[email protected]> Gilad Avidov <[email protected]>

---

v5:
- changed author to Timur, added MAINTAINERS entry
- use phylib, replacing internal phy code
- added support for EMAC internal SGMII v2
- fix ~DIS_INT warning
- update DT bindings, including removing unused properties
- removed interrupt handler for internal sgmii
- removed link status check handler/state (replaced with phylib)
- removed periodic timer handler (replaced with phylib)
- removed power management code (will be rewritten later)
- external phy is now required, not optional
- removed redundant EMAC_STATUS_DOWN status flag
- removed redundant link status and speed variables
- removed redundant status bits (vlan strip, promiscuous, loopback, etc)
- removed useless watchdog status
- removed command-line parameters
- cleaned up probe messages
- removed redundant params from emac_sgmii_link_init()
- always call netdev_completed_queue() (per review comment)
- fix emac_napi_rtx() (per review comment)
- removed max_ints loop in interrupt handler
- removed redundant mutex around phy read/write calls
- added lock for reading emac status (per review comment)
- generate random MAC address if it can't be read from firmware
- replace EMAC_DMA_ADDR_HI/LO with upper/lower_32_bits
- don't test return value from platform_get_resource (per review comment)
- use net_warn_ratelimited (per review comment)
- don't set the dma masks (will be set by DT or IORT code)
- remove unused emac_tx_tpd_ts_save()
- removed redundant local MTU variable

v4:
- add missing ipv6 header file
- correct compatible string
- fix spacing in emac_reg_write arrays
- drop unnecessary cell-index property
- remove unsupported DT properties from docs
- remove GPIO initialization and update docs

v3:
- remove most of the memory barriers by using the non xxx_relaxed() api.
- remove RSS and WOL support.
- correct comments from physical address to dma address.
- rearrange structs to make them packed.
- replace polling loops with readl_poll_timeout().
- remove unnecessary wrapper functions from phy layer.
- add blank line before return statements.
- set to null clocks after clk_put().
- use module_platform_driver() and dma_set_mask_and_coherent()
- replace long hex bitmasks with BIT() macro.

v2:
- replace hw bit fields to macros with bitwise operations.
- change all iterators to unsized types (int)
- some minor code flow improvements.
- change return type to void for functions which return value is never used.
- replace instance of xxxxl_relaxed() io followed by mb() with a readl()/writel().

 .../devicetree/bindings/net/qcom-emac.txt          |   66 +
 MAINTAINERS                                        |    6 +
 drivers/net/ethernet/qualcomm/Kconfig              |   11 +
 drivers/net/ethernet/qualcomm/Makefile             |    2 +
 drivers/net/ethernet/qualcomm/emac/Makefile        |    7 +
 drivers/net/ethernet/qualcomm/emac/emac-mac.c      | 1674 ++++++++++++++++++++
 drivers/net/ethernet/qualcomm/emac/emac-mac.h      |  284 ++++
 drivers/net/ethernet/qualcomm/emac/emac-phy.c      |  211 +++
 drivers/net/ethernet/qualcomm/emac/emac-phy.h      |   32 +
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c    |  699 ++++++++
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.h    |   24 +
 drivers/net/ethernet/qualcomm/emac/emac.c          |  798 ++++++++++
 drivers/net/ethernet/qualcomm/emac/emac.h          |  370 +++++
 13 files changed, 4184 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom-emac.txt
 create mode 100644 drivers/net/ethernet/qualcomm/emac/Makefile
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-mac.c
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-mac.h
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-phy.c
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-phy.h
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii.h
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac.c
 create mode 100644 drivers/net/ethernet/qualcomm/emac/emac.h
Documentation/devicetree/bindings/net/qcom-emac.txt new file +21 -0
new file mode 100644
index 0000000..e48a9b9
@@ -0,0 +1,66 @@
+Qualcomm EMAC Gigabit Ethernet Controller
+
+Required properties:
+- compatible : Should be "qcom,fsm9900-emac".
+- reg : Offset and length of the register regions for the device
+- reg-names : Register region names referenced in 'reg' above.
+	Required register resource entries are:
+	"base"   : EMAC controller base register block.
+	"csr"    : EMAC wrapper register block.
+	"sgmii"  : EMAC SGMII PHY register block.
+	Optional register resource entries are:
+	"ptp"    : EMAC PTP (1588) register block.
+- interrupts : Interrupt numbers used by this controller
+- interrupt-names : Interrupt resource names referenced in 'interrupts' above.
+	Required interrupt resource entries are:
+	"emac_core0"   : EMAC core0 interrupt.
+	"sgmii_irq"   : EMAC SGMII interrupt.
+- mac-address               : The 6-byte MAC address. If present, it is the
+			      default MAC address.
+
+Optional properties:

Documentation/devicetree/bindings/net/qcom-emac.txt line 31

Quoted 10 lines
Documentation/devicetree/bindings/net/qcom-emac.txt new file +10 -0
+The external phy child node:
+- compatible : Should be "qcom,fsm9900-emac-phy".
+- reg : The phy address
+
+Example:
+soc {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	emac0: qcom,emac@feb20000 {

ethernet@...

Documentation/devicetree/bindings/net/qcom-emac.txt line 40

Quoted 9 lines
Documentation/devicetree/bindings/net/qcom-emac.txt new file +9 -0
+		compatible = "qcom,fsm9900-emac";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg-names = "base", "csr", "ptp", "sgmii";
+		reg =   <0xfeb20000 0x10000>,
+			<0xfeb36000 0x1000>,
+			<0xfeb3c000 0x4000>,
+			<0xfeb38000 0x400>;
+		dma-ranges = <0 0 0xffffffff>;

I believe dma-ranges is supposed to be in the bus (parent) node.

Documentation/devicetree/bindings/net/qcom-emac.txt line 46

Quoted 6 lines
Documentation/devicetree/bindings/net/qcom-emac.txt new file +6 -0
+		interrupt-parent = <&emac0>;
+		#interrupt-cells = <1>;
+		interrupts = <0 1>;
+		interrupt-map-mask = <0xffffffff>;
+		interrupt-map = <0 &intc 0 76 0
+				 1 &intc 0 80 0>;

Why? This looks unnecessary.

Quoted 20 lines
Documentation/devicetree/bindings/net/qcom-emac.txt new file +20 -0
+		interrupt-names = "emac_core0", "sgmii_irq";
+		phy0: ethernet-phy@0 {
+			compatible = "qcom,fsm9900-emac-phy";
+			reg = <0>;
+		}
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&mdio_pins_a>;
+	};
+
+	tlmm: pinctrl@fd510000 {
+		compatible = "qcom,fsm9900-pinctrl";
+
+		mdio_pins_a: mdio {
+			state {
+				pins = "gpio123", "gpio124";
+				function = "mdio";
+			};
+		};
+	};
author
#4 lore raw
Quoted 2 lines · Rob Herring
Quoted 1 line

Documentation/devicetree/bindings/net/qcom-emac.txt line 40

Quoted 1 line
Documentation/devicetree/bindings/net/qcom-emac.txt new file +1 -0
+		dma-ranges = <0 0 0xffffffff>;

I believe dma-ranges is supposed to be in the bus (parent) node.

Maybe I'm just going to be perpetually confused by dma-ranges, but how can I specify that the emac has a different DMA range from another SOC device, if dma-ranges is in the parent node?

The EMAC itself is capable of 64-bit DMA internally (I should have included a dma_set_mask call with DMA_BIT_MASK(64) in the driver). However, the platform typically limits this range. On FSM9900 and QDF2432, it's 32 bits. On the next server chip, it'll be the full 64 bits. I need some way to handle that.

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum, a Linux Foundation collaborative project.
#5 lore raw

Timur,

I think, the device driver is responsible for setting the right DMA_MASK based on the underlying hardware capability if your driver wants to support 64bit DMA.

Example code in drivers/usb/host/xhci.c:

        /* Set dma_mask and coherent_dma_mask to 64-bits,
         * if xHC supports 64-bit addressing */
        if (HCC_64BIT_ADDR(xhci->hcc_params) &&
                        !dma_set_mask(dev, DMA_BIT_MASK(64))) {
                xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
                dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
        } else {
                /*
                 * This is to avoid error in cases where a 32-bit USB
                 * controller is used on a 64-bit capable system.
                 */
                retval = dma_set_mask(dev, DMA_BIT_MASK(32));
Quoted 8 lines · Timur Tabi
Quoted 2 lines · Rob Herring
Quoted 1 line
Quoted 1 line

+ dma-ranges = <0 0 0xffffffff>;

I believe dma-ranges is supposed to be in the bus (parent) node.

Maybe I'm just going to be perpetually confused by dma-ranges, but how can I specify that the emac has a different DMA range from another SOC device, if dma-ranges is in the parent node?

The EMAC itself is capable of 64-bit DMA internally (I should have included a dma_set_mask call with DMA_BIT_MASK(64) in the driver). However, the platform typically limits this range. On FSM9900 and QDF2432, it's 32 bits. On the next server chip, it'll be the full 64 bits. I need some way to handle that.

Signature · 3 lines
Shanker Donthineni
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#6 lore raw
Quoted 4 lines · Shanker Donthineni
         /* Set dma_mask and coherent_dma_mask to 64-bits,
          * if xHC supports 64-bit addressing */
         if (HCC_64BIT_ADDR(xhci->hcc_params) &&
                         !dma_set_mask(dev, DMA_BIT_MASK(64))) {
Quoted 8 lines
                 xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
                 dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
         } else {
                 /*
                  * This is to avoid error in cases where a 32-bit USB
                  * controller is used on a 64-bit capable system.
                  */
                 retval = dma_set_mask(dev, DMA_BIT_MASK(32));

I'm not sure this example is valid because HCC_64BIT_ADDR is part of the XCHI specification, so there's an architected way determine whether the platform is 64-bit capable or not. The EMAC has nothing like that.

I can do this:

	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
	if (ret)
		dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32))

but this has always seemed wrong to me, because it doesn't make sense to me that DMA_BIT_MASK(64) could ever fail. DMA_BIT_MASK(64) says that the device can handle any physical address, so the device does not impose any limitations. How could that fail? I have has this question multiple times, and I have never gotten a satisfactory answer.

Also, I don't know if I should be using dma_set_mask_and_coherent or dma_coerce_mask_and_coherent. The comment for dma_coerce_mask_and_coherent says this:

/*
* Similar to the above, except it deals with the case where the device
* does not have dev->dma_mask appropriately setup.
*/

How can I know if the device has dev->dma_mask "appropriately setup"?

Remember, I need a solution that works for DT and ACPI.

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum, a Linux Foundation collaborative project.
author
#7 lore raw
In reply to Rob Herring
Quoted 7 lines · Rob Herring
Quoted 6 lines

Documentation/devicetree/bindings/net/qcom-emac.txt line 46

Quoted 6 lines
Documentation/devicetree/bindings/net/qcom-emac.txt new file +6 -0
+		interrupt-parent = <&emac0>;
+		#interrupt-cells = <1>;
+		interrupts = <0 1>;
+		interrupt-map-mask = <0xffffffff>;
+		interrupt-map = <0 &intc 0 76 0
+				 1 &intc 0 80 0>;

Why? This looks unnecessary.

It may have made sense with an earlier version of the driver that had more complex interrupts. I'll fix it in v6.

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum, a Linux Foundation collaborative project.