From patchwork Tue Nov 12 10:05:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 13872020 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2086.outbound.protection.outlook.com [40.107.241.86]) (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 4DF4F2139A7 for ; Tue, 12 Nov 2024 10:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731405990; cv=fail; b=PTzs7CMcRwqONW+Sk+Ll54/0zAIrpiEu08jYY34cFlG4tgq+qSEAHkIWPq1GLdM+vPTp99+G7kzthMuuyi1IzaHi/LrjU7Ck5H6nfFgiHKvwIKRwXaWlmFFuJ6Adn+JoKW/mR/JOoMv1d7A1G/1wfNr7gH/D9kmr3W0okgn8bAE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731405990; c=relaxed/simple; bh=pm2kK3Ah1RHZDU6FNOApQDaFd849mv9G3MCrS75KFRw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nbrMt778UFxFetEkUvbFkSAc9IFQEZP1NWUh42fLhVkYelNU+QOScav1DhBEAq90RyKU0b1NJQJlkIwTNs0dHhRRtCWGWoLnvmDrGE4QhpwxUSVp7nYqY+RLlpoETpE/YeftDrG0I4YzxWuCEScjiDwqfVjEWwgSL4p2lQp4/Ng= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=hRYRVW0C; arc=fail smtp.client-ip=40.107.241.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="hRYRVW0C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N8k+ymnDbeffNSmHu/6me1G1rTLN1ca5zpGMKBo6Kv/8vYz53UpAUbiG1erjTF4tTnuTYnZE9IhrINaZ5R73E69PUX/wXyy6Ek63yFX5uoQv1zpLc0L0ZdqS3s/CVKtbdJ9sI9nLwvCRioLjdyzPR38owjF7JdCtWI6fE/lmnjK/POGVkmMWHOWipXX04FGVhtJgkRLSfVIHo48PpLFWyOHKwUrcfh2dOcnNMn6z/0fx8wf3At0hjqD3hAtz+du+zpPC/U/rQcRbeXrDgr2Ym1Xi+/aeJHcUNeKAEXl0tLKrTet6NzazCZA8Oxjl6rk5A4On4fIuD7DLjNhdo45ZKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=XGfk6W2JCj4wpC6o+Qwd+LjQx3NGxQw6YEQqOKv1cTs=; b=KfYtEsaaGPCIBulLzTcqBbP6ispyPib+ywM7oM9Ye5pdCqRPKAND6pkjV9qykeVb1NyNizDK9p7iGOTLqlP56vYKFCN0KLgAHxP/okSG569D4odswdbejed2Q0sgrUhQnGccLEjByPEpNxhA9oJ6ARJ3kpXhAN5fnsCH+nfX09mqtDj1ZR/X4QaKLQwkN/QZlbKCd/G68vvWuGGE8i2P6Aw7Cly6gLrv9PStU1k643ltiixXwl/f4r2K9sTSzkbBVJbDgDaHLz3mfOOZNKfUmPC4hvVgQK0L3GYcCFELzIQhKmQnIWSGW2589bWKQW0vju3eXYeQ0UZKjAVxhCNxvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XGfk6W2JCj4wpC6o+Qwd+LjQx3NGxQw6YEQqOKv1cTs=; b=hRYRVW0Cbnqxt2HqAxhYlu7tr+LK+tE2qeGM7LsRWt0fVPUOa7P8PvX7Or1JteqXBZwyxtIUTCP0soxv5vNORbjeieVq9VFa928y4axvE1K8Wa/Qko/jhAr/wvdm7vf0Jgx87/jJyoZyyiemlfvhnw6pmAcxSyIvsc/lC+bXVbzwfgw2vSTRtjbuDz2RyL9d4Nzn60nBbGrUZ3FutT9HQHxVpjhuXac62Jk1jzaWXBvSlomOBWR6rJHPVMKqGaceCGnDJ6LekD/UonXpYSPMUeOpTBWKGIjUnWkM9K0b9Yu5c/YjYY7q65Sk3WCE90qrff6upAzIMVM74jZkhwMwsg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AS8PR04MB7879.eurprd04.prod.outlook.com (2603:10a6:20b:2a4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Tue, 12 Nov 2024 10:06:22 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::d1ce:ea15:6648:6f90]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::d1ce:ea15:6648:6f90%5]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 10:06:22 +0000 From: Liu Ying To: imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, catalin.marinas@arm.com, will@kernel.org, abelvesa@kernel.org, peng.fan@nxp.com, mturquette@baylibre.com, sboyd@kernel.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, quic_bjorande@quicinc.com, geert+renesas@glider.be, dmitry.baryshkov@linaro.org, arnd@arndb.de, nfraprado@collabora.com, marex@denx.de Subject: [PATCH v6 4/7] drm/bridge: fsl-ldb: Use clk_round_rate() to validate "ldb" clock rate Date: Tue, 12 Nov 2024 18:05:44 +0800 Message-Id: <20241112100547.2908497-5-victor.liu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112100547.2908497-1-victor.liu@nxp.com> References: <20241112100547.2908497-1-victor.liu@nxp.com> X-ClientProxiedBy: SG2PR02CA0025.apcprd02.prod.outlook.com (2603:1096:3:18::13) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7PR04MB7046:EE_|AS8PR04MB7879:EE_ X-MS-Office365-Filtering-Correlation-Id: a27ea734-9a13-4754-cc32-08dd0301a8bd X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|7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mP/C+pfcssB1urtVnfSr9nSy128rOHlFpmfOjAoHBQFLFTMUltf4tZCQqgnB32u6C1BjTyrlbKofONjndxPBPVhH13OaxoPPeCkoiuOm29YsoFzX7053TXO6D78iZwLMG792LGdcGWq8WEI6SduJJwig9FWl/sWYYDDsj9wbJ2r05jjkiURe2kX+Z3HIYUS65c57S3X8gCTtySJWCqkUHrdggwt2BvjCWwNKIndJU3c6iWdmQC1gNwSLeY0l8bzNdxdsnR6Mk5+Z4nMgKSE1GLdXCgdNKpRiYCdLhY9Jb50WKmoSiccTLmD5oqRXLAi9cbVWCM+Pk9+0MdV+tP3P22yOd1qOnPcHhGVjmG1mOG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7046.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(7416014)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e0S/fUUCrL8FOH2q4e4hfdNI4PfKj3ra+iRha9RhkeWMAUBPdB4xzOzSKaBXMOOngQ1JJKewvQ6hZwGLxUkLhjgn8Qeg6OUARccm9knViboOWBSGLhl0pikZUki281XvwY+2Hu+R4jnUzSBqibO3eAK4n9f2nscq4+9/NrKmzy7BSSOFpaamMqtYjkVsbW0jStGj++wS7dt4pra03yBTj7GxjEUwAYwUxeCbEqiELl7rJyfudCYasMreJvMapzwEr8sp52hrmgkA7RPwmMBpsvSP1FKQeApvPaJYNdG6Nr0G5q2GTdED4cKjwZMNAKFiv7NsGmDXNkuuQ1Rh30XsjzFzV9BUiWFzCA1jhfZrn5FXcFdMIvM+OoioBdqCpPxqDdNpOoa+Kaq2mH6uUFzUlLLuuMpB0YRyGDcqb/7B0Y6DD56aKnCFtLIclhlCVPT03BSLVYCHl3exkW3x67cgP1z3oUiam9z/84WYQMYNs+OTp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zch5l0+tvRvCzvuRbh8xpUTcrG1/7E+vEK4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a27ea734-9a13-4754-cc32-08dd0301a8bd X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 10:06:21.9383 (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: GEjV3ou7ljY2gkzMRaTPBzu8MiLqXA6cybk0HlSHNHNETq0nq67nFTCvXmahoDehRtU7XvYh5IRapVpI2U7ghw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7879 Multiple display modes could be read from a display device's EDID. Use clk_round_rate() to validate the "ldb" clock rate for each mode in drm_bridge_funcs::mode_valid() to filter unsupported modes out. Signed-off-by: Liu Ying --- Note that this patch depends on a patch in shawnguo/imx/fixes: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20241017031146.157996-1-marex@denx.de/ v6: * Drop pixel clock rate validation. v5: * No change. v4: * No change. v3: * No change. v2: * Add more comments in fsl-ldb.c and commit message about pixel clock rate validation. (Maxime) drivers/gpu/drm/bridge/fsl-ldb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/bridge/fsl-ldb.c b/drivers/gpu/drm/bridge/fsl-ldb.c index b559f3e0bef6..d9436ff9ccc3 100644 --- a/drivers/gpu/drm/bridge/fsl-ldb.c +++ b/drivers/gpu/drm/bridge/fsl-ldb.c @@ -270,10 +270,16 @@ fsl_ldb_mode_valid(struct drm_bridge *bridge, const struct drm_display_mode *mode) { struct fsl_ldb *fsl_ldb = to_fsl_ldb(bridge); + unsigned long link_freq; if (mode->clock > (fsl_ldb_is_dual(fsl_ldb) ? 160000 : 80000)) return MODE_CLOCK_HIGH; + /* Validate "ldb" clock rate. */ + link_freq = fsl_ldb_link_frequency(fsl_ldb, mode->clock); + if (link_freq != clk_round_rate(fsl_ldb->clk, link_freq)) + return MODE_NOCLOCK; + return MODE_OK; }