From patchwork Mon Mar 25 09:02: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: 13601808 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2110.outbound.protection.outlook.com [40.107.7.110]) (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 240D1158D64; Mon, 25 Mar 2024 09:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.110 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711357355; cv=fail; b=LEN6y4JM1hTa/L784FKO6gOoiPbAXmilX6c5MGebVbkrdhYEp7EvBPQx/zAgjeOgJSRj5LH12vUswdS/32w2nUhhhlSmHeUzCVfhZ9cUUazsQz8dFedUG71XQkMpwJNX7RPSCZerIhFosEuhhDQsv2nuc052ctI64NHO0ulU28I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711357355; 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=i0a1pyXExNj2kbP43QNZntflS84CzKr0ojaTeLhyNpr3rBjxVaTYS3eJLwU+PkZAepiyn5ENc5BEYtUdc2TDelDO8piZzUhwbfdlMc5ixsVR7mbuKwjXd6nPVHlzcRqKgXwmH7j+c0u94umoQK8n/HqAxOP8txT4PBNCoGMis9w= 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=iDHuYvqD; arc=fail smtp.client-ip=40.107.7.110 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="iDHuYvqD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dTOEoFZmS3I9EHV9ZnMCt/iNM+Rf6/7+GVzlR76f1xeom38RXlTIu+MpwYlM4eL+GKcsmUUIiq6+jGfy2oZeu8bvXz0J34Q+3oWfDFhbYBLTSZTMSfi8aQHkoj3scI8HHrcE+25na42meeobXtpG/zAFVEDs/G5MQ2OnQSRpGD9KbopIGuYC0I5h3aW1/OBZFrynCvieWb9bmUWadAPWROXoaZvSoIYDOkr+Bf2zNB/MYbh39ZQcQ8sXIYo9tK7yZlbYhh5KjGgTnV+SRiEEwuc4suKn7CphMw673lj+HabEd0Bf9Yr28MrCX+Uh2xYKiYcfmfzNYYV+R0nG5lyohw== 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=ahTfcKJ4YMAMjUlF6APvJ8QVZFOpr+00EAbT0AgmGnRrrL/8f1DVcLAhfgqAWsURDtI2UkXoPSBxEzvganXbENk8I68npywB+gG2Tq5uGKSfuAanW4K2MppDU9PlDRCc+QWxVzMJLW17YJ1VgXkHy1bznJbhMNDLbhAfEf/v6nyetVENViZx9cDC+mbmbAoeUfStC0lvrxQhZR2JFZ/+e8rB/ImVkRcV0ghWGrz8SVqYUpxpXR8KNvBVwkt0xXzh5mVfdclNTGh+tOuCZQFRvpSKLwAJsqgpoeChvN5jNdMrO5wXlkRxzvYDONi1dLu5Dq7WK2G/Vc8yHBmNWUCJtQ== 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=iDHuYvqDdhjeYvoGbGXsWH2FQAYg+Ln6A3pVpe6/GDT+VCuR+VGfY8jPBWddb4dFgDk9+mFWDSzsyNJGXsMgqLKlB/r0J9GTcxQ6bR3EpOuJdyKdxQ66yLpNPUFsKroerIm5PTWKJIt0KFYCkzEijROqyemNJbqUvMoyVfQIEQY= 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 GVXPR08MB7848.eurprd08.prod.outlook.com (2603:10a6:150:16::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 09:02:28 +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.028; Mon, 25 Mar 2024 09:02:28 +0000 From: Javier Carrasco Date: Mon, 25 Mar 2024 10:02:21 +0100 Subject: [PATCH 1/2] usb: typec: tipd: fix event checking for tps25750 Message-Id: <20240325-tps6598x_fix_event_handling-v1-1-633fe0c87cc8@wolfvision.net> References: <20240325-tps6598x_fix_event_handling-v1-0-633fe0c87cc8@wolfvision.net> In-Reply-To: <20240325-tps6598x_fix_event_handling-v1-0-633fe0c87cc8@wolfvision.net> To: Heikki Krogerus , Greg Kroah-Hartman , Abdel Alkuor Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1711357347; l=1932; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=osEPO1tew+CMOpuv5J9rsKi+wmwKhDnB1kdG/lLAHPc=; b=wyNDQwbKxSYKnhEHo3V2rt3IwM2gKQHi4mptHJ6dR/dXIwN8dx7DE/KAvD+1H+UDSwKgfrr6J cxgTxaDd6tcCj1KZSgFXpHp6igQh0AcnLNteyvIl/LVhFYXRE7D5xkj X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VE1PR08CA0022.eurprd08.prod.outlook.com (2603:10a6:803:104::35) 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_|GVXPR08MB7848:EE_ X-MS-Office365-Filtering-Correlation-Id: 44de53cc-33e8-4929-9968-08dc4caa4ba1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a2RKhLXQxKNyqdAmIrnZuAPzocFm/N+QuZnW1df460YlJmCidMKDO5pbA8iU/DvKzW3DXWC27A1Ct2mn+7Qrfn0mTE1M6sbuSCQoPnuYcw6rFb+NVyRx4GA3jijtFUKp5iPPnb8pjNLlljWXG/GOTyNtnlfCp4/DyXs5uVedtVT6XkGe94DZWolOiAo4GkSdO4Q/LK1D2C1irovwfe3UBVPZ8UTJacXnoI1S5wX9MV4UFV8gYQSC5s+yTb0q1fnYqfQCuvUcjrECD0SMIcG6c6578pByV+NdRgpFw2nlq2bszrwCd3CbE75CPgyIXmbIF57ecPZOTbp2uM1ioXUX5XS8qn/Tqu4mQh03gZAeHIYlSHNXWgub9ihzG7jq2FYNJ6wz8P2lkQo1a2qZqiccaW4skHQ5v+PT3BERRFi7oCO7atB6ihY5IzC2lJBQ10cRoTniLA2KSXmMuit4I/P0jPDj7uslgv1YnRDc2T6fGq3d0dhPNcrnWNet+/+T17oK/NUgrnA3vW/o+YJl9W4+Eww6a2q+aVSX6E2J5uIPdClsNUCNa9ZA39G6jPpeHYh6hByz008it1eV5FGxw97ECZ9qZnu9YNtRWmasFfNJ4Yc/3vj2OybL5S69N8tIVAdpLM32LF2Xt9zm80COtQxaIg9Nuz+CuPpVMexC+AxDzSdCnVwBUqn83G90TmRcJWD44eMNDe26886zQXlt6xJkCzjiLeSLlmn9RIRC7Kd2UdE= 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?25pwEeumCHAUT8oSD2ztHoRIXt+o?= =?utf-8?q?KUAB8ajebVjql/9lJ+L33udvDxFP0gsc+onf6QSLPZq11ShVTRTSkmVtXjsz6uUtb?= =?utf-8?q?G6/cLAusMi97GCllMtcGc0nL1yloHK/uNFOvHMHG6l0DRnv8xgE6z/U8FLd+sTlFS?= =?utf-8?q?ERFfrTxbSibbDf0dSaEJdSaTIeZH0Kt5HYhu3yR0l4azNmedKQBFwcsnMWyZALgR8?= =?utf-8?q?K4JEVOQkuHbZZIAK4apnG+PJW1wOAD8khnb/mEKVr94QkWhzxebhJZVCIMClW7pQg?= =?utf-8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8lVqhoGkzYSKkSbAOvoPVYfKs37V2QA9JmDdxjvyAhcYliRwRRDJb6XBe4e2j60Mj?= =?utf-8?q?Fsro3yhV4wsRakk52Jc6WHzMog7HgbqbsPguwd969Yu8lkOQ0DqoZeADKSqMSDN9Z?= =?utf-8?q?ZwrALKqKZkUY59kvyUTjPVQUGT2qQiMz4Hg0M2O35mGzWlpxM03h0J9aQXL7aLNp3?= =?utf-8?q?CaRS2WdSYeqsL/2WRWRBL+HoG1q0Kti/jxJgdyn1fVthllWTjZ5pbiO3PpMndMv2t?= =?utf-8?q?tlS7QpTsA81Z5YXYrZ4G1xXUZA7kllTAWz/+E8V6IL/wzCKR42NQzkREi3WhMftkn?= =?utf-8?q?bsYYncXuTkibjZzmTXkg6zDvfx+saWkIxoThNICsilneNZBJhHpliYJd9Z7ooh+AR?= =?utf-8?q?2FI0Nsa44WocIFTrhXsemCtowwYSxKqrWA=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 44de53cc-33e8-4929-9968-08dc4caa4ba1 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 09:02:27.7992 (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: SdvjR2pdPzB8noVKc5Fb9IfV4w1hijhCZ8oPDViIFz65cfmUXSFi3SYUbWZ5AeYFyinAxt8OBOitXOW8jez6cJDyHEE1mckro6LzBxJ9pes= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB7848 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); From patchwork Mon Mar 25 09:02:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13601810 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2110.outbound.protection.outlook.com [40.107.7.110]) (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 90CD516D30C; Mon, 25 Mar 2024 09:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.110 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711357359; cv=fail; b=usgRhOD44LdbGx171LCDSyuRi1tshiLzGGno3Roucr5vBnB+OUTk6viKdKXExGh4hxbzzl+k0rulSOvj6vVF/FJbnyjqXZkhgl3pFdY95b+EYL47gQxdObOcDa9rY6EmOoflZ/Ypywa+ZgAOGrsz9vi7FI1sEgNVvcQAp7y/RyM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711357359; c=relaxed/simple; bh=V4DZHkcARNC7fc2daZ1OECCct358ildSRykedHXTgNU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=H/a119DGqS2FQmLSrS1oNui1lQ/kOwSJVyDSHyErSPMTA3Sy35tSVp8h7lPTmHZGLExz1gZVEFUfUFPqo4VSk1hIqArRSvY+qC//O8m/AhmKU7F6vjDrQukYQiU6o2HhVS7d0Fnct/tQ6bea5oAc5Z5V1mFD5W+JLpt3rWpKQco= 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=NjrSfMiO; arc=fail smtp.client-ip=40.107.7.110 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="NjrSfMiO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X5mBucAUegHfq9T+ZkMKkKrJYrLC6QD8TXPvZWxhVvyf89QGrM8lHV20TPR7rBUxBGHz0cq2YD3r4rPu1W8mncC/kaM+xulGXgNkJl/FA7aNXFu7d15U4VSOJejdL95e82ei1iNqWi99bG1l79ksVrqe9f1DvMtaPlV9DhgkNLYun1zxvg6aU+gYNb+s0E/upPX8fzLEYNt8ZixqSz48AlTGjfLUS5Vf2FXrjZEGGQlc2VFputG9o1qxqDiB7lgZh7BWb3JfqMBQH+LddTf5iNxDgb0pW8kcE444g7RQ1vVZ7cmhw/IIW/7CcB9HcOAFfBLKe/pXwdafS8+TNhGAhA== 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=l6IxgU3KTNIxgzSKuZaYIlNmkj61o383/aiDnWetpD8=; b=GI47scM5dH/vbrxpWi4s0uKXCVvg6kuj6/10P+lTrk855BXSgBcB2bxZhGOVJh7r8bGyiIjhB1uMFFeftZACTCt9d4AbdC6F/XBmn91xU1RZiL9QwyPFvW3J3WaBjStwoP08qbM1T0ghornS6yaDcLdMTOGi75R1v5wzEUf7Xn0qU6djDWhYWR506n+VhDiMnkQRsTKjLNHl/R+OPm716DSC85V3glmsH77DKVBIif/Di0emHL+AkyQzwyqLEQdrIOSwht69peKojR+OwIbZSkpulRnXBYhi7mXmOurodQmywCypKcb05XZfnE10MgzWaVBijfUwh/LBGf6ruF51gg== 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=l6IxgU3KTNIxgzSKuZaYIlNmkj61o383/aiDnWetpD8=; b=NjrSfMiOZYn2kfki+WJac6UXy3QdCjgRAGEqX7cS7+Pf1I1wt3Enr5feBIOfZH6wuQOy7TVFLdJXngq2HOU4o7ukaI6XBU8azpdtHDklzH8FK0Qei7TKdekO+ggI4urXX/S38nrAxzNCnzL5sIb9Pq6nMtRbN88z9LRO23mTfsg= 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 GVXPR08MB7848.eurprd08.prod.outlook.com (2603:10a6:150:16::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 09:02:28 +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.028; Mon, 25 Mar 2024 09:02:28 +0000 From: Javier Carrasco Date: Mon, 25 Mar 2024 10:02:22 +0100 Subject: [PATCH 2/2] usb: typec: tipd: fix event checking for tps6598x Message-Id: <20240325-tps6598x_fix_event_handling-v1-2-633fe0c87cc8@wolfvision.net> References: <20240325-tps6598x_fix_event_handling-v1-0-633fe0c87cc8@wolfvision.net> In-Reply-To: <20240325-tps6598x_fix_event_handling-v1-0-633fe0c87cc8@wolfvision.net> To: Heikki Krogerus , Greg Kroah-Hartman , Abdel Alkuor Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1711357347; l=3228; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=V4DZHkcARNC7fc2daZ1OECCct358ildSRykedHXTgNU=; b=oqMTptz5e9quNz9ztaaualZjG17J2v/Y0ZDoKeiCRD0Geok9ws2nLi4ErNi0SerQsO2VvjFYY 2PscYN1aMt9Bcl3+S+l+0+ccY0AGS19vAVtpgLxcKpKgk+vxj83yZG1 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VE1PR08CA0022.eurprd08.prod.outlook.com (2603:10a6:803:104::35) 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_|GVXPR08MB7848:EE_ X-MS-Office365-Filtering-Correlation-Id: cbfb46e1-09a7-4bb1-4242-08dc4caa4bcf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DP7DwmjGbymgOrulASjMnQJm02T3Ta+CG366QDt1WAKaaCrKZxw2F9lbZIhzho/QJ00+Dbrk2WP6UjvNVFAlmA3zx8Z5wngtFUQVSay8Y5rOGZQPgEA5YebqbC9uKdZ1DL1w/QIE+IpyNBYEzernDWw7TA9hNXpwI7PTrJbuRg3LmCcMX2p8HM0o00WHZ46XlNtQT+LgiVvh/EMDjsgAuW7XKO9/PoPL+8MaxKJ2lZw2NRNAqCTPMgZEcaKtWs2dRYp1n0NUbiRZJmJIgE2XF63bDg60VI0RgCxioX16vLhzxB7LJfCRgPlI+t4L3IhYrkI3yPt9Cd7Bq0KqDg7eheKwW+KZ6JWehSvIvCkdyC+rjqm7vtN+mkTRU/7bVllOKGnt0pMtjESfeAxxsw+mRb9JJMgJETsa2721iLmZWRtPyZsjTVO5UrBAtewzUshbH2mGg5efznM/oEub8BCOtzBTHO0ffIbHJem6k+1lfruvUf24twJJsNs4q+KnnOUGyMuOCh+FHTL0G4YTZAPyvDEiK6T1uzLkZbwpPb6R09Vy54NAReyam2vu4mdzY87MF/rSuWD3PQkF+BzJA3krFYNcj2ScJTVtCVYcSQ9WL2F69kiuz8OJ/LnAllzo+pQm6NDS2ufkedExtfd7FW2rpKQiGrBulDxNJ8uQT+Ac/JqrhQPykJpEbLVHhm7KqsJMB21FBSFL0dhyv3uwVfEvuw== 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?YNQlAi7k/cbH3W+aYEDa9M3xT784?= =?utf-8?q?D1ecyBfaIDAhQ1qyc+9nYIFoUtsW7IKMbHnEbRuQnrzFIdJjC99dgh9JYVsoDr4M6?= =?utf-8?q?gaA9Z7TjQcnqZ3kyA0zj2qaYsU/Y+3oQhB6KP3Uwt1IvYdRhNucCljxntYC3zYo9w?= =?utf-8?q?Uc5KB6VtVrdVoEpY2Fi+xjlN75y5Cc4jogy2HcCjl8UMPsN1a+FXOuGNI/WZuIv6D?= =?utf-8?q?xhUHmlvsMYeAeyQmO1kawxodnKIN+Gyju2u2KGRLnaqmVIzSYm2Csb2MPBENZybrc?= =?utf-8?q?Ce3uZ74t+q3ZX481e5pwU0b3BPR3MoBQ9VE/4FWOnT0IKpReNx/mqJaDRwT9ONw3t?= =?utf-8?q?JloAp0MShv4w2yCYN0BGSICy4ydrlCPHHXTttWmrxOHHQ42mO72nmPdYMnu0pDeNd?= =?utf-8?q?UDXjlScfS+IknutSfVG8hqIdg3HdTxZW25jdb4KqqSQ4qXkJNcMUHzAYqQIAxcPyO?= =?utf-8?q?afK5z5qB910p3pA1DSGVgRA5+De5RolD9VAAyiHf1RTMqK5sPyKG12B4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K2J4SsOlu50kx4QjfOl3Dq?= =?utf-8?q?ITOVT4YuaosCmlvs6y1UP7RXgNgxmUv7ROrZmbHjceNLqw9R7iIrNwhdUs1ziUkvF?= =?utf-8?q?v7UG+f8qQ+vW6pzak2i083zycGcB3Im0M7MSPyg6d0At8jniFaQwchowPCLCqcXb4?= =?utf-8?q?z8j0k7j9J9YooDlGF2Iy+qWUlhUNlA6t6Q=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: cbfb46e1-09a7-4bb1-4242-08dc4caa4bcf X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 09:02:28.0606 (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: wKHt89uBX7Kdo0xBrA0SpFRoUbNDJNNtiKHqWDjH9GIqIhggaFVgfwhL//BkMvSbOYV/ysof27ib3F6tUgZTDbwTHu40UiTM7XqJSNdtZ84= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB7848 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") 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; }