Received: by 10.192.165.148 with SMTP id m20csp555336imm; Wed, 9 May 2018 18:26:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqoP3+IyGZCMUQA7cSV9Cvb6YdfThLx84Z+dZiWuxNel5+M6FP/0dipdTAfN5FL/BpNWlf2 X-Received: by 2002:a65:4a87:: with SMTP id b7-v6mr14942600pgu.36.1525915618514; Wed, 09 May 2018 18:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525915618; cv=none; d=google.com; s=arc-20160816; b=mH55FgKr4j5YTy0FRPa5342ucAugeTQh8Tg6CXFTNSyMyLjLXqj1fZ33Po+msovQF8 xnrY3uFDescF442nw14AkiV5u0zPBB3tlEl5aFgZrT4udxCYM+sAEuhAxnC8zPVqNb7C pW0AvO7gh9ChscQEsc0FBs82rf/3RpXGZDN8FonHmRB78VlL+1ZWZPoLOdQlalKRPoAs Kv/SW5z0wg4KAAuqEPZlu7bAIw+FV9EhYWl7kZgi9sXhTpFvx2O41CqpeznzjBg+N3+E n4n2m/3Sy4RLglSL+VuskIgjDj8PhGniMQ9g9DyoocWp2zLBAwehxJxebjFcGu2TRk43 3ozA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date:arc-authentication-results; bh=M3NtIDOqjD4Nf2FPYi8J8upHrEsWzmILUOiOzPa1uJs=; b=uOGbs5ht+mSWjbLBY08Lwbo/PHR2b+vyKRYXUdEB/oiNJIb9R4FMWoWNZCDDTVp3Ie ziaWbL1Tlog94D6E2csZKZ/8fffjOeEKDbkvxHcyvrLyR2FfBSzshoR7CaKDPV0oC69H ybQTS+M2bBt6ia4hNEDJvBCriByeaXi1kcSnDJvTwvJpilhg20fmRSSDeTuPGQm+aAw1 ssa34rFrPNaceHXj6TZS/obAQQTPrPUoMAs0tGNWSjW1Vob+ng/iFLH1rgtMxUcki781 7DWjyqBAbxx+P5TZwfMcDQ3Q0+rMRuBKcizoFmMh+/6/A8Gt/vga2eRwd4c9bRaCXdSg biPA== 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 203si15248005pfc.21.2018.05.09.18.26.34; Wed, 09 May 2018 18:26:58 -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 S1756388AbeEJBZw (ORCPT + 99 others); Wed, 9 May 2018 21:25:52 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:58154 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756003AbeEJBZv (ORCPT ); Wed, 9 May 2018 21:25:51 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 2D53E22BF3; Wed, 9 May 2018 21:25:38 -0400 (EDT) Date: Thu, 10 May 2018 11:25:35 +1000 (AEST) From: Finn Thain To: Geert Uytterhoeven cc: "David S. Miller" , linux-m68k , netdev , Linux Kernel Mailing List , Christoph Hellwig Subject: Re: [PATCH net] macmace: Set platform device coherent_dma_mask In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 3 May 2018, Geert Uytterhoeven wrote: > > Perhaps you can add a new helper > (platform_device_register_simple_dma()?) that takes the DMA mask, too? Would there be enough potential callers in future to justify that API? It seems that there haven't been many in the past. I found four users of platform_device_register_simple() which might benefit. Mostly these call dma_set_coherent_mask() in the platform driver probe routine. drivers/gpu/drm/etnaviv/etnaviv_drv.c drivers/gpu/drm/exynos/exynos_drm_drv.c drivers/gpu/drm/omapdrm/omap_drv.c drivers/parport/parport_pc.c (Am I missing any others?) To actually hoist the dma mask setup out of existing platform drivers would have implications for every device that matches with those drivers. That's a bit risky since I can't test those devices -- that's assuming I could identify them all; sometimes platform device matching is not well defined at build time (see loongson_sysconf.ecname). So far, it looks like macmace and macsonic would be the only callers of this new API call. What's worse, if you do pass a dma_mask in struct platform_device_info, you end up with this problem in platform_device_register_full(): if (pdevinfo->dma_mask) { /* * This memory isn't freed when the device is put, * I don't have a nice idea for that though. Conceptually * dma_mask in struct device should not be a pointer. * See http://thread.gmane.org/gmane.linux.kernel.pci/9081 */ pdev->dev.dma_mask = kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL); Most of the platform drivers that call dma_coerce_mask_and_coherent() are using pdev->of_match_table, not platform_device_register_simple(). Many of them have a comment like this: /* * Right now device-tree probed devices don't get dma_mask set. * Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ > With people setting the mask to kill the WARNING splat, this may become > more common. Since the commit which introduced the WARNING, only commits f61e64310b75 ("m68k: set dma and coherent masks for platform FEC ethernets") and 7bcfab202ca7 ("powerpc/macio: set a proper dma_coherent_mask") seem to be aimed at squelching that WARNING. (Am I missing any others?) So far, this is not looking like a common problem, and I'm having trouble finding some way to improve on my original patches. --