Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1692529imm; Fri, 6 Jul 2018 04:59:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdnwqR3rftDMH5jbwR3RfmyP7A8OCaP/byWl3di40vJafbmvTtdmGb3ZYLZmDK/L1MKRgWy X-Received: by 2002:a63:9856:: with SMTP id l22-v6mr9385221pgo.208.1530878385715; Fri, 06 Jul 2018 04:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530878385; cv=none; d=google.com; s=arc-20160816; b=hfiYTh1FajSX8E3gfDP5DYh42w8smUHbg0HyDcrEtjd0Np3GKwegu5xes/T1pX7EVB im8WkOzhKWLUkay8/NdOmyBVnWfMhP1C3zm9fwb7iesPPsWpPZ9qw37Pqv0yoJ0iYCoJ yKtClKV2sT3Avfpk706KRUQQlOj9knHd53TxcXH4nryH3/NG4Z1MbF0e5r9ZqaCArPEw LiFh8F7BfXiiWeb5G36vD7EsQtdhSXzKnsVt58pDFrZv8VvgbQMTHMxI6SEQXjiOJFny Ame59Vdrpik7HDKcGPGHSeKnHhS0PuC/qILfuv5uKBZ9/foRmYlWDpTP3jC0EJOwjgWB FnPQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=VCbOuYkmdWRhkRJzKfHdEmfy6eiSnA+GJcvJsBENugg=; b=bO3OM8f8kCTQtxXkB2QPN4dIW+Q9qI7zy68bn5lMP10+o/eIQ20XE+I/BeqZOSyPym m6qHvy8YE2P1cqfV6EtxlT2iaMx6UWiTFaQZULpbL5u69iRvA0+kyZXL4VjZgv5d/6ay sKoU0DsZqtiRxAPOn/gEfqhMTwN6Uhieq1v1c4EiAwgR9n3tUuGVaLQ6v0uvW7pBE+if lKpsW3h9VXKrH5EVDBgk0NmUzShWMXrWossUOVvvc7Jb/zlScySfmc/aQnuwSQEPXGMZ ay5aYGHwp/CC4bntf11N3DdwzoOAgiqcH6DVDzC6Ljsz81kUNrKmr2I5EEvFBVwAu6T/ ti8w== 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 31-v6si7808826pli.45.2018.07.06.04.59.30; Fri, 06 Jul 2018 04:59:45 -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 S932925AbeGFL5S (ORCPT + 99 others); Fri, 6 Jul 2018 07:57:18 -0400 Received: from foss.arm.com ([217.140.101.70]:35328 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932630AbeGFL5R (ORCPT ); Fri, 6 Jul 2018 07:57:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 55D1418A; Fri, 6 Jul 2018 04:57:17 -0700 (PDT) Received: from [10.1.210.23] (e110467-lin.cambridge.arm.com [10.1.210.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 670F83F5BA; Fri, 6 Jul 2018 04:57:16 -0700 (PDT) Subject: Re: [PATCH] dma-mapping: Relax warnings for per-device areas To: Christoph Hellwig Cc: noring@nocrew.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, JuergenUrban@gmx.de References: <1f8262d206c6886072d04cc93454f6e3f812bd20.1530623284.git.robin.murphy@arm.com> <20180705193613.GA28905@lst.de> From: Robin Murphy Message-ID: <5811ebe5-b2bd-efc1-bf54-a8f05432c4f8@arm.com> Date: Fri, 6 Jul 2018 12:57:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180705193613.GA28905@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/07/18 20:36, Christoph Hellwig wrote: >> - BUG_ON(!ops); >> - WARN_ON_ONCE(dev && !dev->coherent_dma_mask); >> - >> if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr)) >> return cpu_addr; >> >> + BUG_ON(!ops); >> + WARN_ON_ONCE(dev && !dev->coherent_dma_mask); > > I think doing dma on a device without ops is completely broken no matter > what you think of it, so I very much disagree with that part of the change. > > Also while I don't think not having a dma mask is a good idea even for > a driver purely using dma coherent pools. If the pools really are on > the device itself I can see why it might not matter, but for the case > commonly used on some ARM SOCs where we just reserve memory for certain > devices from a system pool it very much does matter. > > There really is no good excuse to not set a coherent mask in the drivers. Right, I was rather on the fence about this - on the one hand it is objectively wrong per the API for drivers to call dma_alloc_coherent() without a prior successful dma_set_coherent_mask() call, but then I thought that in the case when they're *only* using it as a proxy for dma_alloc_from_dev_coherent() and explicitly don't want regular allocations from kernel memory to ever happen, then maybe it might be somewhat reasonable. But indeed I hadn't really given enough thought to the reserved-memory carveout case, where we definitely don't want to let a legitimate warning be hidden on a developer's machine but hit by users with different system configurations. Fredrik, are you happy to fix up your driver to initialise a suitable mask at probe time? Robin.