Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1988221ybl; Sun, 18 Aug 2019 15:39:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7CVxbIy/+8cjCu1CSqrn3PuROpSeMRPObdKvXxTwSElsDqk0tuclodlr1+LJdwoTnCoka X-Received: by 2002:a17:90a:be02:: with SMTP id a2mr17874580pjs.94.1566167992149; Sun, 18 Aug 2019 15:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566167992; cv=none; d=google.com; s=arc-20160816; b=ySvgDBVigwAW9cdjp3Fm/AYmVCd5dVR8rl6uHj970h43psfBGnPawP2a8xE98lgoBt 5XiuRtq2CKCdqWBxuv1UsXD6wn1Frpc367Clvv8UKN7yy4gKGZ5o+7BwAwO1eAUJtJWg tT/RmDt0WfNH4GtJFoTdfFNSyd2kGWwbsTE3jUld/ETpHOVcpWXL9WedJ/VnMsh0TqmX m+arHY7bmaZU68xkxGKT97l0ywcQ0A1M62vywr3aF1/V6x4tdde6benTWRm2/2r8XGo9 M37ovtNq5HoXVNfAzf5mb8FjMI6fWjPE6zwLv0Lzfk2t1wLBn1Y2EX0YvABaT7bgKrlu GDMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/TtI3E0eNUMp7j62i4ZzobFDeBI0jgRGvg+VFpMzmdA=; b=lY09OhSvs5nCljCt0gboAACXaByrUWWbfXiDhuxQBAzMOQ662UBYJuYHcZlpXQn2+v 36mzGASno1RQxzPolIuLUvymYyBiLCeY5hxVZpcY8rv2UFNvnHs8DEBEVKLY+13dgnQc g2X/IuNIz0ogAezkxWNRPOMjarhCakS9S0aPn4w0jkH5HG6IDCG8QFq86UCoQWShXfUt pIZxsivi1latAnld2WhdP4/UtTYBspc9uL/vPhGRp4KYfdHTQf+Y8N9KhzdrucaY+8MC /q5qoHv/E+WLmbZCE53lBOg7nhyYoQkj8LOkK8JlVAn0mk++Z4YF665qJJJnUCfYGBw4 mNXQ== 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 r4si8684477pgi.304.2019.08.18.15.39.36; Sun, 18 Aug 2019 15:39: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; 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 S1726291AbfHRWit (ORCPT + 99 others); Sun, 18 Aug 2019 18:38:49 -0400 Received: from mout2.fh-giessen.de ([212.201.18.46]:53830 "EHLO mout2.fh-giessen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbfHRWis (ORCPT ); Sun, 18 Aug 2019 18:38:48 -0400 Received: from mx1.fh-giessen.de ([212.201.18.40]) by mout2.fh-giessen.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hzTot-00006F-7x; Mon, 19 Aug 2019 00:38:39 +0200 Received: from mailgate-3.its.fh-giessen.de ([212.201.18.34]) by mx1.fh-giessen.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hzTot-00BKMq-28; Mon, 19 Aug 2019 00:38:39 +0200 Received: from p2e561b42.dip0.t-ipconnect.de ([46.86.27.66] helo=[192.168.1.24]) by mailgate-3.its.fh-giessen.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1hzTos-0003g0-O3; Mon, 19 Aug 2019 00:38:38 +0200 Subject: Re: regression in ath10k dma allocation To: Hillf Danton Cc: Nicolin Chen , Christoph Hellwig , kvalo@codeaurora.org, davem@davemloft.net, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, m.szyprowski@samsung.com, robin.murphy@arm.com, iommu@lists.linux-foundation.org, tobias.klausmann@freenet.de References: <8fe8b415-2d34-0a14-170b-dcb31c162e67@mni.thm.de> <20190816164301.GA3629@lst.de> <20190816222506.GA24413@Asurada-Nvidia.nvidia.com> <20190818031328.11848-1-hdanton@sina.com> From: Tobias Klausmann Message-ID: Date: Mon, 19 Aug 2019 00:38:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:70.0) Gecko/20100101 Thunderbird/70.0a1 MIME-Version: 1.0 In-Reply-To: <20190818031328.11848-1-hdanton@sina.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18.08.19 05:13, Hillf Danton wrote: > On Sat, 17 Aug 2019 00:42:48 +0200 Tobias Klausmann wrote: >> Hi Nicolin, >> >> On 17.08.19 00:25, Nicolin Chen wrote: >>> Hi Tobias >>> >>> On Fri, Aug 16, 2019 at 10:16:45PM +0200, Tobias Klausmann wrote: >>>>> do you have CONFIG_DMA_CMA set in your config? If not please make sure >>>>> you have this commit in your testing tree, and if the problem still >>>>> persists it would be a little odd and we'd have to dig deeper: >>>>> >>>>> commit dd3dcede9fa0a0b661ac1f24843f4a1b1317fdb6 >>>>> Author: Nicolin Chen >>>>> Date: Wed May 29 17:54:25 2019 -0700 >>>>> >>>>> dma-contiguous: fix !CONFIG_DMA_CMA version of dma_{alloc, free}_contiguous() >>>> yes CONFIG_DMA_CMA is set (=y, see attached config), the commit you mention >>>> above is included, if you have any hints how to go forward, please let me >>>> know! >>> For CONFIG_DMA_CMA=y, by judging the log with error code -12, I >>> feel this one should work for you. Would you please check if it >>> is included or try it out otherwise? >>> >>> dma-contiguous: do not overwrite align in dma_alloc_contiguous() >>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c6622a425acd1d2f3a443cd39b490a8777b622d7 >> >> Thanks for the hint, yet the commit is included and does not fix the >> problem! >> Hi Hillf, i just tested you first hunk (which comes from kernel/dma/direct.c if i'm not mistaken), it did not compile on its own, yet with a tiny bit of work it did, and it does indeed solve the regression. But if using that is the "right" way to do it, not sure, but its not on me to decide. Anyway: Thanks for the hint, Tobias > Hi Tobias > > Two minor diffs below in hope that they might make sense. > > 1, fallback unless dma coherent ok. > > --- a/kernel/dma/contiguous.c > +++ b/kernel/dma/contiguous.c > @@ -246,6 +246,10 @@ struct page *dma_alloc_contiguous(struct > size_t cma_align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT); > > page = cma_alloc(cma, count, cma_align, gfp & __GFP_NOWARN); > + if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { > + dma_free_contiguous(dev, page, size); > + page = NULL; > + } > } > > /* Fallback allocation of normal pages */ > -- > > 2, cleanup: cma unless contiguous > > --- a/kernel/dma/contiguous.c > +++ b/kernel/dma/contiguous.c > @@ -234,18 +234,13 @@ struct page *dma_alloc_contiguous(struct > size_t count = PAGE_ALIGN(size) >> PAGE_SHIFT; > size_t align = get_order(PAGE_ALIGN(size)); > struct page *page = NULL; > - struct cma *cma = NULL; > - > - if (dev && dev->cma_area) > - cma = dev->cma_area; > - else if (count > 1) > - cma = dma_contiguous_default_area; > > /* CMA can be used only in the context which permits sleeping */ > - if (cma && gfpflags_allow_blocking(gfp)) { > + if (count > 1 && gfpflags_allow_blocking(gfp)) { > size_t cma_align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT); > > - page = cma_alloc(cma, count, cma_align, gfp & __GFP_NOWARN); > + page = cma_alloc(dev_get_cma_area(dev), count, cma_align, > + gfp & __GFP_NOWARN); > if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { > dma_free_contiguous(dev, page, size); > page = NULL; > -- >