From patchwork Mon Apr 29 13:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13646992 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2111.outbound.protection.outlook.com [40.107.7.111]) (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 4853C70CAA; Mon, 29 Apr 2024 13:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714397776; cv=fail; b=KvqtDJkXN5zLnBCs0u65dz/Yw2RHUZvBsxteqi7s2kjP5Y5+x2HoR+MAvbhu8lvTFL+wRMOZml9MXabqHELgbEpqS3BLE9zTi7ZlBBmrVlzmI7T5O/5kRO/5pccT6puXapcXHSM3MiSoiVxlCuV76tfFTw83qDavUHkQrtN04Kk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714397776; c=relaxed/simple; bh=mPz17j8a4IHEa0xQ3LIdo6bFeELnHmA0q6rbRgSPqyc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=BwnUTMtdhi98L4HOeJTxw2Wyav0VzIoKryrFSOkdhT4Z+GcbHo9JqTXZvkJp25GQXZI4YdpcTffLuXrWmsWRDW8CmwEj02JjNuN+rvVQZTd6AhvOiTmtwJur8U2/cF/8u99sbFgZdT0VRdQr7hp3DgImNEKnRGg1Dbjuub5bAig= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net; spf=pass smtp.mailfrom=wolfvision.net; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b=cF11eXIJ; arc=fail smtp.client-ip=40.107.7.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="cF11eXIJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tb6tKmkrUONOxqwVdaJAuQpbiZI/H1F6kYs9i9TErdG7ULjUrAWj069lErpyTDVRROP109jR5Lp0xLXkgWclL4vblYVUREaxDLkT8zGHaJYN2TXmtOPEmewrsUsURD9Z9P+TbwhXVK0mGP1cnnhjQ+vul6dWZRn9i47la7t/T2xVp4/QWPaZGhb0BCw8Cb6pJOza9mj0GOLT0u4W1iF9XzkkbUK3iVaEj4lvex6dJwpmZV0lZPLojLd15vI22CY6IpU4eI7s142LVX+Mi8fOiis7Xz/MAGHF3i332GQOhsXznUxZeY6AFgL0gYbuDOotHVYGT+FvQdGu5ZPy4TtH+A== 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=ncjrC3kUTsgVty4+sjzIsJ+cO+ZALoxrpo3b3eMhqM0=; b=ny2eep901htm7oFbrQVtp+5sbVsBZfndimNNer2Y7jD22S7TRbYcLQ+I6yicAAB5tsVZRB7g5P6Sj5hAx+T5M9tXfr06su/cWk+pQOZ9JMtfl6GaKobf4eMI2JAnO4K8ttTLHNOLKvCSgEqcGnvC0KZDvLihnPuZCreDuBp2vFD2hndfrYdzZptM5fjfWIYeU1/Ivnpsgnw5v2qr2HPScgMKwG59uuSRRILE7P2m3YAqQmBXa4voGz17/klnXokEN1KnBPVlDQU70T0LWaO4SBoxtafxmGIUkjkt7faBs+15Zpve1we+beTvSozzU+sq+krmZ182+N+XVgfgZwsERQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ncjrC3kUTsgVty4+sjzIsJ+cO+ZALoxrpo3b3eMhqM0=; b=cF11eXIJ+bxHWzp+HZwrWsTWqY8lwQdN07RaM49c1/+eCj0mV2zIMZZs4YxPpTu180R1iGsQbhC+CGUbOBzTeCOwllssJqXUT4cHa3evxWsvjP52gzYaAuBaGB3lGUD/SpaQdHLNyKqj0Rr3mAYC+SsHLUZi40oePtyJof3unAc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by AS8PR08MB6087.eurprd08.prod.outlook.com (2603:10a6:20b:29c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 13:36:11 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040%6]) with mapi id 15.20.7519.021; Mon, 29 Apr 2024 13:36:10 +0000 From: Javier Carrasco Date: Mon, 29 Apr 2024 15:35:57 +0200 Subject: [PATCH v3 1/3] usb: typec: tipd: fix event checking for tps25750 Message-Id: <20240429-tps6598x_fix_event_handling-v3-1-4e8e58dce489@wolfvision.net> References: <20240429-tps6598x_fix_event_handling-v3-0-4e8e58dce489@wolfvision.net> In-Reply-To: <20240429-tps6598x_fix_event_handling-v3-0-4e8e58dce489@wolfvision.net> To: Heikki Krogerus , Greg Kroah-Hartman , Abdel Alkuor Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco , stable@vger.kernel.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1714397770; l=2021; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=mPz17j8a4IHEa0xQ3LIdo6bFeELnHmA0q6rbRgSPqyc=; b=zm/dkARaTTq5ui496GhXZdoMyCKpZqc6SvpP0mvKOdmivcIgsvJC/Xfw/mAypt+SEmEaG66mV tA42EgNcm98DehkhDIJv9MiTtIXqcXOQ4+HkhIg9idWqukNcEwoP07M X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VE1PR03CA0005.eurprd03.prod.outlook.com (2603:10a6:802:a0::17) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|AS8PR08MB6087:EE_ X-MS-Office365-Filtering-Correlation-Id: dada9d60-776a-4daa-8b8a-08dc685154e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|52116005|366007|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lAeYfhS390oooNSmdpjrVlb3hDI0RGK?= =?utf-8?q?GxTdMTLPSkafBI21pAN0/c1o1H7kKj3B7eDVbp8pgDyBIIPwF/RH+foVElZ0h0azG?= =?utf-8?q?5Z7RGOCOifiCIdt+suVnroh+cCY17E6Ujr7oUpV8oHJUo8ScfdlKCO9e7e3njw6oZ?= =?utf-8?q?mx+usSQlz8y1YRht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zURiIXoRFkgHyfA81Cu30jUNSTRDg/ZRi?= =?utf-8?q?ETirjvI6evJC/XZ3ykui3vgGCplopisyXOebxBA8hilsSXu2HXb54mRINrMkjFF0B?= =?utf-8?q?GRqSNzDUnSnCAfQfR2m0MIqMxvDATwshnApt38fvVzMTaBgSNjKU1JXuolMWPJffq?= =?utf-8?q?qKU61EG2Q2IpB0yXcugmrgchNI1zCG/Mm09i+gbrWzZypmhSYA1QLsD6VMANGutQF?= =?utf-8?q?yC6LmuNc3mpC6KSmAbp7Hn+e+WzQZny1A/w=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR08MB4974.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015)(52116005)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?5HahmmXtEpc0N0/jLRWedO+Nvos2?= =?utf-8?q?/Yy6NymedR+uFn+4oxfamm0nv/xOkfdY8LYZ7Zu8eiSL0M4URAZsa2VBZ89mFg5EX?= =?utf-8?q?ViS2rm65PI97WnxQA4bifJuTEJpL4F1DcQMzUQk0B7v5BIHOOHoLWrZ+Ob8jtXy8K?= =?utf-8?q?hmTNH/6De8yPBB24IuVVYq/x+oSHnbk3+CbO8OiIA8eDTPev/KXF8wIDunD3XaKCF?= =?utf-8?q?gImTp5XenNqTZPJPm74agdar8IMqOGCPbGuKugY+XjffTmMgAdT6nNhLmnxaju+LB?= =?utf-8?q?jbuRkqaFeVlSBiBHd1BON/k2WWR78QdeOpnGbHS31r9HHmXcVOiGdb3OlMDKfPBmR?= =?utf-8?q?MXTwfEgpsFZQTKvBKaY4ZeNxGNY3hhfP0xEhDK47xMkANyEUGUx7fEdmrzxjmCjVV?= =?utf-8?q?x/1wTB8rNiNkFW0ke+rFw9kpbNkLePYE4b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5aNuIMMc5I4uxbXUkHio2Ik9FoWNa?= =?utf-8?q?O4oUR2UGfeeipwfEz3gSRNrPbrcLO2/ZU6LVoKCIJ41jYlP1C/aWWw2jYKYumYhB7?= =?utf-8?q?/VkI9y2lVmf8fvbxB0aTIMUqUXmK5ZTgEanQnbymecNY2M1F9EOnzzq16PoAXffhS?= =?utf-8?q?/Lul+kpyZmx+pdSwSQv1xyArUpPOQp4ufJ5s2o6ome4J4NUCtv81/ME5DxPDJ2qZH?= =?utf-8?q?8+VukcxUgumZmNwGaYeAvxhrMmosckse74+3eHVi+cwxaEm5/wvnaU4=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: dada9d60-776a-4daa-8b8a-08dc685154e0 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 13:36:10.6985 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z3T0eUb2Ti6bdIFRkyjXXEzAVQNrKic49/vdvbBXWufbDpoeX4gsHv4mkAvG9LJFhjTeZFjKncW42l5oHhmgRUDfSCfUi/LRWptaam9bwR0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6087 In its current form, the interrupt service routine of the tps25750 checks the event flags in the lowest 64 bits of the interrupt event register (event[0]), but also in the upper part (event[1]). Given that all flags are defined as BIT() or BIT_ULL(), they are restricted to the first 64 bits of the INT_EVENT1 register. Including the upper part of the register can lead to false positives e.g. if the event 64 bits above the one being checked is set, but the one being checked is not. Restrict the flag checking to the first 64 bits of the INT_EVENT1 register. Fixes: 7e7a3c815d22 ("USB: typec: tps6598x: Add TPS25750 support") Cc: stable@vger.kernel.org Acked-by: Heikki Krogerus Signed-off-by: Javier Carrasco --- drivers/usb/typec/tipd/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 0717cfcd9f8c..7c2f01344860 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -604,11 +604,11 @@ static irqreturn_t tps25750_interrupt(int irq, void *data) if (!tps6598x_read_status(tps, &status)) goto err_clear_ints; - if ((event[0] | event[1]) & TPS_REG_INT_POWER_STATUS_UPDATE) + if (event[0] & TPS_REG_INT_POWER_STATUS_UPDATE) if (!tps6598x_read_power_status(tps)) goto err_clear_ints; - if ((event[0] | event[1]) & TPS_REG_INT_DATA_STATUS_UPDATE) + if (event[0] & TPS_REG_INT_DATA_STATUS_UPDATE) if (!tps6598x_read_data_status(tps)) goto err_clear_ints; @@ -617,7 +617,7 @@ static irqreturn_t tps25750_interrupt(int irq, void *data) * a plug event. Therefore, we need to check * for pr/dr status change to set TypeC dr/pr accordingly. */ - if ((event[0] | event[1]) & TPS_REG_INT_PLUG_EVENT || + if (event[0] & TPS_REG_INT_PLUG_EVENT || tps6598x_has_role_changed(tps, status)) tps6598x_handle_plug_event(tps, status);