Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2389838ybt; Fri, 3 Jul 2020 07:56:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+E4ZfpiAkpYgmLGWLnC55FgQbvdlgu84bmbC4FXjfyGyDtVXDM8/S0cbWUUaXVrJgHSW2 X-Received: by 2002:a17:907:9495:: with SMTP id dm21mr32390803ejc.357.1593788208471; Fri, 03 Jul 2020 07:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593788208; cv=none; d=google.com; s=arc-20160816; b=wVizptTELNYuBY0wB2EcKbBMLIYmVTYBuxlEWaM0l5A32x61LxALx5NMVb5DtTOfOO tBsXV+8UcsPsQnyWD8ecEMfnoJizsF34WIvlSeQ/CC23KSqCa81xRefetMw6JG5q31z2 CG9uqaKxkr1xTWjzDLRb05IDgOebVIxRlrENJwi0s3Rf6bdEyZIsYX9RmaHm+zSCJ/it 6rQk04rlKzX0YEsaFoccertS25KfL8SwA6WDY076pF6chSbV6T9HPWM/HpiKuGiwYuxf oPH2emugi0InFcImi+9wRpmQth+N6mm7CKBlHPcJco1+AYJ0WkrywhYGX2FE4oTdEY1I EOLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=ovqyT1zb1bPH4oZR0/fX6yef1sWZh1LYT4QdHLF/Fk0=; b=N3Ab1vT7oEvpwVH7V9DBX0ExWAUkgHG3LHbrulnRlpnQVALBdo1GD80mklGL8mWuJa cvN6QQ/JDnn4lcy5N4lD4TI7z/5rKknc9dWLscke6Xeqx6IN6NvmdNhKJPsNv80cI7LF sQbsUu/xFjYtHByVF6aui7xSSBXF0RuGfLBingkh27xyc2oU6Q7iIT9qu20DZVcmxC+u e/nKUp4PUX03bpqBChFKyUUobrlUhEtD4wjpH9oCykfXhlFB/+5P+cDtz2d0B7TLirrQ cQp/knK32RCP4yMTmkEUjF+4T3AA/J8DQPxWFN9D3IsGD7X/ysi9HgNAt14x2z6hRIaL pUiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si7805531ejd.356.2020.07.03.07.56.25; Fri, 03 Jul 2020 07:56:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbgGCOxt (ORCPT + 99 others); Fri, 3 Jul 2020 10:53:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:60512 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgGCOxs (ORCPT ); Fri, 3 Jul 2020 10:53:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2C652AF69; Fri, 3 Jul 2020 14:53:47 +0000 (UTC) Message-ID: Subject: Re: [BUG] XHCI getting ZONE_DMA32 memory > than its bus_dma_limit From: Nicolas Saenz Julienne To: Jeremy Linton , "linux-arm-kernel@lists.infradead.org" , linux-mm@kvack.org, "linux-usb@vger.kernel.org" , rientjes@google.com, Christoph Hellwig , "linux-kernel@vger.kernel.org" Cc: linux-rpi-kernel Date: Fri, 03 Jul 2020 16:53:45 +0200 In-Reply-To: <34619bdf-6527-ae82-7e4d-e2ea7c67ed56@arm.com> References: <34619bdf-6527-ae82-7e4d-e2ea7c67ed56@arm.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-jPh4P4ef6IRIm8gZjo2Z" User-Agent: Evolution 3.36.3 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-jPh4P4ef6IRIm8gZjo2Z Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jeremy, thanks for the bug report. Just for the record the offending commit is: c84dc6e68a1d2 ("dma-pool: add additional coherent pools to map to gfp mask"). On Thu, 2020-07-02 at 12:49 -0500, Jeremy Linton wrote: > Hi, >=20 > Using 5.8rc3: >=20 > The rpi4 has a 3G dev->bus_dma_limit on its XHCI controller. With a usb3= =20 > hub, plus a few devices plugged in, randomly devices will fail=20 > operations. This appears to because xhci_alloc_container_ctx() is=20 > getting buffers > 3G via dma_pool_zalloc(). >=20 > Tracking that down, it seems to be caused by dma_alloc_from_pool() using= =20 > dev_to_pool()->dma_direct_optimal_gfp_mask() to "optimistically" select= =20 > the atomic_pool_dma32 but then failing to verify that the allocations in= =20 > the pool are less than the dev bus_dma_limit. I can reproduce this too. The way I see it, dev_to_pool() wants a strict dma_direct_optimal_gfp_mask(= ) that is never wrong, since it's going to stick to that pool for the device'= s lifetime. I've been looking at how to implement it, and it's not so trivial= as I can't see a failproof way to make a distinction between who needs DMA32 a= nd who is OK with plain KERNEL memory. Otherwise, as Jeremy points out, the patch needs to implement allocations w= ith an algorithm similar to __dma_direct_alloc_pages()'s, which TBH I don't kno= w if it's a little overkill for the atomic context. Short of finding a fix in the coming rc's, I suggest we revert this. Regards, Nicolas --=-jPh4P4ef6IRIm8gZjo2Z Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl7/RnkACgkQlfZmHno8 x/7Hzwf9EK5UZ/nU0kNYHFn34OzNUw81RBxAseEJjDNzqtbLPFOnBapN7FTeMf3t SEVbR4NXtItrMqKjppBcAhqjw6geoWvgonDnZlMKZhV4CNSGqgBc8U1kn5FRY4H/ 6/nJ2yzcRtuYCmoIK/Rtc6g53+lJoM+Cmor1Bdp9RG+qOc9cylECc1FI6zx3HaZv vBfaKbqF6relsISrxWkD/iRne99hINnTvdE2LTz8VoZWWbN3G+lUkDw9KJbm4WaT 3lFAMPf2XQ9pJVmDj+M2TYMLkCGTelhml4o1ngHvugQFfjaueuFdOcbXiTikx7RP IJWc4W/+qG6zKC3cOjN6oj6fLNCQaw== =5wyW -----END PGP SIGNATURE----- --=-jPh4P4ef6IRIm8gZjo2Z--