Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1212728ybh; Sat, 3 Aug 2019 20:45:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA0W19Oyv/9p6by+yxBgwLyNbh+cO4hb4vX9jQwsYiFMhWY/5/8wjTHYY3z4OJLQNP5oh2 X-Received: by 2002:a17:90a:fa07:: with SMTP id cm7mr12081941pjb.115.1564890333711; Sat, 03 Aug 2019 20:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564890333; cv=none; d=google.com; s=arc-20160816; b=0cOekQxcO8u0RevdMJrcB8zjdrdm1g6iD0Yq6jPOHKfsrUt1t0CAHlC4guq9HP4RO9 tBnyAPOCKsTp8B12GRiuQuW2SKhECpqhrky9F03lqSC3HBH7Au2S36WLEl0QgNWNnh9o Pt9262WqDIlQP34+LlItjgXIN6tHXgeHgPZWYax+B/Wrfxx3zc/yrEhIyURoCZTrpqRN fhp4Zj33qSTO8yCfjI4Qy+FlHQPO4xMOpLaCEZ/hHyVaYeJq7mpaf7ZF6ZQj4GdR4Ey7 /L27L5j8xFdjjiHCfdDXk2C1niJuFhqJkqpd2hmRKcdszb9efmkLqRDLlsaZBJtoiQMR cZHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=fBD1OygWpf0jhZ+0kewBSUJ8FtX2ws5QC67s/CxpbU8=; b=TZeWbwAsUKOzKUA8RruaQLJFguwS2kgrrqfAuOo/qqtA7pXXJbZZEemCTEklwR0PNv kn61SP1ng5zIAN8jOCZWWZN+5mgOkJZZWb76PdAf2oPMNI05gHyUOM8iGA5L3fdhJp4H MYoEjxBL/Iv4YGLh1fKDdUIPTSbrLhU/mrCKjIiP0NYdLxipFs0qPyP/KknjcL6Or5wr MJgA44BArU3QeukmOHfRLEeFUqfUxxtNHcaRlgWpMiwLpIIlfwwU5XZgZEwafWoiVrJT XHLsUwTDWma5KBqFNKFfDwUAt9L0RbhUWo5U+fLcZr7orQAuCK0vF7Lx40A+3iQBxnBP A3Bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i198si40967721pfe.228.2019.08.03.20.45.18; Sat, 03 Aug 2019 20:45:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390476AbfHCMcC (ORCPT + 99 others); Sat, 3 Aug 2019 08:32:02 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4163 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390259AbfHCMcC (ORCPT ); Sat, 3 Aug 2019 08:32:02 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 7FB3845D03C61DAABD11; Sat, 3 Aug 2019 20:31:58 +0800 (CST) Received: from huawei.com (10.67.189.167) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Sat, 3 Aug 2019 20:31:51 +0800 From: Jiangfeng Xiao To: , , , CC: , , , , Subject: [PATCH v1 3/3] net: hisilicon: Fix dma_map_single failed on arm64 Date: Sat, 3 Aug 2019 20:31:41 +0800 Message-ID: <1564835501-90257-4-git-send-email-xiaojiangfeng@huawei.com> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1564835501-90257-1-git-send-email-xiaojiangfeng@huawei.com> References: <1564835501-90257-1-git-send-email-xiaojiangfeng@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.189.167] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On the arm64 platform, executing "ifconfig eth0 up" will fail, returning "ifconfig: SIOCSIFFLAGS: Input/output error." ndev->dev is not initialized, dma_map_single->get_dma_ops-> dummy_dma_ops->__dummy_map_page will return DMA_ERROR_CODE directly, so when we use dma_map_single, the first parameter is to use the device of platform_device. Signed-off-by: Jiangfeng Xiao --- drivers/net/ethernet/hisilicon/hip04_eth.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c index d775b98..c841674 100644 --- a/drivers/net/ethernet/hisilicon/hip04_eth.c +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c @@ -220,6 +220,7 @@ struct hip04_priv { unsigned int reg_inten; struct napi_struct napi; + struct device *dev; struct net_device *ndev; struct tx_desc *tx_desc; @@ -465,7 +466,7 @@ static int hip04_tx_reclaim(struct net_device *ndev, bool force) } 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; @@ -516,8 +517,8 @@ static void hip04_start_tx_timer(struct hip04_priv *priv) 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; } @@ -596,7 +597,7 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) goto refill; } - 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; @@ -625,9 +626,9 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) buf = netdev_alloc_frag(priv->rx_buf_size); if (!buf) goto done; - 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)) goto done; priv->rx_buf[priv->rx_head] = buf; priv->rx_phys[priv->rx_head] = phys; @@ -730,9 +731,9 @@ 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)) return -EIO; priv->rx_phys[i] = phys; @@ -766,7 +767,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; } @@ -909,6 +910,7 @@ static int hip04_mac_probe(struct platform_device *pdev) return -ENOMEM; priv = netdev_priv(ndev); + priv->dev = d; priv->ndev = ndev; platform_set_drvdata(pdev, ndev); SET_NETDEV_DEV(ndev, &pdev->dev); -- 1.8.5.6