Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1674494lql; Wed, 13 Mar 2024 05:20:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhrtqeUGqAKa30R0D7w5xK7XPcEMNfGvUwl1LCniOV625lfeMF3V/SopEHGv8xkgpcDI8KwFCKmVWsAohOrG0W46A01YbMbZZfNusV3g== X-Google-Smtp-Source: AGHT+IEHv28fTRKS3ZTl2vQSJawA5v1g41TBoOuk7YPHexqGT86dpL+qSW2MqSWFJOFcvst3naA1 X-Received: by 2002:a05:620a:1081:b0:789:c8b0:1fe1 with SMTP id g1-20020a05620a108100b00789c8b01fe1mr1990381qkk.13.1710332417899; Wed, 13 Mar 2024 05:20:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710332417; cv=pass; d=google.com; s=arc-20160816; b=fKls0lOV3U2Sgi3Ub0jglfl882URAnEzNjJqO+YDpShIs6D0NxfpTfV2N8HoYC7Fmj g+SSDzeMXYxly6P1OVaRYABu+JrtJd+/KEAknagr2T6Olq/+C3w2R13Me7IFhZnrrZPP ZLxsQRnLLGna7JpKau41eKPq0jv8ln2tRlsWb7GEul9IKBLdLF81R9se5fbuzESu+NLO 383S2jfhPj7ARA88UJdbOzJnxlGMzpjeQWklmWS+uR7cDMr1uRVLq1eV/5R0cG5xVOSz fvj+kqv1sZc4Lmrr8jNcdu7L0k124/MzPE9j55umzZL9+P9dbaHZo4CBR1aW3D0V9uV1 jEcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=or3eZs8Nrn7r67hSRxouiC9/TCgQeXLDBKP3b0Zq57o=; fh=12hFriRSaTdgNqNrzmeWt/UGUpydSkBu8c9XSYqsGkQ=; b=dg8aTCsy1I75j/7//+BiZPAb/hETnMXAlLoPGM5ZQwugwLI/XC7m73JjPMCl0kbM2L NrXjGh1KPJU9YWXJgmfqPR3LRnnHc+MdtaZhudC20o/5bvJO49TxIsyAP9W45TfPe6Hg DDCWC/Kc+wl4e55SJpuawG26/5tVdesZSgHQhqIp8aGWjZYR1kVd+5rVxNC+idE70IvA kL0WMpSNaKE/I0I6144HDiCsevFdCTnYAZoJEW7gnWmt0yG5c2Gi5B9jC4eUiCPe3PAo aleh8TqUUkMe0StZE99gzfZfA/34XP3bIUzIZVGWHPkT+UpHeIjJkp3vI/pkgNggRBtr /KQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=OJFNyDrt; arc=pass (i=1 spf=pass spfdomain=mailgw01.mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-101464-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id xz22-20020a05620a5e1600b00786fe4117fcsi9186412qkn.388.2024.03.13.05.20.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 05:20:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101464-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=OJFNyDrt; arc=pass (i=1 spf=pass spfdomain=mailgw01.mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-101464-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 99E701C22DED for ; Wed, 13 Mar 2024 12:20:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27C31405E5; Wed, 13 Mar 2024 12:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="OJFNyDrt" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28FED1E531 for ; Wed, 13 Mar 2024 12:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710332410; cv=none; b=QAb5PkCfx7ysp2uAS86EQyXpF8irHwIF6pXEsl49WsqaTlVBTh1eLeggVaM9M5WQoMn7a4Tw2SCh7Nv+4zmnEekWKWHWOKQbrdHBSqZLzD6dJfO/vlKAQ8by6FlGY+CSe+h1uRk4iZnCEqBdgrEHmDypjD9ARn2iRcf8tya202Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710332410; c=relaxed/simple; bh=kRcXtIS0ZB+5A1tH+RAb/Y3bMwHWyq/xrkLxiZ8FCuI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=GlRO1JqC9jA2Hwh98kO2ly1bGfk4jlTnTXvejPdtjq+zPu+SceMScF1e181hNnNcOoLe/eo9XdAumafaHz3AlE+P3OSZoEOuwBsipuAMYXnQTzINnWmzqsizEkR23FdBnGal51nZ5VY6AsyOHS+qIhkEdBptqPr8OZ9JZyOVjzw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.helo=mailgw01.mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=OJFNyDrt; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.helo=mailgw01.mediatek.com X-UUID: 0542496ee13411eeb8927bc1f75efef4-20240313 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=or3eZs8Nrn7r67hSRxouiC9/TCgQeXLDBKP3b0Zq57o=; b=OJFNyDrtC3+oQbXmk5FsU5zXM1+tzZHvj/J5qyvfWsMtHLD1AgslKEOeNhlycK8tcUFyA3akbVofeu1D7cgkg84q7sBHWfwhXFy7b1X1ACIoXd4fr4xTE/W97WuHImBtJ68G1yiD0PJ8/AYvB1WtQMcysUDiqOUEs/6Uo62r8IQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:607074f0-30ea-4ce9-a3c9-c7fe5cb0a1dd,IP:0,U RL:0,TC:0,Content:-5,EDM:10,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:5 X-CID-META: VersionHash:6f543d0,CLOUDID:0fc95b90-e2c0-40b0-a8fe-7c7e47299109,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:nil,TC:nil,Content:0,EDM:20,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 0542496ee13411eeb8927bc1f75efef4-20240313 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1803951228; Wed, 13 Mar 2024 20:20:03 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 13 Mar 2024 20:20:02 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 13 Mar 2024 20:20:02 +0800 From: John Hsu To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , "Matthias Brugger" , AngeloGioacchino Del Regno CC: , John Hsu , Chinwen Chang , Casper Li , "Kuan-Ying Lee" , , , , Subject: [PATCH] direct-dma: WARN_ON_ONCE when the page is not addressable by device's coherent_dma_mask Date: Wed, 13 Mar 2024 20:19:30 +0800 Message-ID: <20240313121933.15839-1-john.hsu@mediatek.com> X-Mailer: git-send-email 2.18.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--8.982500-8.000000 X-TMASE-MatchedRID: ApWTbtae/ntKpt0bXTOsseIfK/Jd5eHm5Y0kb0hqatzb6Y+fnTZULx8+ XHETeZCzWC2b8unx+lIBXdtZPWfJ2ti5OqTR/Gdcdj6ndECc9fQwCmrLlx+Sdd9RlPzeVuQQrWv A11V1iKmeI7jQOR42AmzlLAWyLHZTHxPMjOKY7A+Wlioo2ZbGwdmzcdRxL+xwKrauXd3MZDWuik CL8VXXTOdCoM5AWaTNQYSNUwqrAIm7Om/jsUAZXIZt0Zt5H8bBdGByp+zdaDg= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.982500-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: DDC29104D7E7600799E9307E9FEDE743D00DAE66AF562F97600BD1818E0CF95B2000:8 X-MTK: N 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. 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; } -- 2.18.0