Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2066943ybl; Thu, 15 Aug 2019 06:06:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtX/U6RlhNVpnEp+PM5+VSfSBK5WQw11f62F+5hwvu9FMVsq9EQEs9edIc55BG2aQ1IYd2 X-Received: by 2002:a63:5a4d:: with SMTP id k13mr3364436pgm.174.1565874387984; Thu, 15 Aug 2019 06:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565874387; cv=none; d=google.com; s=arc-20160816; b=eePfU12eO4YRVAvr6wbU8+AYwQV8TcNj5alzoC8vGbV1ky9krZJPDNSaJk+D8fKWIf Ve18r9iuJRpwqXKf8e0tAlH66RH0uBsjsbuZaMKycLOeSdSjA0ZzjwXSl3XjcC7QOtlY 2Bli54R5BWdIFi4hkNPbeXpTY7qw5ftgoYc6251lEHlgTAbYg9Q4RYIvRS9PJmmBtORN ELLco+XHON8L6XEre/JMBlZYSY1+g6xgMwJjFHjhZ/5ilLV5hFbZKU3iAmZRNWN2m/Iv X60JRkwP4wxlYtYsUS+SUpXYW8NrvbCUEywtMdAdleXghM6P7bC1ALX0H0s9Tvb6nC5o Y9iA== 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; bh=BSjuHGospjhTAPhByixBg0xp96YNwU2XqbdQvVoYKMM=; b=i5SuiEKCdBXirMLzRZRqot8d+Aeoap0mWLGmcJXjHsygbxsBfDXwha9JgI25c6IINF 1RF7ZvwdpCTcBGezvKHkU+RCGC9dv+ULDy5aQOsKF0NCloV3gTUh5IiUIoxXBkZreevC UAO0mo7GWKRVxvfXF+eyCL9npgDs6khnA3gL5/5n64lO1/LiHUgk8Ag7UqGkfFBghT/A T1gHsW/xnOOYl9SrvgkQNF3kf1vwkF5xHarOFcCmXdT7+s3/133GxwdhIOrehPS7LmGl E8jWg8SstCAXpVfXqRCle+36kfpL881V0PEaFEE1CJrplKzw9aMZ9q6qsUP+Q+K/hsaF gcqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uwl+0uYf; 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 d13si2020271pfo.33.2019.08.15.06.06.07; Thu, 15 Aug 2019 06:06:27 -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=uwl+0uYf; 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 S1732121AbfHONDc (ORCPT + 99 others); Thu, 15 Aug 2019 09:03:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:44204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732101AbfHOND3 (ORCPT ); Thu, 15 Aug 2019 09:03:29 -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 3B2B2206C1; Thu, 15 Aug 2019 13:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565874207; bh=05FKrWR8u7yXNSzvDhK14jodYXXtJLhq05DEOB370o0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uwl+0uYfDOJT/3Ymv4Xv86Es37VhW5Szs/xP6ombz3PRSN6J0RcO0roRJ6TqaUrJ4 WSmNGttTeaVHYBoDy9MKtrR1Llvej761IhslQEAv61f/O4h2cwf8/2SbbMxIjcxa/O n3hqpkpGHdq3IH3OCwePPEUClxHF6VmSJ+8p6W2E= Date: Thu, 15 Aug 2019 15:03:25 +0200 From: Greg Kroah-Hartman To: Christoph Hellwig Cc: Maxime Chevallier , Gavin Li , Laurentiu Tudor , Minas Harutyunyan , Alan Stern , Geoff Levand , Michal Simek , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Olav Kongas , Tony Prisk , Mathias Nyman , Bin Liu , linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/6] driver core: initialize a default DMA mask for platform device Message-ID: <20190815130325.GB17065@kroah.com> References: <20190811080520.21712-1-hch@lst.de> <20190811080520.21712-7-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190811080520.21712-7-hch@lst.de> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 11, 2019 at 10:05:20AM +0200, Christoph Hellwig wrote: > We still treat devices without a DMA mask as defaulting to 32-bits for > both mask, but a few releases ago we've started warning about such > cases, as they require special cases to work around this sloppyness. > Add a dma_mask field to struct platform_object so that we can initialize > the dma_mask pointer in struct device and initialize both masks to > 32-bits by default. Architectures can still override this in > arch_setup_pdev_archdata if needed. > > Note that the code looks a little odd with the various conditionals > because we have to support platform_device structures that are > statically allocated. > > Signed-off-by: Christoph Hellwig > --- > drivers/base/platform.c | 15 +++++++++++++-- > include/linux/platform_device.h | 1 + > 2 files changed, 14 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index ec974ba9c0c4..b216fcb0a8af 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -264,6 +264,17 @@ struct platform_object { > char name[]; > }; > > +static void setup_pdev_archdata(struct platform_device *pdev) > +{ > + if (!pdev->dev.coherent_dma_mask) > + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); > + if (!pdev->dma_mask) > + pdev->dma_mask = DMA_BIT_MASK(32); > + if (!pdev->dev.dma_mask) > + pdev->dev.dma_mask = &pdev->dma_mask; > + arch_setup_pdev_archdata(pdev); > +}; > + > /** > * platform_device_put - destroy a platform device > * @pdev: platform device to free > @@ -310,7 +321,7 @@ struct platform_device *platform_device_alloc(const char *name, int id) > pa->pdev.id = id; > device_initialize(&pa->pdev.dev); > pa->pdev.dev.release = platform_device_release; > - arch_setup_pdev_archdata(&pa->pdev); > + setup_pdev_archdata(&pa->pdev); > } > > return pa ? &pa->pdev : NULL; > @@ -512,7 +523,7 @@ EXPORT_SYMBOL_GPL(platform_device_del); > int platform_device_register(struct platform_device *pdev) > { > device_initialize(&pdev->dev); > - arch_setup_pdev_archdata(pdev); > + setup_pdev_archdata(pdev); > return platform_device_add(pdev); > } > EXPORT_SYMBOL_GPL(platform_device_register); > diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h > index 9bc36b589827..a2abde2aef25 100644 > --- a/include/linux/platform_device.h > +++ b/include/linux/platform_device.h > @@ -24,6 +24,7 @@ struct platform_device { > int id; > bool id_auto; > struct device dev; > + u64 dma_mask; Why is the dma_mask in 'struct device' which is part of this structure, not sufficient here? Shouldn't the "platform" be setting that up correctly already in the "archdata" type callback? confused, greg k-h