From patchwork Mon Oct 14 09:09:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "G.N. Zhou (OSS)" X-Patchwork-Id: 13834492 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2053.outbound.protection.outlook.com [40.107.249.53]) (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 1F1981ABEC7 for ; Mon, 14 Oct 2024 09:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728896972; cv=fail; b=o44jQ9dZsYAEEhtWHchJPBJOFad8JCThC39UmC6YTHz8QiI735lEP1BTDuOgBfbl8xsoI/2DqI1YdsI9zJ4714N2wXT9fP9D1bXRqN1kCTzAaRmLTAhH/GEPoh8VNL2HqX1xoxl93JWNBKLWPG9XUY6uV8FbmQLjMP+tUTx0Lxs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728896972; c=relaxed/simple; bh=u0z2S4au1f+koSwRKzJkJR0UpbF+/pwH0rWaOPj2njQ=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=lxC5YsfezsRhAK3fBFY5JhjPHRdCT/bqp5Is5HXEOx/VqsLdyNQRQ+SL7HYxXBlG+AiVmI5qLarnOLxzh9cRbaRoXnXc2pwemWsPrrxuwVKsUFcGwpkHtzcWlGzgipPDEurvIJL1iDkAnBa2tihcB2DGPcLYZ1Rnw1sSBHKvnYI= 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 (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=XPbtwjiX; arc=fail smtp.client-ip=40.107.249.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="XPbtwjiX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lWg/c4nOj+sZS5aKOidyP3avsPVzGc1Ckv2YzQWV5LCY+2X+1e3ih6y5cY/AJ0b6dz1cCIYhFRphhKObATgBpSNtvfNlJYMfQwAIxBGCdIBQpG/Wn960qYXt5229ZJnIHz+n5I/zRDo4xy/xKeqqwhTIy/CtwjukmtUmdlkr6PkE7n2qjENfDTSewkT6eejstDbmEzPg6mbEPD6e5WPb87qNqaMjEKr0gF52RMyoY6Ejiu6LkZdid57yI25anyxP1GZ6ZrYq3aapOnoF+iRP/kwq8wKRwRrNWJo4jeuXtX3GqFAwLD+LxTaDgWAWME6cfOuMiGZTJfUTAnCTwsJO8A== 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=OBmZKker1n9bOwmeNWdnZ/y2Rt4qikijZOhEi8TVGoY=; b=VpiRy+W07x5xk5yMNgdr4LXsPCyxmAGlqXorkq+kNkBqHo2ksTnNrYJI3+6AaekSXkUwTvgH876+OBPbjHU7Toc/TeP1qngUMkmrTbN/53feqaHNZ6hfK/cHtk823ZpjcmKpUgARInBt2MgPnLdKEO2OJzqhgi/Nf+Wo41Cy+MBoH7/CfoY9EXZyqXVPUtVw4LLifE848PlPFgTgt39sKTKI5HMgHo2HvM/1wkS5/1O5JWmy0/sXPljSmJXgokrWl9y7jZgqV9NIVsK0fshijAvBUipv/SE40zDzHKlrssKJ5lvGC7kN6AL8t7nqx8LfLT1swWBGFS2PGjWjRTG7DA== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OBmZKker1n9bOwmeNWdnZ/y2Rt4qikijZOhEi8TVGoY=; b=XPbtwjiXlmD5kw+U9zeFYtuoGxt8bjb2J/dGGk39Il+DBe64fYTup4x+iBXhTddw4upM+j8yVJRG9Ak2ZG8BI5jQGa1n+XPO69ymdVinravMpZabbnIPjPmW9fA2zmMuEKChhGoIpkF6bHISmBuNdKViQOlIG3Ol+yqHJ5UyzUCME3bsxqH2slSXgEgXK9KTsoUzuA83u3P5T/yKBS/TNlIzosvFQVPct8wntXygJdDJkduwm6/Uc6vQz18utK4v31qWoCICEKDT7tN1CqRHXphOUiC4wVvbUT5TrDpZ5CuDhq9aIWAD/bsE46qN8nZt0XYOXpsqff4YnBadxuKZ9g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) by VI2PR04MB10265.eurprd04.prod.outlook.com (2603:10a6:800:221::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Mon, 14 Oct 2024 09:09:24 +0000 Received: from AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::93bd:316b:682f:5e59]) by AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::93bd:316b:682f:5e59%6]) with mapi id 15.20.8048.020; Mon, 14 Oct 2024 09:09:24 +0000 From: guoniu.zhou@oss.nxp.com To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, imx@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] media: nxp: imx8-isi: Add suspend/resume support for ISI mem2mem Date: Mon, 14 Oct 2024 17:09:59 +0800 Message-Id: <20241014090958.1551492-1-guoniu.zhou@oss.nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:4:195::23) To AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB9080:EE_|VI2PR04MB10265:EE_ X-MS-Office365-Filtering-Correlation-Id: 4cda3fd9-cddd-403b-838a-08dcec2fe5ce X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True 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|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?pQ29iKUswg4qSo7DsHvktLv3jUzZI/H?= =?utf-8?q?MNGV7TfT+K6KB4r/7TiWA1ckr8uuF8iGiSOxcaIt4b46gk6LF+33nK+Fjw7K6oGCn?= =?utf-8?q?7sST0TrdNyqI2BkqzOW1yCQCAV8goJBDPVUAxgQ7VIcqk9AHnRegLTjIQ9gwC4iqp?= =?utf-8?q?3IFFIbVq+OvilLA7MTyJm8Kn+sAR1edm7JJt7DAMedy/16CmQgzOlpFif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?g0lveoBrhB9YZqw246K2DMshqrCrLQxbTB09jNJUSjlrcr8iiscHgLNoBE3V6eIci?= =?utf-8?q?zLqUjz6xqIHQiSjxfRU1QDvvncALcahhs7cX5GeS8R2TObPCAdP50V1qOcR4sB0F9?= =?utf-8?q?D59YwYK34fVjZPqqO+DY9V2ou+3ujhQ7Y8HN1eYX2PdYvbsxCJnn17TMTae4b2Per?= =?utf-8?q?H8SJNDOHES/1dUJG49u8SUlQ0DA4RyLKWqg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB9080.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(366016)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?X7iWWRyZJQ7pykA0lO+5ap3Sd9VN?= =?utf-8?q?1i3VbLIUUQPPgy/vryK1uj6Cl6q1ZRobpd7ByLUK1x4pb+slyVoCvB9F5LAXSTjSH?= =?utf-8?q?hHt+wMV2ldwyEBXw/tjFNipLIIhj8iJvGPfICoVctSVKjVhINrdqsB/B57jGrUzqV?= =?utf-8?q?82/PiqlqIhUqC3kHpqIhurl6o9izcpJCoylMQeR3iTwN2T98o7j14SDIUu0ziXA0P?= =?utf-8?q?qREW8mzunEra054bF2OZZmPNxgtKVk8xEn7MYAvoKJffhykhYRW4NcD36zzoC8E6f?= =?utf-8?q?EMAvx9kx1fkpSJgSr4KyMn3xucXgItjNA3fXg6pNUyU7jVa+vF7GziQ3Nt+NCkESF?= =?utf-8?q?EuH/IaZ8PWdVGV+Fgikel6/VBvfXF9uy0cx/ntEZ7kObRpL/bIlt2qHQ/ye2pnPfJ?= =?utf-8?q?9nZlYNKaNsMs3GjH+u8P3gneB2WbI0uAuiVRuN16XYqKbaE10K7pf7wDFNDSaQQkv?= =?utf-8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?G12PGL/0X7cDV14D6KQLc5wl1ssuhc/R8raCEXcPRPWADzIWOpu1GUx8zMO51iyaS?= =?utf-8?q?QUrt+ws7wTzkBCuQ4X4BSUd6r4wM2uiEgEd2UniVdlybF4GN7AF+xn+DofqOE0t3n?= =?utf-8?q?KsfTsWz88qJD+ZAvEC0LQV+hArrzNia8fW9LOjNJ5UaBhs3LhiR20cyHwklDTsjSy?= =?utf-8?q?M0WJkakc5ivw?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cda3fd9-cddd-403b-838a-08dcec2fe5ce X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9080.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 09:09:24.6555 (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: CYNSqADtYc/Ijlqpbuv8Ybx8sZNaA4j/lUqcG6OTciH9vk3vjKrYpHGqF69/6hE1wJgwhuDs3o08cTawB3en0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10265 From: Guoniu Zhou Add suspend/resume support for ISI when work at memory to memory mode. Signed-off-by: Guoniu Zhou --- .../platform/nxp/imx8-isi/imx8-isi-core.c | 8 ++++ .../platform/nxp/imx8-isi/imx8-isi-core.h | 11 +++++ .../platform/nxp/imx8-isi/imx8-isi-m2m.c | 48 +++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c index 528e723114d5..35a771714614 100644 --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c @@ -347,6 +347,7 @@ static int mxc_isi_pm_suspend(struct device *dev) struct mxc_isi_pipe *pipe = &isi->pipes[i]; mxc_isi_video_suspend(pipe); + mxc_isi_m2m_suspend(pipe); } return pm_runtime_force_suspend(dev); @@ -376,6 +377,13 @@ static int mxc_isi_pm_resume(struct device *dev) */ err = ret; } + + ret = mxc_isi_m2m_resume(pipe); + if (ret) { + dev_err(dev, "Failed to resume ISI%u (%d) for m2m\n", i, + ret); + err = ret; + } } return err; diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h index 9c7fe9e5f941..895b47ef4658 100644 --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h @@ -343,6 +343,8 @@ int mxc_isi_video_buffer_prepare(struct mxc_isi_dev *isi, struct vb2_buffer *vb2 #ifdef CONFIG_VIDEO_IMX8_ISI_M2M int mxc_isi_m2m_register(struct mxc_isi_dev *isi, struct v4l2_device *v4l2_dev); int mxc_isi_m2m_unregister(struct mxc_isi_dev *isi); +void mxc_isi_m2m_suspend(struct mxc_isi_pipe *pipe); +int mxc_isi_m2m_resume(struct mxc_isi_pipe *pipe); #else static inline int mxc_isi_m2m_register(struct mxc_isi_dev *isi, struct v4l2_device *v4l2_dev) @@ -353,6 +355,15 @@ static inline int mxc_isi_m2m_unregister(struct mxc_isi_dev *isi) { return 0; } + +static inline void mxc_isi_m2m_suspend(struct mxc_isi_pipe *pipe) +{ +} + +static inline int mxc_isi_m2m_resume(struct mxc_isi_pipe *pipe) +{ + return 0; +} #endif int mxc_isi_channel_acquire(struct mxc_isi_pipe *pipe, diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c index 9745d6219a16..2d10c0639096 100644 --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c @@ -722,6 +722,54 @@ static const struct v4l2_file_operations mxc_isi_m2m_fops = { .mmap = v4l2_m2m_fop_mmap, }; +/* ----------------------------------------------------------------------------- + * Suspend & resume + */ + +void mxc_isi_m2m_suspend(struct mxc_isi_pipe *pipe) +{ + struct mxc_isi_m2m *m2m = &pipe->isi->m2m; + struct mxc_isi_m2m_ctx *ctx = m2m->last_ctx; + + /* + * Check pipe for ISI memory to memory since only + * channel 0 support this feature. + */ + if (m2m->pipe != pipe || m2m->usage_count == 0) + return; + + v4l2_m2m_suspend(m2m->m2m_dev); + + if (ctx->chained) + mxc_isi_channel_unchain(pipe); + + mxc_isi_channel_disable(pipe); + mxc_isi_channel_put(pipe); +} + +int mxc_isi_m2m_resume(struct mxc_isi_pipe *pipe) +{ + struct mxc_isi_m2m *m2m = &pipe->isi->m2m; + struct mxc_isi_m2m_ctx *ctx = m2m->last_ctx; + + /* + * Check pipe for ISI memory to memory since only + * channel 0 support this feature. + */ + if (m2m->pipe != pipe || m2m->usage_count == 0) + return 0; + + mxc_isi_channel_get(pipe); + + if (ctx->chained) + mxc_isi_channel_chain(pipe, false); + + m2m->last_ctx = NULL; + v4l2_m2m_resume(m2m->m2m_dev); + + return 0; +} + /* ----------------------------------------------------------------------------- * Registration */