Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1118937imm; Tue, 15 May 2018 14:09:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp+Yaw3ZUIvPAWj+ZJ6Rr0fSQAglQvfg8eOjfJP0kQG+mp3SxXWIMFAx0vk8jzArkzv+zuo X-Received: by 2002:a62:8910:: with SMTP id v16-v6mr16479199pfd.13.1526418581042; Tue, 15 May 2018 14:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526418581; cv=none; d=google.com; s=arc-20160816; b=fZpFhbmuTivCP0h5iUwcD26z2oCRkOOvU2Bg6v375WQlgv1Y9WVkUcW89pGqHP730M Fs5Hb/gb7SedA+4Sdg1lWNQio/5rPe82mAWE3zr5ZhIvbDghsFV8xwhtKrO4VZ0yw0wb jjpfHYTQEn/Aj3SdsGEhEDQ7Vcs/t1gKp5BGaoWVR1Neay6LZSCDtJ74jXzPeZMO6YNr OAaEnsdf1LFbORw//N1fVSWkjPCdFozgNhP01WX1DJa/DsodkzmmEpNw/83xGT6g/FQv qKtfWI1Grkz2ClK4P3BybhxGB73AjIe69XAiNMIlTUSlSMJXMWr3L+N42lCJRrfN/W9a akGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=NGBR2RP0+50JwFNLdxFRGsoojYzpoGiVzpafJMGHmm4=; b=DF6s2fDPkCTHYjPsHwYffwghSl3hi15pW70LmILfYwF/g9kTHaiQUMhYYSm8Zyq+Cv eSuxfDKUQ9/H0HCZUwfIHvsfi5pN3UhxYDPmFaPTdcVD7YFD/kIw/XrCwk21yaR8x3UF 89AVMgIF2MDQr8t3sK/cXdWseLLLZ86O8oX4h6umUiAeGtRBiGOiASqcFo0T64VnbAhg 3/37c8PCcjt2c8TS6DMWiP23VcjSu4MEDcmkcrv4wlETc3DuEV9yUuM/87mg6qBcCFfS ph55OpTduhFoj1B1z5kupoWbA0zIKZUq7po+gvUT5/Ss5FzItBbKRjpb3c4mvVKfaAhz QkCA== 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 e37-v6si904041plb.400.2018.05.15.14.09.25; Tue, 15 May 2018 14:09:40 -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 S1752629AbeEOVIC (ORCPT + 99 others); Tue, 15 May 2018 17:08:02 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:37072 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752289AbeEOVIA (ORCPT ); Tue, 15 May 2018 17:08:00 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 36B76C1032; Tue, 15 May 2018 21:07:59 +0000 (UTC) Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo01-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5FYfNga3TyoS; Tue, 15 May 2018 21:07:59 +0000 (UTC) Received: from lianli (31-211-236-16.customers.ownit.se [31.211.236.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 24A62C1000; Tue, 15 May 2018 21:07:49 +0000 (UTC) Date: Tue, 15 May 2018 23:07:30 +0200 From: Emil Goode To: Thierry Reding Cc: Thierry Reding , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] gpu: host1x: Fix compiler errors Message-ID: <20180515210729.qtokt4zjlrbzdkem@lianli> References: <20180326144314.xeuocqp5fjpfjm3q@lianli> <20180514084308.GA18312@ulmo> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180514084308.GA18312@ulmo> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Mon, May 14, 2018 at 10:43:08AM +0200, Thierry Reding wrote: > On Mon, Mar 26, 2018 at 04:44:14PM +0200, Emil Goode wrote: > > The compiler is complaining with the following errors: > > > > drivers/gpu/host1x/cdma.c:94:48: error: > > passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type > > [-Werror=incompatible-pointer-types] > > > > drivers/gpu/host1x/cdma.c:113:48: error: > > passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type > > [-Werror=incompatible-pointer-types] > > > > The expected pointer type of the third argument to dma_alloc_wc() is > > dma_addr_t but phys_addr_t is passed. Fix this by adding casts to the > > expected pointer type. > > > > Signed-off-by: Emil Goode > > --- > > drivers/gpu/host1x/cdma.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c > > index 28541b280739..5e8b321a751e 100644 > > --- a/drivers/gpu/host1x/cdma.c > > +++ b/drivers/gpu/host1x/cdma.c > > @@ -91,8 +91,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb) > > > > size = iova_align(&host1x->iova, size); > > > > - pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys, > > - GFP_KERNEL); > > + pb->mapped = dma_alloc_wc(host1x->dev, size, > > + (dma_addr_t *)&pb->phys, GFP_KERNEL); > > if (!pb->mapped) > > return -ENOMEM; > > > > @@ -110,8 +110,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb) > > if (err) > > goto iommu_free_iova; > > } else { > > - pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys, > > - GFP_KERNEL); > > + pb->mapped = dma_alloc_wc(host1x->dev, size, > > + (dma_addr_t *)&pb->phys, GFP_KERNEL); > > if (!pb->mapped) > > return -ENOMEM; > > > > This doesn't seem right. There's no guarantee that phys_addr_t and > dma_addr_t will be compatible, so the above isn't always correct. Also, > I don't see a need for pb->phys to ever be phys_addr_t. It's allocated > through dma_alloc_wc() exclusively, so it should just be dma_addr_t. I agree that this is a better solution, however when changing pb->phys to dma_addr_t the type will be wrong when it's passed to iommu_map() as phys_addr_t is expected but that doesn't cause a compilation error. > Note that the !pb->phys check in host1x_pushbuffer_destroy() becomes > technically wrong if pb->phys is dma_addr_t (0 is a perfectly valid > value for dma_addr_t), so make sure to flip that to !pb->mapped instead. > pb->mapped and pb->phys are always set in tandem, and checking mapped > for non-NULL is the right check to test whether the pair is valid or > not. Ok I will change this as well. Best regards, Emil