Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4053599imm; Mon, 14 May 2018 01:43:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpNaUHbXh9CHygOul5wIKEg8vQBkG2fMAJ2E+JTBo/o+a3znGd91RwWhK6uTh8Ix1Q2N08C X-Received: by 2002:a63:9846:: with SMTP id l6-v6mr7644396pgo.217.1526287432299; Mon, 14 May 2018 01:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526287432; cv=none; d=google.com; s=arc-20160816; b=GdqCT1IW1+hIQ4JSleNIAcKrEBcsmt0/s8s4r5n31vlzRM9CHXbyEIxOpaWAaouT9t pD6DvxfKePAV+Hx9jRMvCEPWnafzAdFGW/AQFR5lNpo/UPho4i/x8aR2org/tNYH6uUa 5VuiOz7xUjkMi+8cgCpSczXlDKw3GLY+coaqg9Or4L7Vk5D9FRqC2tZ/BYdaAc+7BKdg w2dGvsE5ERCdOKGX/ir/GOxcGT1c5h+Sz65pyCTLJLD/wwz6yyGaeXh0rK20PA/8WbGs x9xKR7G5r1YBFvG87ydno4Kf4dsWJ3ZW9Ue7gnWjDKJuJDjAaZt9hI1CGd1EvShjJKLO cD7g== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=KMJhAC+f9MyQ5B2sji+l1/YT0VcWtaLq30SzjqWx/Mw=; b=WsI0xpwgQxzhHZZWhI5Mr0q9cbaIUdaz18qtP/zxobn4cEgunDudEVPE30b/ejMGHR o048os8EwtxCF9iUi9tMyqJwiTDsT4RLacIjbjt1cxF/9Vw1wnxhkdpgopMpcjXpiyrD /bMAMzu9CqcXIT42NsAVCWfUrZBQ6xUAPgLLN2jtYhE1MOTmB5rANXzWwkFRg9AkKVY9 g7GiXY0Mt0wr7xIVjAiBchUdaCVBrKBgbqkYBKeJrLMc2ofAZHs3oG8lkLUXInUkXICX xs8rP14uyvN1Gho3LEf6NfqjVdxrdIfqJcf2Cmbvl0+vp8iXNIFtq83Q8Hq7/zNljwcW AqJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lVjVC5aw; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si9203744pfa.170.2018.05.14.01.43.25; Mon, 14 May 2018 01:43:52 -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=@gmail.com header.s=20161025 header.b=lVjVC5aw; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbeENInO (ORCPT + 99 others); Mon, 14 May 2018 04:43:14 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52256 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752017AbeENInL (ORCPT ); Mon, 14 May 2018 04:43:11 -0400 Received: by mail-wm0-f67.google.com with SMTP id w194-v6so11918251wmf.2; Mon, 14 May 2018 01:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KMJhAC+f9MyQ5B2sji+l1/YT0VcWtaLq30SzjqWx/Mw=; b=lVjVC5awnProl88u8YtntRdzTquvAIroh0RU/ZuYa0XjMofyMEiFXRi1NCuIrmuvhn EvyDynw5RJjY8SpfOvsy6dTVGpCQ4sA804LiDn2aMFnluIINWYJljDY3jbY631yKnzC3 3siA8MT48+UfMR51ksux7z2POv5iyvKjvOl+Jv2/DPasfxJBPLyjbBaF1hvi2f3P+ttL 1rjie0WAgK7ICDBueNFQKReKX4/l9ulwfpXFcZiqHMgHwSdv6+7ANFFznl4AA0S7ivwL FCmzDdpfIHqXNXTz7/rVYEJm0wbKlRvXv2dtprnhCunQY2wOUvqKk6jq2ehwVf8mOMB8 Ek6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=KMJhAC+f9MyQ5B2sji+l1/YT0VcWtaLq30SzjqWx/Mw=; b=i5C93zOEjqQBKYsvPQhdXQzF4mB4h34Wm5WhDe8r27TuxtfBM5gicgoniMT+imjWf9 ep4Oxq1uNYeUGWkfBcSGHBGfpvSL3DqcdUNxpCGuezwIrxYpKrmFd4Y8s1aMo3JGg2xq r8pGR9KomBud2GHm0HyuJQJlW6PItij8AljVlluZP6gRcjRe0E0jRvnCylrx2IXHJ7BC dgSemgZpKR8oPxrcHF5Uv4M23/Zw1B+YHWGchsJ2qlq8TWEw6FLvZRgcXzPFdzY7zEiZ /dQyVaUiaq2rQePjfIicXKP7wL3Fw1BYYQsqEO2z03VUrpT0YJzlDVtB4vhcXAZtTdjc Gv5A== X-Gm-Message-State: ALKqPwfSXqodSbHvZ3jLzfBHlTM+eUMf72IPv+C9lDHLOiZRzYkLUHJK 6CPG0AKFLTOGXkT/UI/KrKE= X-Received: by 2002:a1c:8444:: with SMTP id g65-v6mr5092135wmd.114.1526287390028; Mon, 14 May 2018 01:43:10 -0700 (PDT) Received: from localhost (p200300E41F19FC00D958180F3872A5C5.dip0.t-ipconnect.de. [2003:e4:1f19:fc00:d958:180f:3872:a5c5]) by smtp.gmail.com with ESMTPSA id h81-v6sm8608948wmd.0.2018.05.14.01.43.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:43:09 -0700 (PDT) Date: Mon, 14 May 2018 10:43:08 +0200 From: Thierry Reding To: Emil Goode 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: <20180514084308.GA18312@ulmo> References: <20180326144314.xeuocqp5fjpfjm3q@lianli> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bp/iNruPH9dso1Pn" Content-Disposition: inline In-Reply-To: <20180326144314.xeuocqp5fjpfjm3q@lianli> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 26, 2018 at 04:44:14PM +0200, Emil Goode wrote: > The compiler is complaining with the following errors: >=20 > drivers/gpu/host1x/cdma.c:94:48: error: > passing argument 3 of =E2=80=98dma_alloc_wc=E2=80=99 from incompatible p= ointer type > [-Werror=3Dincompatible-pointer-types] >=20 > drivers/gpu/host1x/cdma.c:113:48: error: > passing argument 3 of =E2=80=98dma_alloc_wc=E2=80=99 from incompatible p= ointer type > [-Werror=3Dincompatible-pointer-types] >=20 > 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. >=20 > Signed-off-by: Emil Goode > --- > drivers/gpu/host1x/cdma.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > 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 *p= b) > =20 > size =3D iova_align(&host1x->iova, size); > =20 > - pb->mapped =3D dma_alloc_wc(host1x->dev, size, &pb->phys, > - GFP_KERNEL); > + pb->mapped =3D dma_alloc_wc(host1x->dev, size, > + (dma_addr_t *)&pb->phys, GFP_KERNEL); > if (!pb->mapped) > return -ENOMEM; > =20 > @@ -110,8 +110,8 @@ static int host1x_pushbuffer_init(struct push_buffer = *pb) > if (err) > goto iommu_free_iova; > } else { > - pb->mapped =3D dma_alloc_wc(host1x->dev, size, &pb->phys, > - GFP_KERNEL); > + pb->mapped =3D dma_alloc_wc(host1x->dev, size, > + (dma_addr_t *)&pb->phys, GFP_KERNEL); > if (!pb->mapped) > return -ENOMEM; > =20 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. 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. Thierry --bp/iNruPH9dso1Pn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlr5TBkACgkQ3SOs138+ s6G56g//VpYNFTGEXoQtF3mu6srEPteFaOn/GAVW/kBSUvL+ujF7mZQYM67KdBPH /ZxRkc+2oCZ025a91uVMWj8Qz8H3hUlSEZx4Ep7OQrJqlL9FO8cROnfAKt0Xq6zT PYsQGPecBeGURZ3G+QDT5gb3DBLdzF7GoTO0Aj7wrzG1A0QHqtgjcvQj1vhxrDPw T1iOZpax8iZdmZwLJRmGmGi/TUPd9LghmSy7Uy3zFwxU3Fzue9Y7qZ+jdtImD4bJ 6ZkkVTyz2cbuUQo3P7nU6ic2LXnr8LTPCuIvKHN/OSjQWUOOhCWf/i0uS/qLlNeU RulA6dvHr29QqAFITwvULHApPTxz8u4Hu0lsvISWyIkXNUeg9iRmravS2JqDHFRp upFEdX3tdlFJFtlveIvBfuoCHwWQrzhGK4dIC4x2XMxBz5MPuvDMyAIil0HUCj6W pOLsbn57GKe9jr5UlpNNUFpm0epbNj/kIRVV6lsMoHzUQYwDyBNVyeWPpp04Ldov yRG+O4KG9ejXPkQp2X5vtl+zvFMx64ENVYISywbd9s7963+u96VyV8UgKmC/3bOO T+gZ9TOiTjWv0xKe3PmpHbaHxhgWmrO0V8uVCA/kNzhXfpTUEE/TLI0WZoQuRRzW iU4or6UysrLgMBl8lQTS35qgruAjQM38VxOeCai9DiIQHb4BTBQ= =Q7XC -----END PGP SIGNATURE----- --bp/iNruPH9dso1Pn--