Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1431571lqj; Tue, 4 Jun 2024 00:55:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWfpqgUB5mPvCPWkVENE6boPMTwAMGxAFmYyqFDXbu531bp7SvQv9Rq9VJA43fReJJw7CUqYnbiWRv/PMDSSBpgb0F633sJNCC4OmIKeA== X-Google-Smtp-Source: AGHT+IGP4b8vcZ3hE92EdOm6jL+1qENYN0mN9ikcku7ZJ+U92cQITWv/U2HHuzTfVzbwugAX15Sa X-Received: by 2002:a50:8ad9:0:b0:57a:6e41:9d8d with SMTP id 4fb4d7f45d1cf-57a7a717b8emr1387140a12.18.1717487700950; Tue, 04 Jun 2024 00:55:00 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c62d39si4888671a12.255.2024.06.04.00.55.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 00:55:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200192-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=WLONGakP; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-200192-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200192-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.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 3D42C1F219C9 for ; Tue, 4 Jun 2024 07:55:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67E5C142630; Tue, 4 Jun 2024 07:54:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="WLONGakP" Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2061.outbound.protection.outlook.com [40.107.8.61]) (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 B3DD11422AF for ; Tue, 4 Jun 2024 07:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.61 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717487674; cv=fail; b=XEmIWy7rSUkqmdB8lR3cLpcL1aheH7qJ5Pm+aONIZW1OHqsMOhjPpLf/3qPj5V+VdPwztUvda9sarbjn60Ci9iVNjbsCDzqhT5PkxHq8fAtCSjG8XWJs9KsFChyMnJu8I85cXIPzGWIEEzstQ+RYFu9LKQEs+kAMMflhknY1VqY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717487674; c=relaxed/simple; bh=qcq9lu7LExDAHb+/Jf7Mn02xmr7/LJ0Vbn4lUy0T3As=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=His+WB+NUje6buBLFzpVfbTzsg7q0F1IQRoB7CZgIFO90gbaf6rDeemQF3RyByCcw15woOd13cfW3QyRwsa6EYj+3pJr36TKclDoLAnpqidjYDZFuMw1gE5bCXymp1efqJarhDPXf6U2/63BQu1is+emxaejwTFfIaRSxYQ35L0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=WLONGakP; arc=fail smtp.client-ip=40.107.8.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rcbloe1hCIpQnXjLlY7KAtzz1ThpgVBrVLwgbEukOTzfCPb+5GpLsH8Tuc1A1Riwyqk8q9WIRBtdqkl8unuhv222rqICy8327fNAMOImYPhuQl7bxXgFmYA/o4VAA1IJUlLWSsYyVuPU2XDD1o2Di5tCbrp0ZTa52FZa/VbrjTZccQNorWUTtrHk/e+v96/KeTZMdgP3UFh5uiNriCjErAscXE+dNYfRZ7/DF/OwSKdR22F7b68nW+cJs5g2ETiE3tHYAhxgveVVMm3DaVq6dMfeTSNAFgesCTpvscXh6erRUEoJxhGfWs4UWOAHvA3O+G9UYjjYVotJ1BhbWH0V3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hteWmja6vb3IQ8GfcY3lSL1CRwcOLpAMk0QyTnGJc2M=; b=CGqjG/43FgZPZaWWd4Q+ImoCR4bLVNuKYwEaL/KHXvjvyvaogKmQ35Icp0JImf4NlVY4IQt5i+uPANplSphJf6OxY2RDkwjIRfKTyVi6WVW7Mop1AW3xW+mFpN9XYy9Fd+T5M3tO9xwDhYbGubmcAf2zTrGuFLJmZMlwbTFCqvt0P7O9jiZayyj+2K7r0kEzs1TSoSLZ9xWCciQ9C6xLpU1n8Xshc2MsgzfWEIF/t29fiju+bYWmvUP9yJpYjDC8se4QD35PffFLJZnHp8COrXcnV9OL1talO2jktUuu701A5lC9N6ZKPt0vR3iL4dHHwB/f9igW1cKPBT+Ugkj5eA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hteWmja6vb3IQ8GfcY3lSL1CRwcOLpAMk0QyTnGJc2M=; b=WLONGakPgoWhUMlh5VriErVGhIJwPuILp+qugVwZVM+jn+O5msH6akhtgDp8AGcfgZ1vUKrWjLKfjnV/UgzQYfaI7kEC8oIyh4q5HojdGHxL15uPa5Ur1IR5ros5lYRdgTJ8R0jMzN7inz2KiTCysOKSOKdVMgoCRIIUdFHwSEU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DU2PR04MB9019.eurprd04.prod.outlook.com (2603:10a6:10:2d4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.27; Tue, 4 Jun 2024 07:54:27 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c%7]) with mapi id 15.20.7633.021; Tue, 4 Jun 2024 07:54:27 +0000 From: "Peng Fan (OSS)" To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Javier Martinez Canillas Cc: Peng Fan , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/fbdev-dma: fix getting smem_start Date: Tue, 4 Jun 2024 16:03:28 +0800 Message-Id: <20240604080328.4024838-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2P153CA0028.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::9) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|DU2PR04MB9019:EE_ X-MS-Office365-Filtering-Correlation-Id: beb9456b-15e1-4151-7d85-08dc846b8eb9 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zs47fTBrfDyH0TTfaGI6SHSZUtNJrIhEKkaN6+zilTfnKeSnTAqIkLt68TB7?= =?us-ascii?Q?ioMPY8k0vsbYFUCg3IR9MmlwMaccz8gTK+g8b5joToI90Mqs8MsyETdwbxUA?= =?us-ascii?Q?Xewf4qGVpLXtG4fwE/OJIhCrptwNKFZSvd4qfu6pu/FxWTrxzxC89Ddr7UCb?= =?us-ascii?Q?7VcrzaSMLlSpborRQ68/PQTj5Ymxf+FVq4A2qMW09ugg83Qmp1IdMrExGAs3?= =?us-ascii?Q?ROMtAhKQnYJmjnlMKTH7bjiWSDjVVZ+QLuLimp/xmi9qZRthoyuEHiTjvfSJ?= =?us-ascii?Q?t4QURXNv6JbRbZtec1Rk39MFihY9n0wAiu+f8uDF8R19HoGZ27UXj0a1JY3Q?= =?us-ascii?Q?dsswxRUPi66S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us-ascii?Q?tlaQ3jyy5cZcAeqW1F1PNI8AFTski/EYBpNkZ+fxZpP2s1N0FDhmtg+BROhl?= =?us-ascii?Q?pdyE4OmZI2y9M7imNUhfOSmVBKYmqHziKEfNpQuCSmzCVQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ry7zHsSLf7Sh91FWMRNu1CssHy7bsqN5tPDkUf3zyf+GULC/5pri1QNybZht?= =?us-ascii?Q?Ftie0048x/OVy8FVv5ZvgLnJ9tlsuqetQqZUzhzTvfiHJv+4DpJHcwbsukbe?= =?us-ascii?Q?lPwHZVgDSmuz0MM4YNkwk1PFK87wo91ZzpoYGxvQmkJ5p5DilOogr6RgAbgb?= =?us-ascii?Q?/5JovFtISCDrN0cFvsnfgAwahwxTQAleUOHuOU/5owtBFctlgJ5Ewb8lHosA?= =?us-ascii?Q?sDGEh2v5OvD8u2XwUnxLRRvPtSwPs+z8QyPWVZSgG+wzCEwWrQTQxm6D3rLr?= =?us-ascii?Q?urVC2RfNBx/eooRpSnbpjlwNJwfbtCU1YEbgqKr/j7mhFgY1B0uL0MOouRmJ?= =?us-ascii?Q?mUac5VZQgenwN1vZihNfgzBygqHUcAE459RyN4BA6+yOvyo57k+GY9NwMafo?= =?us-ascii?Q?Ra6cdwEX2xVG0NK/Qn/ExEn76+1nEjzHVcPiLbBugYcC+y564p2T/Uu0Fa8d?= =?us-ascii?Q?tTY9PXNXJal7evabgoRLiNc4MrSV80q8j+cgvbIQ0Z74sWlc/I07rBif2s5U?= =?us-ascii?Q?Is5I3ejH6ERTbChj3cEBGCFwzJDqNJIw9SchLmAf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l6WDqKe9oXZMRlsZGziTCbLAJBnZHME5RRESi89YVXYTEDz414PFy?= =?us-ascii?Q?4PXESd8U+fcGaPd0UlxE8qon+sPRsf0dQpTxFXEoaHQT7A2ysaGYbfnx+UtS?= =?us-ascii?Q?/M459fMKWrZ833+3SxhlUtmcpOR7Sh6RpO9fuIye?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: beb9456b-15e1-4151-7d85-08dc846b8eb9 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 07:54:27.5422 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Jy0mmp7YSVkRGMMt9cqmELLAD3hM8CRJoLMYAiDBfIwVft9VwtKD6xyTjQlvCfN/7n9+ntu54i+KDW4w4BQKCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9019 From: Peng Fan If 'info->screen_buffer' locates in vmalloc address space, virt_to_page will not be able to get correct results. With CONFIG_DEBUG_VM and CONFIG_DEBUG_VIRTUAL enabled on ARM64, there is dump below: [ 3.536043] ------------[ cut here ]------------ [ 3.540716] virt_to_phys used for non-linear address: 000000007fc4f540 (0xffff800086001000) [ 3.552628] WARNING: CPU: 4 PID: 61 at arch/arm64/mm/physaddr.c:12 __virt_to_phys+0x68/0x98 [ 3.565455] Modules linked in: [ 3.568525] CPU: 4 PID: 61 Comm: kworker/u12:5 Not tainted 6.6.23-06226-g4986cc3e1b75-dirty #250 [ 3.577310] Hardware name: NXP i.MX95 19X19 board (DT) [ 3.582452] Workqueue: events_unbound deferred_probe_work_func [ 3.588291] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 3.595233] pc : __virt_to_phys+0x68/0x98 [ 3.599246] lr : __virt_to_phys+0x68/0x98 [ 3.603276] sp : ffff800083603990 [ 3.677939] Call trace: [ 3.680393] __virt_to_phys+0x68/0x98 [ 3.684067] drm_fbdev_dma_helper_fb_probe+0x138/0x238 [ 3.689214] __drm_fb_helper_initial_config_and_unlock+0x2b0/0x4c0 [ 3.695385] drm_fb_helper_initial_config+0x4c/0x68 [ 3.700264] drm_fbdev_dma_client_hotplug+0x8c/0xe0 [ 3.705161] drm_client_register+0x60/0xb0 [ 3.709269] drm_fbdev_dma_setup+0x94/0x148 So add a check 'is_vmalloc_addr'. Fixes: b79fe9abd58b ("drm/fbdev-dma: Implement fbdev emulation for GEM DMA helpers") Signed-off-by: Peng Fan --- drivers/gpu/drm/drm_fbdev_dma.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c index 6c9427bb4053..9e2eddb6eb5c 100644 --- a/drivers/gpu/drm/drm_fbdev_dma.c +++ b/drivers/gpu/drm/drm_fbdev_dma.c @@ -130,7 +130,12 @@ static int drm_fbdev_dma_helper_fb_probe(struct drm_fb_helper *fb_helper, info->flags |= FBINFO_READS_FAST; /* signal caching */ info->screen_size = sizes->surface_height * fb->pitches[0]; info->screen_buffer = map.vaddr; - info->fix.smem_start = page_to_phys(virt_to_page(info->screen_buffer)); + + if (is_vmalloc_addr(info->screen_buffer)) + info->fix.smem_start = page_to_phys(vmalloc_to_page(info->screen_buffer)); + else + info->fix.smem_start = page_to_phys(virt_to_page(info->screen_buffer)); + info->fix.smem_len = info->screen_size; return 0; -- 2.37.1