Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5214556ybl; Tue, 27 Aug 2019 00:55:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg4QU59Ly5R4ffGEaEp3XTiF8+jF7Ny5jJvs4ChTX2qIAoI93SANhS29+wTRDcwHER3+di X-Received: by 2002:a17:902:fe11:: with SMTP id g17mr23787813plj.154.1566892520992; Tue, 27 Aug 2019 00:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566892520; cv=none; d=google.com; s=arc-20160816; b=GMZlQJ/6IUYUibODj/qkO0P4Y+EWkeXk3TJ4D5ZGc5acocreTx7BHea5+clzZHviaF ab2OW/1we3qpZp4EWzhTcSQ0RZiZC6Zh/G24mLgDjPkZCmffbztAcbd4t6cWB0KY/tON /ajQdQxZ5kYSpzd3hE95aYYDXn01frQDcQ2REIB8Vnky8/NeFHnsLd0d89xkOeo3qQ1v sAUU/22QlyyLBI71z5wp1DWi3SG+KHrVVrO8D07Fo4Ahd1WGP8cluU0mno6lMThJDwRX tmLo9HwZonSVkH/p/sLHqrbE89k0f2ZubXIQd867VVEV/gWZx2IfknuChMigQkMSMDFm sEMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9XxDMUc24Mj8kWMzmD4zTW+RlcgNkKaFPiYqjBLuiCE=; b=DgzGeTojv8wzRJRRgv+QmE0/uDM+LeuOwXMvG9b9TVf3Cm4n9Rw6yZ16zS/G3FbGrP Jf7Cx6MwrEXwPq58cKq/DsoJn38aQJTsROuLe9oVdyOT7+P9EqVcN869A2ME9ybXk+S2 I3C1JizZGj19l3YuhenS/jWrnRWyhEMz9jgMJKbe7Ah+wJBnTgupoLkbUkd/n/JHotd0 vMAElU5NpM3e11RSDlYqYye81Xfus+0J5viqLCk/MJdat+jTl7yBQ6Na+pOGjeflJFie UwftT+QUpIBG5oEWWWcUMrF3IG00kdbQRmv6phEJeG2Nw+6XeIuDn7Bjqe2C5EoDyqho v8Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=orU6brb7; 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 d8si11953252pla.206.2019.08.27.00.55.06; Tue, 27 Aug 2019 00:55:20 -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; dkim=pass header.i=@kernel.org header.s=default header.b=orU6brb7; 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 S1729548AbfH0Hwl (ORCPT + 99 others); Tue, 27 Aug 2019 03:52:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:44040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729512AbfH0Hwi (ORCPT ); Tue, 27 Aug 2019 03:52:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 666CB2173E; Tue, 27 Aug 2019 07:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892356; bh=3htwOyT7gj/2/HR4EphNQ7N5LbhlPmyp74pPeOdykV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orU6brb7RXIzGcG6ebqfrDTflnh842WmwgBjO4GFOolTNU3WWdw19PPOXmzpX5uuh 1k5KmoyU5zcQhalYgHpTQMaX5Jgre6QVM2rh9flNO+SF0AVINAOW7G9EYTyjqVMBGM qzDH4/eXMq/IoFKTjW4/+h99HPcvcVeD44l4AmhQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiangfeng Xiao , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 27/62] net: hisilicon: Fix dma_map_single failed on arm64 Date: Tue, 27 Aug 2019 09:50:32 +0200 Message-Id: <20190827072702.038855544@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072659.803647352@linuxfoundation.org> References: <20190827072659.803647352@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 96a50c0d907ac8f5c3d6b051031a19eb8a2b53e3 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 b04fb82d7fa3e..1bfe9544b3c10 100644 --- a/drivers/net/ethernet/hisilicon/hip04_eth.c +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c @@ -157,6 +157,7 @@ struct hip04_priv { unsigned int reg_inten; struct napi_struct napi; + struct device *dev; struct net_device *ndev; struct tx_desc *tx_desc; @@ -387,7 +388,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; @@ -437,8 +438,8 @@ 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; } @@ -508,7 +509,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; @@ -537,9 +538,9 @@ refill: 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; @@ -642,9 +643,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; @@ -678,7 +679,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; } @@ -822,6 +823,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); -- 2.20.1