From patchwork Mon Jul 10 15:14:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 107304 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3555086qge; Mon, 10 Jul 2017 08:15:16 -0700 (PDT) X-Received: by 10.84.129.12 with SMTP id 12mr18836218plb.242.1499699716352; Mon, 10 Jul 2017 08:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499699716; cv=none; d=google.com; s=arc-20160816; b=RRx2XlKrobKRiCuKtrvtEtInqnI7txZrr2fteoDwNFQxt1O3AsDI3A7/CLT4e7UwSM ca4UnbkSUWeQI2w81kBPL8cz4EPj/2TkkLRAI7Vr0ZY8cMix1bK9whDy/XpQh3JTWUhC OLn3ZOp3VvzLVWXIA3O3WvdX6CDaKFHDGye5e0VJ1Pec5bUrfTOk464BUtD+x8x2IifG 6qpU7YZwbxa1DPCUK13A1kh+3sBrOf/ELYE/uBHu34LXLnkG5s0K6+NQPcttE0y3Fup9 4Rc1GWuYy/suHXrHmA5CrYhJGZOvq1u8Epqkoj4h+TWrQzd+gAbP1VE9Db8jNEV1ELAc I6LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=54kkv1cI7hLVclh7xcdGH4b9gl5xyo08mKBym3NYWSk=; b=BAiFr3zrWJ53EEfC7zJpEP3KiYVfW1s0jwFUeh0SCysDUZ8d6M59yaVbA3eG+cTOYw KPqK6nhkyBdh1RHiyOBGs9bLPR5B+KMU/LzFW1TmPhkQvt3dTZ1o+6cu6QQVDDuPRhMS Z+9Wx3CAcKoB+soTWk9kcpVOoivqFRO+68Nsk4odK4aGifOil4N7MDd0xgQEe48nL7cr 9pgBAC1ZJaGUq/a1qgGybb5tyuiXSfJRV3y/Oovke2/EoNxmqr7XeU1jA4N53Xb7S/Xx eFC2gai1Aq8ehVM/VQa3J4pPuiHkq8jK+ddbMGXPTIVCsaT+STYeDhc1s25WQJiSmE1f yfbA== 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 i2si9341269plk.467.2017.07.10.08.15.16; Mon, 10 Jul 2017 08:15:16 -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 S1754276AbdGJPPO (ORCPT + 25 others); Mon, 10 Jul 2017 11:15:14 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:60239 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753245AbdGJPPM (ORCPT ); Mon, 10 Jul 2017 11:15:12 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0LfSYr-1e1B7J17Av-00p6Ga; Mon, 10 Jul 2017 17:14:56 +0200 From: Arnd Bergmann To: Madalin Bucur Cc: Christoph Hellwig , Marek Szyprowski , Robin Murphy , "David S . Miller" , netdev@vger.kernel.org, Geert Uytterhoeven , Arnd Bergmann , Camelia Groza , Claudiu Manoil , linux-kernel@vger.kernel.org Subject: [PATCH] dpaa_eth: use correct device for DMA mapping API Date: Mon, 10 Jul 2017 17:14:27 +0200 Message-Id: <20170710151447.2814348-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:EFfajtYFAf5oM1xRUr16XjeUZLpUzqD7YZF0FB5x/BQic3S5oRB L6mJi8nJlXc7kz59NZcfqwCS2mGz+zq0vdtldZfkFF2HdDeLepHxUGvfJdp5KyE+W3I4gKP /GHwxAAwqPcCcqKXyYeh9mOs023jdOL83TBdoDsw2xroAVe7CMSM9ncrr1gcsf/Cmt7VzaK pV4HV9HeYwiHmeqkw5I6w== X-UI-Out-Filterresults: notjunk:1; V01:K0:tz9YlwgIU1s=:DXFdYfrqY2KjfTz09zNITA ve3Zehb1ibxYF03QQ+Q9tq04i3oXh+/EOamLiejSXwX9nIcZmQMEh2hYV9FwTUF9hZl1HLU83 nmpYwTTeWd76lGu9fKxqV5VxQSuBdFrMN6ju4g6UX/ffNGMGmgI7pw2uAZQOhM+qTvMo1m+0g V2rxqnh9lGYdOCPTPq8S8zA8a2GV1gVheXQSgc3cDDpqoqOiPqH4UZbsb0kdJX2H5Z7CUKxXr I7OWXw3+FBDaUlxsNR6pEmnXAof1UitGwNpXxOI2ew+DRU5C2jO4KNbUkZKNiIIFwKFdtg8kd rEOw+yFLNlHdKsBSDgXQ7DZyb3OM6RpyzvfZTJrwEmqHXAARQfTyillBkdgzhTo0nUXnjl8D8 pdo22csyluhslqwQl2EQQdO+kdTz3cWDztxL48Bbn7tPpddrBh/1xfm1568j+FFhCvtyd/kCS y6VBelH3KXtKlo/mjwdwDu35qgD79WQaGN5uyJi2ksAljg3ZnvmUS6qp32AE7WSKX+pZJcNzc W8PNuwrFtDZYXRFlEWkUYEHH4VFrUCMrxe5aNjeEvMaXpPNeWq+ld+0TfV1l2dxq28PwAiWcw Ci63b2CYL3v1/u3PYM9L2g66FY+sbZHobevnbISgK4o0Jh1ICHQ8vUl0Ir+fyqLOjAY0ic/GS MzAVXZoVA1bLSA9P6Wqo44YlMTEayE4949e4wILzmKUJmHOrC/HvVKC+LL0hhh8dyJRQ= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Geert Uytterhoeven ran into a build error without CONFIG_HAS_DMA, as a result of the driver calling set_dma_ops(). While we can fix the build error in the dma-mapping implementation, there is another problem in this driver: The configuration for the DMA is done by the platform code, looking up information about the system from the device tree. This copies the information only in an incomplete way, setting the dma_map_ops and forcing a specific mask, but ignoring all settings regarding IOMMU, coherence etc. A better way to avoid the problem is to only ever pass a device into the dma_mapping implementation that has been setup by the platform code. In this case, that is the parent device, so we can get that pointer at probe time. Fortunately, we already have a pointer in the device specific structure for that, so we only need to modify that. Fixes: fb52728a9294 ("dpaa_eth: reuse the dma_ops provided by the FMan MAC device") Signed-off-by: Arnd Bergmann --- Not tested, please see if this works before applying! --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) -- 2.9.0 Acked-by: Geert Uytterhoeven Acked-by: Robin Murphy diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 757b873735a5..f7b0b928cd53 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2646,14 +2646,6 @@ static int dpaa_eth_probe(struct platform_device *pdev) priv->buf_layout[RX].priv_data_size = DPAA_RX_PRIV_DATA_SIZE; /* Rx */ priv->buf_layout[TX].priv_data_size = DPAA_TX_PRIV_DATA_SIZE; /* Tx */ - /* device used for DMA mapping */ - set_dma_ops(dev, get_dma_ops(&pdev->dev)); - err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(40)); - if (err) { - dev_err(dev, "dma_coerce_mask_and_coherent() failed\n"); - goto dev_mask_failed; - } - /* bp init */ for (i = 0; i < DPAA_BPS_NUM; i++) { int err; @@ -2665,7 +2657,8 @@ static int dpaa_eth_probe(struct platform_device *pdev) dpaa_bps[i]->raw_size = bpool_buffer_raw_size(i, DPAA_BPS_NUM); /* avoid runtime computations by keeping the usable size here */ dpaa_bps[i]->size = dpaa_bp_size(dpaa_bps[i]->raw_size); - dpaa_bps[i]->dev = dev; + /* DMA operations are done on the platform-provided device */ + dpaa_bps[i]->dev = dev->parent; err = dpaa_bp_alloc_pool(dpaa_bps[i]); if (err < 0) {