Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11810663pjo; Thu, 2 Jan 2020 14:40:56 -0800 (PST) X-Google-Smtp-Source: APXvYqzhjLwJefxR51htsn0dhJyzENDqLP2eIQgW7LsnBG91djXuvlSKfnW98JXupigQ+09gxJg2 X-Received: by 2002:aca:ed81:: with SMTP id l123mr3311937oih.129.1578004855972; Thu, 02 Jan 2020 14:40:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578004855; cv=none; d=google.com; s=arc-20160816; b=X+1HWj/tqowD1IxrbzPQf2RnqNI4aSGM9RL3FbnJ1YubG4M5yL+0ey6zAgRhM0qbJg khvXtNU7Lhmyhf/Nq+1+PSlLuQncvqG3ICERuUA31hnlGilfiFMka1oJ44G9UPWCpGu+ gmdwykPlkOxcLTu1bR8U1erwk95Zy/V3NgB1XQYZ08h4vK+xK0InRqX6hUx6P9pTsazv 1Ahx4FrCHJrwflLdSgq5Jbx+iZHJnZp7FngzUoIBz0UggwIuk1YNqANAawcLcZoKrLjr JTsbBdzOJTgRxssTm9a6VEllLztYJYQKf986g9h+95oQ/SSqonfsPlA3vMInTYsEmt4z 7Igg== 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=yKisVB17EU641mhtjzacPSG7T5g6ay32/khvLxLakbk=; b=DHj4Ime3Pf+UzrbA7B+ZrNZHolzCZGpg65/PMFk+3uc5Eh7B8QiXIUqLsOuyWoebR/ 4qGyYJnQu10O95t+RacsR+XJvN3MbS+aJAejHy0vnsiWBeOmzucgYBS4YCTQvOrPiep0 csEsSrSmqPq+Y3zbtZDYaojQmldmvcT29K/RbyT9yw1Ei+h7mH/NX1UMWJ/n8g0uBpVc f+PGTr+2nzr8G9XZCGmsRzWDIoBIcHMh3SKTMF8/NfvC7Dq5KAcffurKNDZXAxCm4Lwg k7jK3FOQrjdZKuaCoPwKh4X0TxVjrEykrZqixCmnOfZwPnZM0fEq1e0PuzmJ7L6QIAaw KShg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OPkY85Qf; 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 u12si21121597oiv.13.2020.01.02.14.40.44; Thu, 02 Jan 2020 14:40:55 -0800 (PST) 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=OPkY85Qf; 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 S1731364AbgABWi4 (ORCPT + 99 others); Thu, 2 Jan 2020 17:38:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:53788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731136AbgABWiy (ORCPT ); Thu, 2 Jan 2020 17:38:54 -0500 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 5D1D620863; Thu, 2 Jan 2020 22:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004733; bh=/g65bUBkUZz6J1YbcMzmMsnYXMy3bnSpWKDlcEJBmV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OPkY85Qf05aVWMFV6gAjw6ylcxXiXdrF11NwpLHY0PGKdX0qp9D5wuu/cg4oxt2C0 GZluzglvR9N99urCtTVHWgz0EzbE50bVigGcUlG09tiPdc/vafvVOYQcYRvCZAgib3 Cw3DB2Ua0k1hMPfzuKWw1/MKTyIqSmmQZKaIQhqI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , "David S. Miller" , Daniel Wagner Subject: [PATCH 4.4 130/137] net: davinci_cpdma: use dma_addr_t for DMA address Date: Thu, 2 Jan 2020 23:08:23 +0100 Message-Id: <20200102220604.672480604@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@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 From: Arnd Bergmann commit 84092996673211f16ef3b942a191d7952e9dfea9 upstream. The davinci_cpdma mixes up physical addresses as seen from the CPU and DMA addresses as seen from a DMA master, since it can operate on both normal memory or an on-chip buffer. If dma_addr_t is different from phys_addr_t, this means we get a compile-time warning about the type mismatch: ethernet/ti/davinci_cpdma.c: In function 'cpdma_desc_pool_create': ethernet/ti/davinci_cpdma.c:182:48: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types] pool->cpumap = dma_alloc_coherent(dev, size, &pool->phys, In file included from ethernet/ti/davinci_cpdma.c:21:0: dma-mapping.h:398:21: note: expected 'dma_addr_t * {aka long long unsigned int *}' but argument is of type 'phys_addr_t * {aka unsigned int *}' static inline void *dma_alloc_coherent(struct device *dev, size_t size, This slightly restructures the code so the address we use for mapping RAM into a DMA address is always a dma_addr_t, avoiding the warning. The code is correct even if both types are 32-bit because the DMA master in this device only supports 32-bit addressing anyway, independent of the types that are used. We still assign this value to pool->phys, and that is wrong if the driver is ever used with an IOMMU, but that value appears to be never used, so there is no problem really. I've added a couple of comments about where we do things that are slightly violating the API. Signed-off-by: Arnd Bergmann Signed-off-by: David S. Miller Signed-off-by: Daniel Wagner Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/ti/davinci_cpdma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -82,7 +82,7 @@ struct cpdma_desc { struct cpdma_desc_pool { phys_addr_t phys; - u32 hw_addr; + dma_addr_t hw_addr; void __iomem *iomap; /* ioremap map */ void *cpumap; /* dma_alloc map */ int desc_size, mem_size; @@ -152,7 +152,7 @@ struct cpdma_chan { * abstract out these details */ static struct cpdma_desc_pool * -cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr, +cpdma_desc_pool_create(struct device *dev, u32 phys, dma_addr_t hw_addr, int size, int align) { int bitmap_size; @@ -176,13 +176,13 @@ cpdma_desc_pool_create(struct device *de if (phys) { pool->phys = phys; - pool->iomap = ioremap(phys, size); + pool->iomap = ioremap(phys, size); /* should be memremap? */ pool->hw_addr = hw_addr; } else { - pool->cpumap = dma_alloc_coherent(dev, size, &pool->phys, + pool->cpumap = dma_alloc_coherent(dev, size, &pool->hw_addr, GFP_KERNEL); - pool->iomap = pool->cpumap; - pool->hw_addr = pool->phys; + pool->iomap = (void __iomem __force *)pool->cpumap; + pool->phys = pool->hw_addr; /* assumes no IOMMU, don't use this value */ } if (pool->iomap)