Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2243650ybt; Sun, 21 Jun 2020 13:45:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwOy8wl2rx5i26hou8sUWg3lB0i36tN/nDPVzL9fsql9AH2sB9WW6U6soivu/ngz8om32L X-Received: by 2002:a17:906:7f94:: with SMTP id f20mr13494956ejr.394.1592772310507; Sun, 21 Jun 2020 13:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592772310; cv=none; d=google.com; s=arc-20160816; b=uVrUBgK9lq2sCsKNEoI5VKi+V4wzRAbhPyVDiIMk2HtjMbtvPfLe9ssZYpYhBtJzi5 Raos3vf6Gtvbi25Bbo7cchVYtklkYsADz9UBBmN17aW4vu4LzTTA/E9XBfFm/lD1GwfL Fz697O5j9Oq2Q4FnPpdObfchJkmk7YFx7LZCiRwUQVRjjYv1VRJ2vAKcrddNtIfB0lfk Zg+WiIuz1TwNp5xtR/auUbf0/4QlVwYnFQN2GA1sPob36x7AGd9UbTUfnr+FKNGP5P+X pvhw/ouoHrvd9VlILxT428M0h8mO4sQztKRqJEnUGB60oD2UEdArftx8JHJZ3yeFEKyW OTZw== 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:message-id :subject:cc:to:from:date:dkim-signature; bh=PvZljGHNreo2tyXJVvsTBccc3LskiWVWOyP0n6ravmE=; b=ekZ/Xf/d5Nm8H9D9pduWxKVHWhJvA+HkV9QTQCiwMjYXN3wPXxRna/pct0anfJnAJA JgcjALJ5MXYfZak/RWRdoPeizhbP7Hmoj+XkZXceBaSDp7pQ+pwzxNzbQJAHHeST3gD+ eMzz8iqOlG0Z85jq95UzBK8DZrbU7RHZVkiNm7mv3emmcst0fRRIKJiAda1btrDW4J/Y hbYJqSppNzJtVDRtAvDxZqXAD/Xo0WZ+n7qrmUdaBqtRa+ZF3jHaOa/3up85tCeTjcNA 5//MbckjTXqbamfY8cLyB5fq5+OUE6JrpChHzTpE25x1JKcNfp+iGepvxgowusvPx2XA g/nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=a5FmRKW2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si7647623ejb.233.2020.06.21.13.44.47; Sun, 21 Jun 2020 13:45:10 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=a5FmRKW2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730653AbgFUUnE (ORCPT + 99 others); Sun, 21 Jun 2020 16:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728860AbgFUUnE (ORCPT ); Sun, 21 Jun 2020 16:43:04 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEF96C061794 for ; Sun, 21 Jun 2020 13:43:03 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id k1so6612850pls.2 for ; Sun, 21 Jun 2020 13:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=PvZljGHNreo2tyXJVvsTBccc3LskiWVWOyP0n6ravmE=; b=a5FmRKW2nzxF4C5QCSMWyxbMtHd06V1ej3ANmTPXZdyDxWXpV+nqYGzuaoZ3QjNE0G 6zKlRnuKU/8T42WFDfCTuILMSh+2dHrjnCuXcdl8GPjzXndyCX6ZVxGMUldRaE3jwY1H uYjnXMhUQNToXjfQsELyHV7MYban3XTH0ewBWy9ww8hvCnibv7CZfH7xB9c7tQSoFp5J jSF7RRc6oH8ytBy+5Tsw6Hy4X+82zx32FF79dfb7oo59/vfB7DA6AaqtnSg328QtBHHD v0M5R+GMYYj0DKfqjzGlzRNklq94g2ypEiXzajJ1dAvqKRhkLaFRMSltmuCZort0Hx0Y h6yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=PvZljGHNreo2tyXJVvsTBccc3LskiWVWOyP0n6ravmE=; b=JVAjGFIkOcIzGF77swK7v7jjirdvOxbCUvY9KZh7JfHHcvcqetqlyI4TI7zg8TbrD7 /gsxDdO1x5oBCz70XjyPYdWLgaShvpcMPVBy92ID64TpvzE5TqEbbrV/TosCaI+OHM+u 9HiEm885tqZ4dBGmLBZGWB9JRYG9HI/buoP3e/03WdBQBeGYLqYpIrS/ca0je9PEcZo6 KTbYdBHnmIIzt8AalAcyAiLqH9WeDeiTLW7VjB32TVWovJcMPWviwVMURi5xLmM9vBH/ cyhIbs+VHEGwNCn7mJJb4uPS/KcH9d0xXMWvq9S6B0kwPjIEHjVilIY21Vyw1Xug5eth PwtA== X-Gm-Message-State: AOAM53094xFNUUak1SvKwyrLmaHcG9Eg8gLatOhMte/1GOW9TUPuBc0U VIz8VE3KCwxgnNLVPzbO9P3kTA== X-Received: by 2002:a17:902:a511:: with SMTP id s17mr16615698plq.37.1592772183174; Sun, 21 Jun 2020 13:43:03 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id f6sm12610020pfe.174.2020.06.21.13.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2020 13:43:02 -0700 (PDT) Date: Sun, 21 Jun 2020 13:43:02 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Christoph Hellwig , Guenter Roeck cc: Geert Uytterhoeven , Marek Szyprowski , Robin Murphy , Linux IOMMU , Linux Kernel Mailing List Subject: [patch] dma-pool: warn when coherent pool is depleted Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) 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 When a DMA coherent pool is depleted, allocation failures may or may not get reported in the kernel log depending on the allocator. The admin does have a workaround, however, by using coherent_pool= on the kernel command line. Provide some guidance on the failure and a recommended minimum size for the pools (double the size). Signed-off-by: David Rientjes --- kernel/dma/pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c --- a/kernel/dma/pool.c +++ b/kernel/dma/pool.c @@ -239,12 +239,16 @@ void *dma_alloc_from_pool(struct device *dev, size_t size, } val = gen_pool_alloc(pool, size); - if (val) { + if (likely(val)) { phys_addr_t phys = gen_pool_virt_to_phys(pool, val); *ret_page = pfn_to_page(__phys_to_pfn(phys)); ptr = (void *)val; memset(ptr, 0, size); + } else { + WARN_ONCE(1, "DMA coherent pool depleted, increase size " + "(recommended min coherent_pool=%zuK)\n", + gen_pool_size(pool) >> 9); } if (gen_pool_avail(pool) < atomic_pool_size) schedule_work(&atomic_pool_work);