From patchwork Tue Dec 17 04:51:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jackson.lee" X-Patchwork-Id: 13910970 Received: from PUWP216CU001.outbound.protection.outlook.com (mail-koreasouthazon11020132.outbound.protection.outlook.com [52.101.156.132]) (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 4FEFE1531D5; Tue, 17 Dec 2024 04:51:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.156.132 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734411108; cv=fail; b=VMEChkFF5gjbIK4RFbVl9DuJ3l27lFRSUVSBFVZh4CV68kLdAZ6tabIFGuYIDZdngrvgAvYIbbOySWtvcH4E9twqTmyoECLw5AOLbdcnBuK+AxrwjenXHoP4O+cuEeIx12gQRRvvhTP/2eu38x8Uc5rYgAyt404crRa8Jdv0+vA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734411108; c=relaxed/simple; bh=vVBu55Ig+PYsFFq9QKpfR6QOFBgXjzSqWXsnUVmJ0Xk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=dv3ld1/rRDWcinsyQDtps00VV/GBzfZVdQQ+Ki3ccPYAiZQa3tp6Uhes3g/caCEyDIJBnbWt/q2jTasyeEtL7nOhBicpD3drV4hQN/tNWniZiVVvXIEgiANmLUdTGtjiZLchSY3vXRD+DMISt/Wq03ok7JzuXaieMRHSvVfvo3U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com; spf=fail smtp.mailfrom=chipsnmedia.com; dkim=pass (1024-bit key) header.d=chipsnmedia.com header.i=@chipsnmedia.com header.b=X0PKllmW; arc=fail smtp.client-ip=52.101.156.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.com header.i=@chipsnmedia.com header.b="X0PKllmW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SOoRibyxfrZtlPoYKTSZ0XsQtxAtI3VO97S2yMA6+F1NwGr8caHAB9LxigmgoN6lGfe7eZXDrxg1brZc//wHVjgxeSaosbbWJJwKzQfcYe5452LsjBgCp1cqtYaXJ3KgG4gh9Neb1MXhH7cv0S2NN4aReOKGYWzzHwmAtGcOnI7ISgA17JL6JxPJ23Ql2ydwBimn0cFpyJFqZZA73KKGo1BvQ9+mATKMBjYX45VgRbRgOWItBbn1d+n7bej610KCPWXj9DldK8G0Vw91iNgXnhZ54H9xovU5o2ELynZHWUGLucKxqIevEIICCxDrm8xIngh7iW0r29p2KaAYkTHgbA== 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=mYy+GSU2vLdo/1ssMs8tywbX+RBJvozv/3j96s2GLzM=; b=ufet/Op1swPq0/lLkTGaM2lmSK7YYqqfGodJIPD9Tb1ydooG0cDt28xULXe7XrQ8GvAGnKlNPXKNJAG4jWFa9MvQ9U9a1xVRwfy0t2HBcM0546R9HBp9xi5qW4dSzU0nlV7UY5rSa9IJYYsuxUKn6gnIshVspPqo78lwlHYI0kAMN4gUJwUuSnQR4fNQHe9giuXSfbJ4EhPjOYWeIT8jPXXBiFebl38I/ma9WI+dmkTpYMeCO1HQZUlZosHwpQjhauKoef7xzZo2ht3WkRkzLR4WB00FKLnkOSV3wdadZJbPMtjRt0q1gCqUFbWC+Ov0g7+OD681+x3kzKbdzpym/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=chipsnmedia.com; dmarc=pass action=none header.from=chipsnmedia.com; dkim=pass header.d=chipsnmedia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chipsnmedia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mYy+GSU2vLdo/1ssMs8tywbX+RBJvozv/3j96s2GLzM=; b=X0PKllmWQRb7CVItRo1uJnl4ueajo3gQ6gNz0N6a+wZoAmlHhL8FnqHOZExo3KvkOmx7jH7mCBWh/vR8HfScpmXTj/rld1v+W3XycpSO4Un15Hr/goyb7VSVDu8O4v/DAjEs29Lwmb7yUcFqJ4vwnWEguWL6Di5u02sXyA6Z31k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=chipsnmedia.com; Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) by PU4P216MB1872.KORP216.PROD.OUTLOOK.COM (2603:1096:301:109::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Tue, 17 Dec 2024 04:51:36 +0000 Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::b711:5ab1:b5a4:d01b]) by SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::b711:5ab1:b5a4:d01b%3]) with mapi id 15.20.8251.015; Tue, 17 Dec 2024 04:51:36 +0000 From: "Jackson.lee" To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, sebastian.fricke@collabora.com, nicolas.dufresne@collabora.com, bob.beckett@collabora.com, dafna.hirschfeld@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com, hverkuil@xs4all.nl, nas.chung@chipsnmedia.com Subject: [PATCH v2 2/4] media: chips-media: wave5: Avoid race condition for interrupt handling Date: Tue, 17 Dec 2024 13:51:23 +0900 Message-Id: <20241217045125.58-3-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241217045125.58-1-jackson.lee@chipsnmedia.com> References: <20241217045125.58-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0103.KORP216.PROD.OUTLOOK.COM (2603:1096:101:3::18) To SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SE1P216MB1303:EE_|PU4P216MB1872:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ab016bd-07cb-4b11-c531-08dd1e567cab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|7416014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: I8lmjhC6JMIbWtQqvo2ussAB+HAAfns1ARd88nG++hUltp+5IA5reAwch71+dwcZMgvtRzO4WodqUCaEUYeYHHYojwm7z3c77EWYCqN68cpvM20EWtgPdYaOrttcsh/XYND3IfgdYnqJqhyI5CFaneAmx5zTCj6+qh+cZc/QN0oc9AoqAQYeuOR6EMStfMfQD8/QUeRoW5MPLOxTr3jlvcmckQFrydeo8Zf9PG26ycoNraUkTR7LXsOEyXi7y3P2vyq6RV9q3PYG2/Mq31kqn8lcluh3UeHd5lqByjRvvxWWVnDkdmxqi5Hy/Epc74aqCcaXIGCN2OvSPqPH23C2+sBPuERuIxUmf24rPfvwIOOg2uKmnitZFGzebWbga071an+vAIcb+mJYN1sUeOFO1QlA4DRuOefaLFBNhLhBdWh1O+2aF2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G:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SE1P216MB1303.KORP216.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(7416014)(376014)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Btrdds7/IfS5xK6szhS0uM06maGMEOj2wNc3lfA75j+hPWTzfmdTqe4Q8XuEqlGwKup9AUCOdGYWkgM8bwSfRtfPyBJXTzRQjYfV5WydbEd2fotfi6TYUI8t6cwkpV+alH625tz7gXoTN2eHOYpZWoR8w9kWLtGbC1oViGjnulCAE5OIoLMJBzPT+T5sgP5H4IDxz+7GftjJr79dwbwkKzCSzvdFWIeLuv29yCacXMjeYzHLn4UDd6p/7xG9RIyHSZKWqBcqTnsTu65mDEjy0bQ21wQPVuV2VrncNtpXkizSI7RXNKL/b0eswkTEs6opNrhY+BHN/gM2+lMxmo7LhcLbIAkUbYv9bDGlOdfrQDkzhDg6Z7JJlos8I7K4T+GPFeAOCCPEpOWKH+jYkHXK4MyaTGPTuilrIYAF3MWx6bXPcI3zrMyaf3RKGEBtr9hNR6OimmBeUF3xQdTCOuRwkmFUnVKsq7d03Q+vL8tgMlYyCruCZjVjQMluaJfRlWoWWmkBL4yI21mE1N7Epir9/g7CS4F4OgJ6N1ov5ySpZYB1o/LM4KZyM8T0Jd5zj0y7Ba70N2sxNbBtGy3p1sbp3FGE2pFuYpTOR1wgHlSB0AJfdQHVby3bRkughM8Q7crFKbljAqXEi4K9vrQfE+BW9ysYJNRlwj8HJ7BOC/cr7Q0BkvCcOK2xbr+qdWVdW2gA7WIi+3SKQvnrebrbJxmr2F2ah9PdL9Co5nrte21G4ZKYHzgu30WbZwmIPblNE1Pqas1ThzBF11Z+jGF2kOd2bDwYTn8DRvXebUh9YqfnAyqPR6paKoFC0JL1b/CGF0EFJJ8gXmoHQWmgD17u7NtLTazK3F0i9H+zWWv+EKzVcZ3K8Q3M4zefsMFsjU7RHA9HKOfjFPfD/Ni0Tm8GoqIJ9FgQXzuEwTnmo5PBYq1RShQc9FErjtlUvnfp56Yp6Be0LYplwQOkyg/Wfy4ChvB/+9t1VIzYKV/cmsl4XFQFSugBxzPKCn2orw0xUg7+vAsUuZRLyhlTrQu2RI6UfeRtdF7W7PFYA/lsRUw2MDPZU4HBw/GxBmTN/VlSkTN+y0DMDrfKwP1Dqf+CPyqlCAb7wkJ6OyRvpD04Fx0SmYf8T9exWquerWEYEKLouFcdEJHaPPgPUZcTnG25EguOIafNG7biIkmoiGutbFs+BtCTHw3YKKRYEMH6efxKc5+dE6msq6lXVsIpDF/TSz0B34ANXu2Gq82Rw/MEGPdLX9DBfHGERd9ek3wsD4bg4XdnoyQUn0wnY7Ky82Wx/T8+qGKYJrWHFjRAUcTmE7Kue5GaWL6ey1/W24XDdXBqUnnF1t2W2XIf8zxgX4gXYy7qjRw7O/OmJyp6PYfMeGxCPMNsvG973AH4iw1Z1vcQLnhM28Q+Wy9umaA0pRpTlDGzy4TlsMFd+7qaXfCXn2nIusaOReEzFe7agyrD524xzhPmRlkXRCaitoKUoJRVjfGnElFkN/WvkKEzrs8gszBNpOh5oLjOlxSIzhTnjEotdQbcyLU5Yw661PlSxrtKMSvOcMISIbg8aucgCN34iQNNCKJNWoVkcj6v/ji7WqDHmqFpJMbL2R7oKTF25Wj1n/NrgI2AAg== X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ab016bd-07cb-4b11-c531-08dd1e567cab X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 04:51:36.5382 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4d70c8e9-142b-4389-b7f2-fa8a3c68c467 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZxTytnpyilLb7z1Dqq4xlGwfhnj3LM7v05ZCpXV7ZeOSpGZfLw6M5EXOSVZoNdzs2Gc0HR8kSpXoNV8dBV8HkminpACynYiBAC3U+d5fZRI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU4P216MB1872 In case of multi instance, interrupts can occur for other instances as soon as interrupt is cleared. If driver reads the instance_info after clearing the interrupt, it is not guaranteed that the instance_info is valid for the current interrupt. Read the instance_info register for each interrupt before clearing the interrupt. Signed-off-by: Jackson.lee Signed-off-by: Nas Chung Reviewed-by: Nicolas Dufresne --- drivers/media/platform/chips-media/wave5/wave5-vpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c b/drivers/media/platform/chips-media/wave5/wave5-vpu.c index 6b294a2d6717..63a607d10433 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c @@ -55,12 +55,12 @@ static void wave5_vpu_handle_irq(void *dev_id) struct vpu_device *dev = dev_id; irq_reason = wave5_vdi_read_register(dev, W5_VPU_VINT_REASON); + seq_done = wave5_vdi_read_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO); + cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST); wave5_vdi_write_register(dev, W5_VPU_VINT_REASON_CLR, irq_reason); wave5_vdi_write_register(dev, W5_VPU_VINT_CLEAR, 0x1); list_for_each_entry(inst, &dev->instances, list) { - seq_done = wave5_vdi_read_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO); - cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST); if (irq_reason & BIT(INT_WAVE5_INIT_SEQ) || irq_reason & BIT(INT_WAVE5_ENC_SET_PARAM)) {