Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1691344lql; Wed, 13 Mar 2024 05:52:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV45QdZ5NbmuW5NsUUbaelE7H4c0l9FQJUwLqK4r1f4ZXTHXSHEeKvJxtPYbw026yx0t9Sfprs0pelnB67t5QvzbG64PWonEji/aQfFFg== X-Google-Smtp-Source: AGHT+IG7rZTz6S2ayujila/+/y58Y18FIlo53pT6OhQ3qgsFocFPWTm+5zsE/JIh8gkUD1/dk92H X-Received: by 2002:a50:d65c:0:b0:565:cbba:b7a1 with SMTP id c28-20020a50d65c000000b00565cbbab7a1mr3590176edj.1.1710334319977; Wed, 13 Mar 2024 05:51:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710334319; cv=pass; d=google.com; s=arc-20160816; b=WZG+bW3SBCJKS1SbGIu+P7VMONep1I42E7ip2uENckmG/ANEUuj5mlKd+eLNhpXI2s LX1bH+SgQiYP4VF6SnCLT9sDarFCc581ixWpNsj7ORhNdaSk5U05bSnNO8b5UX0Pq20i TY3/4wbjnPd9k/tTVb+ayu1T8Rr7ZR2fUTOhibVTNK4M3chA5IUfE/lYG3CoNLCZuiiK zm2GIy4zyyVapO6s8bl+KJOsCE41zmS7A3utNIqwlj2raqKvyoDiMJbVGri+oiuXUDjx di9RjdgeDa2Za1ciXQPWEZJCvrnLbi4SKrKT2gOBvx9tvQvhyEzY2b+wL+QocWPK8umL i3Pg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=bKFbA8AvNLUbD9SlLtpfgdOrCFfAN9VF5LfTSQYu8Lo=; fh=1AI2xIMKmzaPiBL/wl+PuXV87pW8/JcdS+xA7M8VFoI=; b=HBe8qm3MXDo7J6/ewdGYJYRmd1DgVnQj2ePqldCA0BNjzoO6RyJ7vQElGIATFQz1ur 9BwW2KxBgZXKdeV+eFnxZcXSz7mdyEmlt/8JmTRRe0u9NmkYZlpm6zGOFEeuyC+zugTC D7RznPF3/8HyFjVU0sl+5Y2jv9Ww4CbFPtcwliNw6NpQyTHL+CHPbCx/of0mPqr7KFBU XEdrGgU87hpntqg3lm3785E1WxStJBzZcc0ukluaajfWM6SnvXcXlpa9l0CSxIphT1ia SQ+bu9llyj8mB7RJqyN/xae7+BaBhsZHBgAKRR5RXjYtJSDj5AVKBH50dw830I76r4WW 74zQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-101487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id eo9-20020a056402530900b00568525cde5csi3315848edb.254.2024.03.13.05.51.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 05:51:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-101487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8D55F1F24A4D for ; Wed, 13 Mar 2024 12:44:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 356F11EA99; Wed, 13 Mar 2024 12:44:01 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E33704087F for ; Wed, 13 Mar 2024 12:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710333840; cv=none; b=Pzm2t9oYmu6ICCamYZ/ZJg5OMevfmvBNqd07HYDYORJqNwkQUkE/7RulOlx2VS42C3Z1NMWYo3ENAL2tc0olBMSURC/A9yWcMW04J498BuG4DKaBcxa+NE3KPonsW65rt4Qw2/ZlulO5iS0jVxtoFUNMmHfXcmJeSZSKIn4ilWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710333840; c=relaxed/simple; bh=JifDVMoaPXHaAUPJL3A+n8/jjHlsbgg+T4JcEzCN6DM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XMnqnbmfl8fhIF/EPQzG3wp4dW/SwuYJ/PR4+cPCisFH7I4TioNIT2iSGrOn9EM9vXactGUvV3XHrhLJSbU6LQz57v7AAYHBnhrxmTs8YxLc+WvYLPy8nJ5VU5PMfu8kAHb5FL8JlwvYS66H93HHkxByuNybMMUV2B2keGqMdfY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CAE661007; Wed, 13 Mar 2024 05:44:33 -0700 (PDT) Received: from [10.57.52.245] (unknown [10.57.52.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E38D53F762; Wed, 13 Mar 2024 05:43:54 -0700 (PDT) Message-ID: <6b2fa7af-0fef-4c18-a6ff-1bf4ea16810f@arm.com> Date: Wed, 13 Mar 2024 12:43:52 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] direct-dma: WARN_ON_ONCE when the page is not addressable by device's coherent_dma_mask Content-Language: en-GB To: John Hsu , Christoph Hellwig , Marek Szyprowski , Matthias Brugger , AngeloGioacchino Del Regno Cc: surenb@google.com, Chinwen Chang , Casper Li , Kuan-Ying Lee , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20240313121933.15839-1-john.hsu@mediatek.com> From: Robin Murphy In-Reply-To: <20240313121933.15839-1-john.hsu@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024-03-13 12:19 pm, John Hsu wrote: > From: JohnHsu > > The dma_direct_alloc() may return null in some cases. For example, the > allocated page is not addressable for the device's coherent_dma_mask, > and the allocated page will be assigned to null. > > This patch can WARN_ON_ONCE() when the returned page is null in > dma_direct_alloc. It helps the developers position the root cause of > allocation failure rapidly. No. Failure to allocate a buffer can happen for any number of reasons, it is not specific to dma-direct, and in some cases it is even expected, hence why DMA_ATTR_NO_WARN exists. And either way it's still not a condition worthy of panicking when panic_on_warn is in use. Sure, this may well be a handy development hack for debugging a particular driver which isn't handling failure correctly, but it is not suitable for mainline. Thanks, Robin. > Signed-off-by: JohnHsu > --- > kernel/dma/direct.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > index 9596ae1aa0da..a73b8ad1ef9e 100644 > --- a/kernel/dma/direct.c > +++ b/kernel/dma/direct.c > @@ -156,6 +156,8 @@ static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, > } > } > > + WARN_ON_ONCE(!page); > + > return page; > } >