From patchwork Thu Mar 28 16:55:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13609152 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2134.outbound.protection.outlook.com [40.107.20.134]) (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 27CDD2C182; Thu, 28 Mar 2024 16:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711644972; cv=fail; b=koQ2F4V4TV/WFmfCNpPl4bdurDkMcyVn37SlwhxBlXco7mGfspILUvxgt33JtGI3SKiEWtgwmE0KiK0k2vEeao4JV+PlgVFKaBjWkOqVRqNFa0FuowpbNAHQsgbBqDJinpix/pVagVJjC0Q2zWTXdx0INQZ6djhLrLgt8YoEz78= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711644972; c=relaxed/simple; bh=XGGPJvkGtURQ8RfhDgYr49n4srDFMVXXTC4u6YyVuRc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=T61ZmF+GLPYpI+NUDUEi2dMOOgsuSlWJiuXXhuTcSg5D60PdMb49DgB8BzlB7QH+NdvNAfu0jeEXXM1TT184X8bcwiyspfzMECCG1s0brdI5qtKA1VV9TGLfyRVj7QUpPHsYaExtqpL/pl/TUOTvj5VXHHIY1M23NTbPlnDhjdQ= 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=JV8KQfRr; arc=fail smtp.client-ip=40.107.20.134 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="JV8KQfRr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V1x5fJyLTjw/Rc6ICcq2BTkfsNpFeIe8H0iOYF7pspLwxvnY5x51U0SaTOr1tjrTGzYzDL39pdKuVy1H5U6XHQMtBwMK+WzfjISTgUcgfGqpUSouJ02JPNpLuHhvFOOOupc9YJBMCxG0A1FDBnTOaSwvacBqcZSwXGgqRlsDHgh14rX//JC+VPtIZ0Zx3qvyamUCrO+c203IoEzcO7tiLTd1O5LJ1hwq0BGO1hDNSvyXPPX+7c071P0Lof+FAxx1E9Oavp4wveLCWonA/1u5Fn16+UHBpDBkkFcN4aqf2J9s2mz7jA2SsqEVaKbSwtKCHrDohAyHBklMUqdvj4WLkQ== 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=+4Ta3uG0TigHUQ20gIUhmMMjWyvCjkfdwjoH3P+jiGo=; b=RkeK9rVitcaZeUYWto9ooPBVrUl8ueZytxZNjTS4vW57hM2nePMSA56RCyfvZ5t/msERXwUBN6B80QEJPKn/V7A911oUYpqdNZhoPi8ljdG23kVnXkhpkd/CX95HDZedy16PVsOh7ckYnDy0Cu5w3j9m/LAkH337hKc4D6YTWJX//u8d93xbHKKP/9J6/oPajiFMNvk2LVcTQk6o5WRnZoGNlnDHMzTjL0TOF+uKqrGEQvPF0541n/BD/akIVHeymDcldtlOND6H1gkGgj2jlrOYyhw77wkFA2+VD2Wiqn3RGtbTP9niLxFqqdYAECwXZ9uCvL3MSFyZ7cNg9X82lg== 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=+4Ta3uG0TigHUQ20gIUhmMMjWyvCjkfdwjoH3P+jiGo=; b=JV8KQfRrnSoOW3RfHd3Rp281RYVkbDXPh2pJWTjA8DT2UaHhzTFdoaoGHFNSvreDZFg6BlD0qKdT6tMuA+ohvsTUvpCt4sX0E/xlTJ2M+LuRaNdy3+KBNBsoaCoYkooivCEfChDWbMRTww0b77OtdKQqfxHs95kDUOk3exxcF90= 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 VI1PR08MB10147.eurprd08.prod.outlook.com (2603:10a6:800:1ce::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Thu, 28 Mar 2024 16:56:04 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9e35:6de9:e4fc:843f]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9e35:6de9:e4fc:843f%7]) with mapi id 15.20.7409.031; Thu, 28 Mar 2024 16:56:04 +0000 From: Javier Carrasco Date: Thu, 28 Mar 2024 17:55:51 +0100 Subject: [PATCH RESEND 1/2] usb: typec: tipd: fix event checking for tps25750 Message-Id: <20240328-tps6598x_fix_event_handling-v1-1-502721ff705b@wolfvision.net> References: <20240328-tps6598x_fix_event_handling-v1-0-502721ff705b@wolfvision.net> In-Reply-To: <20240328-tps6598x_fix_event_handling-v1-0-502721ff705b@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=1711644963; l=1960; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=XGGPJvkGtURQ8RfhDgYr49n4srDFMVXXTC4u6YyVuRc=; b=+eUBHuwmL5I35/9Lj6MQ01Rr1KdtMX2ppSimTf/3ZNgqT3vuCSZHwKuH305lbB9+ImJyygo8x iFDAwmC0lXdBwMuxAZOSf5KLOnQX6KhqA249mhXEO43cscfAyY2u1OD X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR07CA0136.eurprd07.prod.outlook.com (2603:10a6:802:16::23) 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_|VI1PR08MB10147:EE_ X-MS-Office365-Filtering-Correlation-Id: 82f2cf5d-bec6-4c60-d142-08dc4f47f447 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sFx+N7C7PB99KO/Qn1bqd34ZLnqwnS590xBFpxh3biymQ/1WoOHiDJ+T3Kf3xrSqsTH/9P7NWMB7gAmslkN+jRHdp69L8csh+soyEvam9RgihYrXv/rFKRYv4mCTiyxBMvDMwW8C2e+Bv2QwbTb3hvNWWTehMVv/4LQyuntbIT9VUMR4oX82vr1W7TFjZzWLJYpGPusFBb/cNARrWZtslO8IQOHZeeQxAemlTtUAnpaZGVirgmF23sKMXrnacvLIDokPELoZaF9T9Mw9bdswi1vDvELycpXNni66g3bod9fcgUl3d2AA41GhR0w9duu4P/zQek19WZBWceqGB/ZeBW2/8Cfa056lEm9kH6n7BQ7mZU6lx+5eGA54K1pIg+C6I8RZt2GY0Q7Mhbj2zlstct8zbBL08HlohGQssIwP3SFmD/a7Vm2AV6jG1/r2Z3vLnCtEX5c6scLbYl0ZMZyi+AQeHo53+kh6X89MyCWa+fzcsjXLsaIxcFjBOHRIyEhMF/lqgZsUYgtpTZih5MvzlMrDBlMrOQYWXQJdhA2yD+irYTEzMMRJG8wJ903+5KP8Pa9CHuhm3EO3gmNFK8HZ4uwHSgjmjGpw144lFUdbahVW1Eff2hWc+D5o9uHdd6x1AUNAVDBHWmOrXyWlmr9YUtCCUhQ/F4KglB68t8qXZx2xY4f8V3g2jsj1nWezX3DDeM0kKSX6pqFTjYAgeVRxF7eUDhw472usU9TK1gzBlLM= 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)(366007)(376005)(1800799015)(52116005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?LW0zJh7DGc+Tpc9PW8xN4+rvJS6H?= =?utf-8?q?iiHKjD+T/2kkHEwv43b3AliT57YIocE6+8LZdrFj9qA0wc4m533J1RQ5pctuONvrg?= =?utf-8?q?WyCA+08fSEWs3PYQZC+s/WkHtIBNtEP/JXZW4sUp9uDBlOS4+tfNuJaPnkRtQ+hwf?= =?utf-8?q?sOyuFZpjQvzlsH0o7UqYTjbOLzCW57c9Zj/SmNuqMVmWJUaBEuDc1j5wnVBWw/25s?= =?utf-8?q?xEsjpZcpx5r04AcyFb3IGbS3j7/biuCKqNWy8o0Qp7+brn8ujwKF5BT6sk1Tk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f-8?q?GS7XsqSkaufDxV3q4rzs8qF+/HgklyXdi+DTZEoQRq3FBXB1PZhhRXcuWGSaG1/Z6?= =?utf-8?q?nJfQQ2kziffZOwc5faCgt3kncZhOnk5iwpNRFD/sUAP7baE3ePGlGbktbWb379T0F?= =?utf-8?q?yQylPH0BpSXHs3uHe/XkAe1HXXPHwwTIVjXi7AMxVsgylBNrQj2bcXtyYF6vqjrnM?= =?utf-8?q?CrfkP/eSA95NGtotLg8cTqd5gxezktRNOcSLCCMm+ENTnPuwaSwI+ekaywNyy7Xzm?= =?utf-8?q?t7ICcbqqmUS/EqSmlJF6lOMjshicHdWLP3ORJJON8Lng8d8qD5tKmVQmOnPDPkWR3?= =?utf-8?q?Uc5mQBIbV7J8jLg8VHLCCV+33vEvLFegqGDIPEya+8km+08ct6D/eLLF4PCxjNotd?= =?utf-8?q?l2o3EBzr3SMl2P8pgYUIGnQcnJ1jYw+GBk1GWHuUquqB7bqny854Mws=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 82f2cf5d-bec6-4c60-d142-08dc4f47f447 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 16:56:04.0384 (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: NpWLwWMp3mmjR96wLR0zIZaBrOqcM4w9sV3QBF4gpUryhZIwPO5RTCNVZwtXzYRij5JzmNIMwdd93hVOsEt+2yvmikNaKxhrhag5yuTgJM0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10147 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 Signed-off-by: Javier Carrasco Acked-by: Heikki Krogerus --- 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); From patchwork Thu Mar 28 16:55:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13609153 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2134.outbound.protection.outlook.com [40.107.20.134]) (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 9412A40842; Thu, 28 Mar 2024 16:56:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711644974; cv=fail; b=uCAoyf4Su/B+lGyDa8KeFnuhRDb/Ebmn9ZP2eEh/C7tn+gud+xeMGn0ZYNN824vtZLPNZGcrQKwkInUs5X8oxvpOoqJ2Q1emTf3iyeSpew/PrJrqPA6bF+0kPjxEYo/p8VDm9AwJP94kqNb6uEXr1UnMxYYTPKc8N91lR023g3s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711644974; c=relaxed/simple; bh=EP/47rbtwXoLrEu+2KhY1GcZMkqPqw0L8TmuyFVtP1k=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Z8BeFZRPJbjw6PPQfKjDrGlWanX8Ncp++A6QoX7VD8Gb5a6pTuDOHY/F/Prd894rSk5YhmcavHLm4bStw6bBI2tqfkDhdj8dn5Uyxw0XCba8NTjgmrTXHdCcXusN3vjVJyW9XRKHv4fH2ssrXCF6TND+AgGSTZtPEXyA9OiYbbw= 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=k8VGRsL3; arc=fail smtp.client-ip=40.107.20.134 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="k8VGRsL3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c8Wn1NC0x+f2muNdoeleCejMXeO4AZixcpYXAu1s0zNC2olx8zGLRoYMc63Ztb8cmFtGJGpRKfpfhgPGMZ0RZomnWyaH+yNf6aGLP2V+/3QiQUZzxsHVXE6kJY6o9Rt/bAEL/35IVqgMzhtC8xdZGglv1uRPBFw1vTSN75LuwviP0FFNmaLKc2Il6S36Ps664Z6t+kXn27/m+NvJU6v0mNzNHgWE6c6/Hcnh/ABwPtWJEGsG6SxLAi8NDWaMuyTtsHhSeQ5UxG/BsadYSN5uVSRQNsDGAw88zS+zQDpepXdCu2XfL0IHEh7y3RWlUNYn4gFf+mAaJlUIQeQgFvuCIg== 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=BQkZk6sE6iUSJbrS/5nH9d92T33fcpDM7u/sEGH9Af0=; b=WYusvR6LpDpkbVHYXvQQK/evohshiJ0EsDI72r0XdFTsvzLAvmklpUlGn8rEqgzSKo+iG3sBF3kp8Kj9AX38une/B/cSi6ya4QNzD/mKaKtqcWLBscEAeWj005Nx6gRKSYDChkWvcYmFPt8O9hEr8v0WpBjQVnolzTd4ID7cq874G91vaZKmX/fPhNwN30kvu78lGf3m5U/UffZNA/k5qnbAk4Jze8fj4h91C0EaTt6bu1aUCfwUC2D82FL/2GTPpLCDhqfW7CVJa9K8V6OVhMRP+AbvwHIVM6SGKmM7bs5CGUvCXvD0cdOfMY49dpp08OyXuS7WQu0EYYqpYTko5Q== 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=BQkZk6sE6iUSJbrS/5nH9d92T33fcpDM7u/sEGH9Af0=; b=k8VGRsL3KReBrG1Eg8MPJ0oILh60Zls6YAH7xfuAWjMyv42xD+FhCp8oPArLWYZV5VVrfrDxTs1lrtndMZFUaPE0Krhi3aqAcTtkXK2/YwkgAmYhUDX9bbHrz45Rzo1Wm8EhC67+VDdWbHVxzIDnjUlxjlaF07x5KcclOpdntpk= 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 VI1PR08MB10147.eurprd08.prod.outlook.com (2603:10a6:800:1ce::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Thu, 28 Mar 2024 16:56:04 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9e35:6de9:e4fc:843f]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9e35:6de9:e4fc:843f%7]) with mapi id 15.20.7409.031; Thu, 28 Mar 2024 16:56:04 +0000 From: Javier Carrasco Date: Thu, 28 Mar 2024 17:55:52 +0100 Subject: [PATCH RESEND 2/2] usb: typec: tipd: fix event checking for tps6598x Message-Id: <20240328-tps6598x_fix_event_handling-v1-2-502721ff705b@wolfvision.net> References: <20240328-tps6598x_fix_event_handling-v1-0-502721ff705b@wolfvision.net> In-Reply-To: <20240328-tps6598x_fix_event_handling-v1-0-502721ff705b@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=1711644963; l=3256; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=EP/47rbtwXoLrEu+2KhY1GcZMkqPqw0L8TmuyFVtP1k=; b=8lqg4QI0D+qgSGB7iKPFemwfcPJahXRzr+h/P4sIfh9OYf1XOdPNBB9KOcVZk0B9Ll3cLR7RH S1X42L35aT+BhOPhSwGNZJaYMekCcbLoOdfn1/Rufu7KeZ7boAPYJhq X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR07CA0136.eurprd07.prod.outlook.com (2603:10a6:802:16::23) 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_|VI1PR08MB10147:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d23f9f2-2756-4542-5e9e-08dc4f47f472 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GaUu8npF+VXeGU4TsVqiQUI2GvGj3w7Y3ImgsvgoLaFOYz5uSb3I8WGeoaXKtRwdWzGrzon9CswIM6iDhIff81+//ZQHxtjNXdVXBHq6wtyWu3TDsyNoABYPDKBy4cmTI/++N3pq6b6JJCrNtT+gnwNm2UJszcyoPzd8pQgI0oQA86pFcvbkUa+uUBsJ8LWFd5anbLT1s5rL7zy69iz/WXi5SDIvmDW7MUdjvXMJIbl3bmplEhn6YrjB1jsQ3GDgqn4lZphwXkHtLoh2j3itVXVCL0zWCUGFxQR5J28MGWMCxqgListt1ITUBEZur/xhJ0SmXv+KXBkRf0iCQRzQy7ThAiXa670QuzO4Ff7TpSdAsSnXnlBH+SC9sFKvU3BFjmt0JbwvV1SMO6w72O9wEKETYbmCQVLeGux20Xf5zcsf42eH1gqzORuylXBDuhaWuNE7ob4lIInvpogl2N5CyWAFXLNPT/bNXzFyE0l2yiIo/QCC+CcR3EzfMoMrKuuIicKoeiJmcFJhhGyKbc1vNzvM/7PQk49e58GiHaJw6JrDK5pVLoIWP/hXT7SVkjDV2Sb/NPwSZDKH3e03JPAi99r2wkjwaQakkY0vVISEy8dFM6N4eqiOjiWHLQd8JoTquR0BDmUBILfgzpWYtIk2vumo66PoPuBceWooRFt43ajuBZPgVVy/raEEqORqqu/omFj8crCLD8PK8aVTmMy7+w== 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)(366007)(376005)(1800799015)(52116005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?jAr11opcSpTlUvMHmEELDQkObcaf?= =?utf-8?q?NOchrhINnif9INPquiU9lnDmXSjbCM2LzvUI21XSwQ6iZegDpARu0H8m+OYhVlkDW?= =?utf-8?q?YnHTZp1aXa5bS3s0C/y3SFaDu8dkuir/SAgaNRGL/YT3mxhIW8YQtEnVk/WZ+OcaA?= =?utf-8?q?d6ub0AxckIv2RRqzaAZZnlFI8RH2hClKk//AdwwfQ8NHGZz4etfnWzPIC79M3D66q?= =?utf-8?q?TqACxeDtO31qA4+zMZPilB8/U2va3dak1sb8uOVqV1ooFu1TS8K0u0ie7O8HjWYvT?= =?utf-8?q?aN/ZAzJbJwCedJ4Z16/tqN40j+dr8MYf3XlhBY1xQrSsGdeYO4PFRYZtXSSdvo1LM?= =?utf-8?q?Z/ZD7b7Exv7hh802fEZ3Am3uQq+r0F8jZ/0Z+f+NW30PxBkjmngTyuvXEJNc7apf6?= =?utf-8?q?TuEYFSusWZD6QuM/c3yifptkjkggf9qdO+gJhIF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AwndRpdfh4btAP9r3kAj99YnX?= =?utf-8?q?AohVKDv+kqx1Y4galDynGYL/+MvY7Y+NB4nolXxKN2iJDVIkmfQMUaHkfYjdVpktP?= =?utf-8?q?qyp61xXyGYL5dzve8wzHV6Row0vVt2s2pqN+rBsSJzdTUiXGyFVaiNqaRItoJEow/?= =?utf-8?q?/M/yPWkl1cVhqy6UQ4jr33B9rt+SQ4Rup5xGn9tPSsJ6ajDA0nHw5Y+16oB4HgDNs?= =?utf-8?q?ENxSR4TbqnTxiUQV1gvdb/gt+iMBFpUz/11EJgkxL3mcCvsITHtSq+A=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 4d23f9f2-2756-4542-5e9e-08dc4f47f472 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 16:56:04.3799 (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: dhdyC7EGQRT4K9hEG6cRHNymtW5NRlDkROSGmiM1vehvLXJTl70rTNQTw9/JYZbumO+R4M7VBmh/1EdTxsRofmtkrZmhrgLW9w33nKsIkKo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10147 The current interrupt service routine of the tps6598x only reads the first 64 bits of the INT_EVENT1 and INT_EVENT2 registers, which means that any event above that range will be ignored, leaving interrupts unattended. Moreover, those events will not be cleared, and the device will keep the interrupt enabled. This issue has been observed while attempting to load patches, and the 'ReadyForPatch' field (bit 81) of INT_EVENT1 was set. Read the complete INT_EVENT registers to handle all interrupts generated by the device in a similar fashion to what is already done for the tps25750. Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") Cc: stable@vger.kernel.org Signed-off-by: Javier Carrasco --- drivers/usb/typec/tipd/core.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 7c2f01344860..308748d6cae6 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -637,48 +637,53 @@ static irqreturn_t tps25750_interrupt(int irq, void *data) static irqreturn_t tps6598x_interrupt(int irq, void *data) { struct tps6598x *tps = data; - u64 event1 = 0; - u64 event2 = 0; + u64 event1[2] = { }; + u64 event2[2] = { }; u32 status; int ret; mutex_lock(&tps->lock); - ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event1); - ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event2); + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT1, event1, 11); if (ret) { - dev_err(tps->dev, "%s: failed to read events\n", __func__); + dev_err(tps->dev, "%s: failed to read event1\n", __func__); goto err_unlock; } - trace_tps6598x_irq(event1, event2); + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT2, event2, 11); + if (ret) { + dev_err(tps->dev, "%s: failed to read event2\n", __func__); + goto err_unlock; + } + trace_tps6598x_irq(event1[0], event2[0]); - if (!(event1 | event2)) + if (!(event1[0] | event1[1] | event2[0] | event2[1])) goto err_unlock; if (!tps6598x_read_status(tps, &status)) goto err_clear_ints; - if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE) + if ((event1[0] | event2[0]) & TPS_REG_INT_POWER_STATUS_UPDATE) if (!tps6598x_read_power_status(tps)) goto err_clear_ints; - if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) + if ((event1[0] | event2[0]) & TPS_REG_INT_DATA_STATUS_UPDATE) if (!tps6598x_read_data_status(tps)) goto err_clear_ints; /* Handle plug insert or removal */ - if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) + if ((event1[0] | event2[0]) & TPS_REG_INT_PLUG_EVENT) tps6598x_handle_plug_event(tps, status); err_clear_ints: - tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event1); - tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event2); + tps6598x_block_write(tps, TPS_REG_INT_CLEAR1, event1, 11); + tps6598x_block_write(tps, TPS_REG_INT_CLEAR2, event2, 11); err_unlock: mutex_unlock(&tps->lock); - if (event1 | event2) + if (event1[0] | event1[1] | event2[0] | event2[1]) return IRQ_HANDLED; + return IRQ_NONE; }