From patchwork Thu Mar 28 16:25:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13608953 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2112.outbound.protection.outlook.com [40.107.14.112]) (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 E71F212F399; Thu, 28 Mar 2024 16:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.14.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711643137; cv=fail; b=Ezo/Dy2fFNJrtsQsQQKFUsVUmFds/LDpcG4mV7mUCn6pdUOtjk/cRhSC7ns/9ZlXTdxYnV0RV3Q0Fvf3jOiD/2aepUi+NzjwpKDGXOtTu/wKazgzB6PIVnY+y7VddJgKVgHzl3lLkimhYXw8pL5B/3Z2kG/2wkuEPC42Xg69KTg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711643137; c=relaxed/simple; bh=osEPO1tew+CMOpuv5J9rsKi+wmwKhDnB1kdG/lLAHPc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=tf0lvuRBEiw8gHnn3SVPw4ixqpzPG+isOpnBCfT05jq//6Bk+C+XTuY2TRM2EZj9fLp+saCPbRReKYVOaAtOQYpH1J5znFfIZGoq3tWhc7OA7OJRzEbNGpYWtubDXVoqVZZ3En1qP8z0yoWCeII1VuFwuWl7tszDKLDva6DR2fo= 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=bmFz19dW; arc=fail smtp.client-ip=40.107.14.112 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="bmFz19dW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bnYhzCoK3E89ZDA5UCmCz6NkBpNWDrENUd8F0HCR1Gv7khvADjwp2j2/22FSlh0pOotFpWdGVkEW4tUPKzRCZxsFQtXU7cWgsbVpHsqwFD/CZa7P2AjULGvywWngkD3d5GOO6RRvjG+tDfVf8RKxD54xc4jNJQ2bnfKxnQv9jTDQX2khiy5580FBJbICk4pl4QONfVLeVYNYzerj8iYXz43myECZYTapdqx/Qw5MSvJcg++x5i5nd0WCEFRryQQ5sldbcwrSP7u2insvE4lJn1Px2uy1jgYEhkgZMvPEAb5JKkfSLvfIDgcdWru9xZAH79NHdnDY8IFVj9PgYY9QKg== 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=rXaF0eUZPso8n7boIJy4yTZBwSmWexgEDBQC14JUkQg=; b=OGt2WRKUiONkxaM/orgl7/KoVS7vIb3sGgxxoNVxFeNO068vAZkMq/SrrxL9GjkC1KAsMFliGeaF7CcP55V78Bikt4OBkgA4fq939rE3GkOkB7o2RVGWLRRq851Rmh16gWum8/ahPcqBYXylbgCvsqP/B0Nl1C+FKza/XIqJ3h1DRmb0RbMm9DmRntHXr4jj2ufQEiqnyr8To8KhmBs7dTd1evVBVTgRCE3ABo8/mN7OGk1GVI/EPnxuSQXLaIEW2BgEH9Za5X04rwzqXog4GNGTvsRhVwMca30NnZ1v4yTx1lWAuKa9Ku4FMQbB23MbQGaaavHIwyMwnYkryKqikw== 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=rXaF0eUZPso8n7boIJy4yTZBwSmWexgEDBQC14JUkQg=; b=bmFz19dW/wGcsLVFQITyCT6IswF4+fGe2xrMARbLgJBhnRwTZWSGME7qaohr9vvlKQUMxU7Vm9bTBwCq/iJ6eJKGdGVWdL1aczoh0fByE5UA/O4Zc7Tv3ZvUBNNzj57JgWKyz5PjuEYzq/cQMmo9xq5LEKUZdywY+kmMH9uzZsY= 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 DU0PR08MB10358.eurprd08.prod.outlook.com (2603:10a6:10:415::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.33; Thu, 28 Mar 2024 16:25:30 +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:25:29 +0000 From: Javier Carrasco Date: Thu, 28 Mar 2024 17:25:21 +0100 Subject: [PATCH RESEND 1/2] usb: typec: tipd: fix event checking for tps25750 Message-Id: <20240328-tps6598x_fix_event_handling-v1-1-865842a30009@wolfvision.net> References: <20240328-tps6598x_fix_event_handling-v1-0-865842a30009@wolfvision.net> In-Reply-To: <20240328-tps6598x_fix_event_handling-v1-0-865842a30009@wolfvision.net> To: Heikki Krogerus , Greg Kroah-Hartman , Abdel Alkuor Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1711643129; l=1932; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=osEPO1tew+CMOpuv5J9rsKi+wmwKhDnB1kdG/lLAHPc=; b=fbGkF19sZagneYA4EdYoIeH/pgszNTTzOCkb3NsSvgrJn+cyX2sSP+pTc5dmss0DmD6bnnlNT 30Jv0DqEsLBC3MATUDjE0SSp1CYS0bZcLNOMUBJfYLR91OW4b7z8HTB X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR0102CA0026.eurprd01.prod.exchangelabs.com (2603:10a6:802::39) 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_|DU0PR08MB10358:EE_ X-MS-Office365-Filtering-Correlation-Id: 79b69eca-fe5b-4d6d-804e-08dc4f43aee7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XJ1Uhtzg/6bal60GAXJpz8oggVXiEV9TjUDWY6LsJH66taWPA2PiUkmExK+I+pdbwI2gibR1U2d2GXmSdSLT1g2gIpTxLwomSOnft0/PdUc2elyJg3FgPUFh7DMLJyY9zjmZsNpFjd11EIFwGeJFDGxeJsE1liPpg6LI6M1Q4grx4UEYoZNrXAJVEWN4f6r+faecZIqHdq4BnO4NE3eqj0v+SsxerQXLf5ZhUBRO+RdX/rcp9QbiERWYu+P4sQNZ6poiI4y+LelKTnf+IyI8TH1PE3w5Ahc7HAn3ENzxgUgVUX+EjTNE6UgIwedL1evGMS1gMDl5m1D6IemCnjXPgtX/Zp/xUHAXgdqSQTHH/xnWaDXxuQRKWSuo+aVSUG3b7Gu57MSvwplMf7u/NjGOagSNObmSXpXqq3M1PirGN+bsqZrpbhtl6hPrMCKHkvjFmFnPYWYPjMKTtNbYWQuexCAERZ35U+jl5SCOVi/knuYtxQiMF62luFo+/D4svOnqR0jCKhV9jWVTpt0mTK9L3DFfxpolq/rH128rlqrfYwJXLJrm6UlYgXHZxp0TVu5DcGqLY0mHJTo6Vq+a4TceWoNhaQCPvl3bQaBoO29tgQFFMgDispMsAqm85fYGHh6hzKsc24EQAmYdQIqnD0WlQFVxkPNsCDKUmRpqiJnW3rACmH7xeDX9Y5ozQgNYgsW0TKEavvI1ujUx3Nxle7l1z4Cadfs+FL5tEg7k5GDHRDY= 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)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?8PeFHuPsiAnBS6p9ytEOyFjtYg9Y?= =?utf-8?q?cambjU7uBVw0JUPGy6FtQ48YsEPPCSLWJouXJTNPdqAnNPLO8qSv5Jt/XLDxsweyN?= =?utf-8?q?bgFpr3GHg0mWOtN+Ecr74uyPmLSgvnWvPos9FS/XrEHNoOi1pilcEzxVUUB5eRhSb?= =?utf-8?q?5SD0+2WdIOWBMeIh37RyLhJzPpwDcpmIwb6EnsVwPtc8GoS5rBGuUH8xT2TDyXMJj?= =?utf-8?q?2psLqh8FJc++jvVzq6tIKIQOsT8Cvp6Oz3AOJKi1kydVcWIBT7fE2hr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SRaF6cBGZ74Od/6?= =?utf-8?q?7iY3xxbJk1P+iBt3iaWtZnAiPcJnwNrwsYRyvIIiXnOP4HgKlpV1ZKF6kRQS0c9z7?= =?utf-8?q?uIRW5K/tZOUAywZ8DIyen+oVVpdYqGPQpyBQXhzBmBPRNNhxqnOQfV0IAlLqUYM2/?= =?utf-8?q?xuCSyADM4R9Uua+QtJqShU8H/WGtmjZ75CfiXIZskvbQDhhtrc0upKBQhN/Jg/dJM?= =?utf-8?q?LJVM8/Uw4P5J5ty5W+B+Mggy9XeWtlfjvrxlR6BINzg4Sm5VhzWgWj4deaN2XqAbi?= =?utf-8?q?8xALSzJ34QSX9R9AhTE/DBlwFyOy6xz/gAtrmLBs5SINLc30iAhg3rbPSM1kWwSNR?= =?utf-8?q?vWssWrihmj1WWxMAv/P5WqTEHdBmB8/txADb9uU2tsw4GkBK/7omWFJxtaR/hJ7kS?= =?utf-8?q?EiD5x/wJr8685GhJXbn8y9/HITzFRNEAHg=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 79b69eca-fe5b-4d6d-804e-08dc4f43aee7 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:25:29.6787 (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: zxWSlIEksCCkXv93dRDBhTQ7qgJ5JuZ6vLqPpWRgdldmMHASTjFfS/Jb1GWkMJU5dTpCfQEnC32JKWHRWCbBVHwFQYRTBMTECzoFIoF4vyU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB10358 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") 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);