aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhangfei Gao <zhangfei.gao@linaro.org>2014-06-10 10:39:00 +0800
committerZhangfei Gao <zhangfei.gao@linaro.org>2014-06-10 10:39:00 +0800
commit17ad12aaaf4d54bfb9370014db9dca98bd247d1a (patch)
tree72d371a16ad362dc7152422655caa55938a369d5
parentb31e9e90633089dba80f4daa3b84a48b8fcd0fa5 (diff)
debug smmueth_smmu
eth0 can work with ping, but iperf no response, stream id = 0 eth1 can not work with ping, stream id = 1
-rw-r--r--arch/arm/boot/dts/hip04.dtsi22
-rw-r--r--drivers/net/ethernet/hisilicon/hip04_eth.c40
2 files changed, 37 insertions, 25 deletions
diff --git a/arch/arm/boot/dts/hip04.dtsi b/arch/arm/boot/dts/hip04.dtsi
index 1cb660eb1d30..76ff1beaa57b 100644
--- a/arch/arm/boot/dts/hip04.dtsi
+++ b/arch/arm/boot/dts/hip04.dtsi
@@ -275,20 +275,8 @@
<0 110 4>,
<0 111 4>,
<0 112 4>;
- mmu-masters = <&iommu0 0x3>,
- <&iommu1 0x4>;
- };
-
- iommu0: iommu0 {
- compatible = "iommu-test";
- mem = <0x10000000 0x10000>;
- #stream-id-cells = <1>;
- };
-
- iommu1: iommu1 {
- compatible = "iommu-test";
- mem = <0x0 0x10000>;
- #stream-id-cells = <1>;
+ //mmu-masters = <&fe 0x0>, <&ge0 0x0>, <&ge8 0x2>;
+ mmu-masters = <&fe 0x0>, <&ge0 0x1>, <&ge8 0x2>;
};
uart0: uart@4007000 {
@@ -337,6 +325,8 @@
interrupts = <0 413 4>;
phy-mode = "mii";
port-handle = <&ppe 31 0>;
+ mem = <0x0 0x4000000>;
+ #stream-id-cells = <1>;
};
ge0: ethernet@2800000 {
@@ -346,6 +336,8 @@
phy-mode = "sgmii";
port-handle = <&ppe 0 1>;
phy-handle = <&phy0>;
+ mem = <0x4000000 0x4000000>;
+ #stream-id-cells = <1>;
};
ge8: ethernet@2880000 {
@@ -355,6 +347,8 @@
phy-mode = "sgmii";
port-handle = <&ppe 8 2>;
phy-handle = <&phy1>;
+ mem = <0x8000000 0x4000000>;
+ #stream-id-cells = <1>;
};
};
};
diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
index 7f01b910349e..ba7b4c81c97d 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -18,6 +18,7 @@
#include <linux/of_net.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
+#include <asm/dma-iommu.h>
#define PPE_CFG_RX_ADDR 0x100
#define PPE_CFG_POOL_GRP 0x300
@@ -97,6 +98,7 @@ struct hip04_priv {
struct napi_struct napi;
struct net_device *ndev;
+ struct device *dev;
struct tx_desc *tx_desc;
dma_addr_t tx_desc_dma;
@@ -328,7 +330,7 @@ static void hip04_tx_reclaim(struct net_device *ndev, bool force)
break;
}
if (priv->tx_phys[tx_tail]) {
- dma_unmap_single(&ndev->dev, priv->tx_phys[tx_tail],
+ dma_unmap_single(priv->dev, priv->tx_phys[tx_tail],
priv->tx_skb[tx_tail]->len, DMA_TO_DEVICE);
priv->tx_phys[tx_tail] = 0;
}
@@ -371,12 +373,13 @@ static int hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
return NETDEV_TX_BUSY;
}
- phys = dma_map_single(&ndev->dev, skb->data, skb->len, DMA_TO_DEVICE);
- if (dma_mapping_error(&ndev->dev, phys)) {
+ phys = dma_map_single(priv->dev, skb->data, skb->len, DMA_TO_DEVICE);
+ if (dma_mapping_error(priv->dev, phys)) {
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
+
priv->tx_skb[tx_head] = skb;
priv->tx_phys[tx_head] = phys;
desc->send_addr = cpu_to_be32(phys);
@@ -420,7 +423,7 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
if (unlikely(!skb))
net_dbg_ratelimited("build_skb failed\n");
- dma_unmap_single(&ndev->dev, priv->rx_phys[priv->rx_head],
+ dma_unmap_single(priv->dev, priv->rx_phys[priv->rx_head],
RX_BUF_SIZE, DMA_FROM_DEVICE);
priv->rx_phys[priv->rx_head] = 0;
@@ -448,10 +451,11 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
buf = netdev_alloc_frag(priv->rx_buf_size);
if (!buf)
return -ENOMEM;
- phys = dma_map_single(&ndev->dev, buf,
+ phys = dma_map_single(priv->dev, buf,
RX_BUF_SIZE, DMA_FROM_DEVICE);
- if (dma_mapping_error(&ndev->dev, phys))
+ if (dma_mapping_error(priv->dev, phys))
return -EIO;
+
priv->rx_buf[priv->rx_head] = buf;
priv->rx_phys[priv->rx_head] = phys;
hip04_set_recv_desc(priv, phys);
@@ -518,11 +522,12 @@ static int hip04_mac_open(struct net_device *ndev)
for (i = 0; i < RX_DESC_NUM; i++) {
dma_addr_t phys;
- phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
+ phys = dma_map_single(priv->dev, priv->rx_buf[i],
RX_BUF_SIZE, DMA_FROM_DEVICE);
- if (dma_mapping_error(&ndev->dev, phys))
+ if (dma_mapping_error(priv->dev, phys)) {
+ printk("map error\n");
return -EIO;
-
+ }
priv->rx_phys[i] = phys;
hip04_set_recv_desc(priv, phys);
}
@@ -554,7 +559,7 @@ static int hip04_mac_stop(struct net_device *ndev)
for (i = 0; i < RX_DESC_NUM; i++) {
if (priv->rx_phys[i]) {
- dma_unmap_single(&ndev->dev, priv->rx_phys[i],
+ dma_unmap_single(priv->dev, priv->rx_phys[i],
RX_BUF_SIZE, DMA_FROM_DEVICE);
priv->rx_phys[i] = 0;
}
@@ -633,12 +638,25 @@ static int hip04_mac_probe(struct platform_device *pdev)
{
struct device *d = &pdev->dev;
struct device_node *node = d->of_node;
+ struct dma_iommu_mapping *mapping;
struct of_phandle_args arg;
struct net_device *ndev;
struct hip04_priv *priv;
struct resource *res;
unsigned int irq;
int ret;
+ u32 mem[2];
+
+ /* mem[0]: mem map start address
+ * mem[1]: mem map size
+ */
+ of_property_read_u32_array(node, "mem", &mem[0], 2);
+ mapping = arm_iommu_create_mapping(&platform_bus_type,
+ mem[0], mem[1], 0);
+ if (IS_ERR(mapping))
+ return PTR_ERR(mapping);
+ if (arm_iommu_attach_device(d, mapping))
+ pr_err("arm_iommu_attach_device failed\n");
ndev = alloc_etherdev(sizeof(struct hip04_priv));
if (!ndev)
@@ -646,6 +664,7 @@ static int hip04_mac_probe(struct platform_device *pdev)
priv = netdev_priv(ndev);
priv->ndev = ndev;
+ priv->dev = d;
spin_lock_init(&priv->lock);
platform_set_drvdata(pdev, ndev);
@@ -704,7 +723,6 @@ static int hip04_mac_probe(struct platform_device *pdev)
INIT_WORK(&priv->tx_timeout_task, hip04_tx_timeout_task);
- ether_setup(ndev);
ndev->netdev_ops = &hip04_netdev_ops;
ndev->watchdog_timeo = TX_TIMEOUT;
ndev->priv_flags |= IFF_UNICAST_FLT;