From patchwork Wed Nov 30 07:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 629852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8FC0C4321E for ; Wed, 30 Nov 2022 07:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230033AbiK3HGF (ORCPT ); Wed, 30 Nov 2022 02:06:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233563AbiK3HFx (ORCPT ); Wed, 30 Nov 2022 02:05:53 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2068.outbound.protection.outlook.com [40.107.21.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19982554D1 for ; Tue, 29 Nov 2022 23:05:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFrHIf6fBg40I0lrqYTEPMx6DA35OgdRNXMwHoSBgNVQy3obMWMvW5MUs2VfXFlR+ObfZ4oHr5CJQK7KmknMwEx6MrgdHrlDIAqNe90nkzNaeJbbjJXXVEPRR8Y1BmQ3DgReGOMSBpmpgVw5odObU8ca/Mzntz4oqWvV4ur+OBlNRrAvLzvu0T7PvgGxx+TLwaJ/8//j97yciEiQqPoYVqJMQY9OmbaQ28QuPUoQdkViNBEfqxhjduLNovGB7cEwUPMqhpwMqF//vw/g+OKdRLsaHJECuP4iPLEID3QxY5M2uOAKlQja5FYGHOuWVhYwPqlLgXd/IN6tWfStQgHGHg== 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=ukIur6+kjO6oVRpE+csVTTfyXZ9y1Wp5LanX0+o/Aos=; b=l5pio9sC3UgLwbMXNADHHBe3dDcDPwpM++Kw5UUvjrFEqrRhEZ13pz5bU9qQYXgCJMkbTLZeurCyy7TzEYa0mGBOH4YIWif/DAb/NfN5xHhym1dauaK9MglEd69nv2CiAC0W0W54G3t6iuTSdearz2OMs2frqDO8ZfzEii0KXKYq9gd1jWiaAWtnhRJwhQ4cYpWQ4gL7M0DRafs4B0zgSFJTbje+w9+zbDuTfZbfVTQ1ccbK+MwbLdAd+YPNPx4Fxfurm4Ax7dVaEhfGfbb1K6bzhsg3F4tP8Xv6KpYPpFrkAA5R8ULxo5qDps7RjyC/XMiteQNaW2GOzRp8x6at6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ukIur6+kjO6oVRpE+csVTTfyXZ9y1Wp5LanX0+o/Aos=; b=Z7YzJaWiC3eLlMvk69AXy7dx45sqPLOcS/tZWoLKp9hv6o9Hkv6eOduDUuWZOvb9Op1Ae8ASJ4jkOz7RWQEQzbI0TCY5+3MCsvexTbT9MWaMeQfxKcnkL+HIivAsdo8SKctfMzxbVEcO7TUBKefZxh43gti5YZeYwafsLqYmlAA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PA4PR04MB9591.eurprd04.prod.outlook.com (2603:10a6:102:270::18) by PR3PR04MB7227.eurprd04.prod.outlook.com (2603:10a6:102:82::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 07:05:49 +0000 Received: from PA4PR04MB9591.eurprd04.prod.outlook.com ([fe80::8184:d5e2:3c61:b493]) by PA4PR04MB9591.eurprd04.prod.outlook.com ([fe80::8184:d5e2:3c61:b493%6]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 07:05:49 +0000 From: Xu Yang To: peter.chen@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-imx@nxp.com, jun.li@nxp.com, xu.yang_2@nxp.com Subject: [PATCH 1/3] usb: chipdea: core: don't return -EINVAL if request role is the same with current role Date: Wed, 30 Nov 2022 15:06:04 +0800 Message-Id: <20221130070604.2439061-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI1PR02CA0015.apcprd02.prod.outlook.com (2603:1096:4:1f7::18) To PA4PR04MB9591.eurprd04.prod.outlook.com (2603:10a6:102:270::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9591:EE_|PR3PR04MB7227:EE_ X-MS-Office365-Filtering-Correlation-Id: 730e14b6-9f68-4cba-015e-08dad2a14ea3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4McSsH5RD9woCwIgvvM366AjcNf/vNLf29g3ibBESDV6aIabC/8IRzKcnvym/yxG9wXkfg5i/Gbuw60M/MwVuKK8OlxUlxYInCXgPvhxN6m5mSXT/Xx48LNU5mdNfwbNCDqTl2WQxgSJjvGcE+Ia0ayVG0vGu3U68PtlP7yPPigZ7mK+Kml0NsYthprElqIW8SeKKXqZui7yRw0o0/CalrsrliH9f2+CDVN8eSbcVBGV/fIW5+dbK5ORwhfczUf7/pKeWg4CDVVK49VXSgCgP1U0XoHY2Ljt6XYAgeYQtNFEo8iqAxagkIpMZAdDoVcxSPAGD49mTCbZaLmyBAN1q8OZx17iHTvUZ7+r1RgKEWDD79HzDs/Gm/pTHrNuCOmzjVKa2DzC+FcdagBfoBgJd96kW2f2zJxdrGb9oG6HZySvDdwHctxBGrxTDwt6T4wFl2iApsyIv5T9FHoGlinL0KeDSz8IaI1oJctciB/TMR14KTdIE7akUiNo1ge5BTDFu9o6Q341SBPd0fIp5YJpLuCARe4n35E0sircuVn3HLzqQrho1BeZMhyH+X24a2wc5NdACl8qv2Ac2z5YT80yHqkKzgRTUnPPCwTOFK/swuVJWwMA+Qj2yM8SPTSIYjmI/syGbRgyZRxCA81ZRQItjoD4q3IizVciHGBXXh1X+hFxph8yu/xYEvlLwc9D2CkR0qdiwXPZu1kacYAPt4kzhA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR04MB9591.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(346002)(396003)(376002)(136003)(39860400002)(451199015)(8936002)(5660300002)(36756003)(186003)(66476007)(6916009)(41300700001)(4326008)(66556008)(316002)(8676002)(38100700002)(83380400001)(2616005)(26005)(6512007)(86362001)(478600001)(6486002)(66946007)(52116002)(1076003)(38350700002)(6666004)(6506007)(2906002)(4744005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yHMEfq45urgdim3A/W+xgWX1BMGH3MYT9F546mo7F1HOuc6m9k4AT72tnGNOS/FaNYW7kL2Iuqqg38+epgTebPqhOVJaiCJd/qqp2wK0hdhwQq9hEHAbP4Br/iuraeQSsY00hAcVWaDJHgKPMxp4SchYJEBuBX3IYaDs1WAfkzMDF4n8c/8zBXebp0zoqAFku10H/1vZYHNy6MyVCQU/SNV8ugcz15GyKJiu86OXusZyuLpiKj6KR9XwgrHm/CAN1HbLW+xRl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jRufr5rhNHyTtY91Ve/QCLsNv/SZ8+9m4f7Z/6WcJzwjbeWuiHFTzt/k1xZ8VcmNqnio5uxH+l+3iLhb1Hmh9h5V0SFS8j+PmQakO9onyn84fV2xiAYpCRsWK2pKLMx49KL4k256uJxDj8f4nnRIAI+TVX1Ya1xl3Kg8Y3P83ugpDJkhxxZW8zNwgbrxz31exshhlWiv4DJbcm8acIqA1v6+S2iOPERo1KT47gNIf+POi6cfp8otXF3zrFY/+ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 730e14b6-9f68-4cba-015e-08dad2a14ea3 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9591.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 07:05:49.5510 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZKv47zkL0BObJrK9Mpx7YSimFQ4L7wwW6zEF52YDGYzvjv5uQ135nBOjFVkBCk4NhZmRhQao6DnZ/9BIDuRYjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7227 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org It should not return -EINVAL if the request role is the same with current role, return non-error and without do anything instead. Fixes: a932a8041ff9 ("usb: chipidea: core: add sysfs group") cc: Signed-off-by: Xu Yang --- drivers/usb/chipidea/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 484b1cd23431..fcb175b22188 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -984,9 +984,12 @@ static ssize_t role_store(struct device *dev, strlen(ci->roles[role]->name))) break; - if (role == CI_ROLE_END || role == ci->role) + if (role == CI_ROLE_END) return -EINVAL; + if (role == ci->role) + return n; + pm_runtime_get_sync(dev); disable_irq(ci->irq); ci_role_stop(ci); From patchwork Wed Nov 30 07:06:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 630607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 421B5C4321E for ; Wed, 30 Nov 2022 07:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233563AbiK3HGQ (ORCPT ); Wed, 30 Nov 2022 02:06:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233565AbiK3HGO (ORCPT ); Wed, 30 Nov 2022 02:06:14 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 883C657B60 for ; Tue, 29 Nov 2022 23:06:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K6Vu9H1vFtWfEt7sNDJ8uMxvkZdh3I1kpKZCG2e6fiYs9/KLgKOEnaSVoeAA7F+xDtLj3y0G+x9+nHPq9WKxadG99oRpkhc7/YhNsgpMF4s4BPxZEWRMW5FPTmsFOmBDOpN/UiISLBwqPPCEWepTD1qnPlV8z2PxM4YBThza9cNrHXpO3Q9kaR2hfUC+bvBczOh50SYjsFvSRxTXjp97Q+l9XG1FqSlWodj7er6hyLveMfrrxJFulWNoMHSeSY4VSezOeHExpjjgjZ673wIj3XKQpqLQ7iO4qdxdp+w/yuJIpIztcUtfcqHHt28qerCN7wDoQPP1207dD1D64OGCyQ== 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=BIfnEz0Zqxy1QKN3BzRuCU1uA+1WIduBpXV4Jq/HwZM=; b=YQAqo36buoE3dhCn/oKgnU1Vnb+U70kzER5XBz5QMsQf6+VnNqF3mWjVlFASbFE7kAdQzhweHPac0+xnoHpAfZAPhvdxgmTImUjknZIbLulLdRFieDCOUWuLp6TqvQfG3vIoWLZe2z4j6qYVhtfonyZInIdm9FIHMj8I9lXSOTHAiZIR626iDC4uFTICmW1ZUhc7qCPpoN9gFLbwt9eajo1JQbwuvzNm2oco63krzMjeHNpQqNsc7trkCcDdufwPC/dN7PGpVaucR9tHaSpW01CmstILClB79fihVodGxevC37tdVIgKMdwRw9Z2/VpKp3cJn0hO+uUTcQhpZmOb2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BIfnEz0Zqxy1QKN3BzRuCU1uA+1WIduBpXV4Jq/HwZM=; b=r5u/xy+mbbl3wJm2euzDexGb35bMAGqms8l2MBWQomvwbSFp1qrHS3UX4JM+OeL7Y3ikztdRanZdBVbljabnFaV+Km1J4WVEt0vRSx/IV39RUfHPG0eSBRAMWg1dg9LChgXvYbzoV2u4jHwzsKXVQibQDBMd7tI3pu6jzieoT2g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PA4PR04MB9591.eurprd04.prod.outlook.com (2603:10a6:102:270::18) by PR3PR04MB7227.eurprd04.prod.outlook.com (2603:10a6:102:82::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 07:06:11 +0000 Received: from PA4PR04MB9591.eurprd04.prod.outlook.com ([fe80::8184:d5e2:3c61:b493]) by PA4PR04MB9591.eurprd04.prod.outlook.com ([fe80::8184:d5e2:3c61:b493%6]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 07:06:11 +0000 From: Xu Yang To: peter.chen@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-imx@nxp.com, jun.li@nxp.com, xu.yang_2@nxp.com Subject: [PATCH 2/3] usb: chipidea: core: fix possible concurrent when switch role Date: Wed, 30 Nov 2022 15:06:31 +0800 Message-Id: <20221130070631.2443398-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR02CA0034.apcprd02.prod.outlook.com (2603:1096:4:195::9) To PA4PR04MB9591.eurprd04.prod.outlook.com (2603:10a6:102:270::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9591:EE_|PR3PR04MB7227:EE_ X-MS-Office365-Filtering-Correlation-Id: 73d943ef-07c4-4b30-ffd3-08dad2a15c93 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AKQGHGMDFeOW6N3Q7pPjKoW3et194BRXqfaB2rSS79sxJfOSi03E558auBaPTN4XEwok1eJPT0rwAcZT388xA8knp3BgGs/foOQJ5imjy+iYPRSF+J631tiVtmWE549QTeuK0YH+ICfG5dX0IXFcxmtnC7Hky+0vetRT3GCyn4us0gIihShZ3G2wdZol+t9gAuLiyM5VZidfl/smmEK8dm5auDMNF/kfO75k6DqeIIXIVpxbLbbZ3V0Izi7+on44wNuwLob5mvMzdnGHLc6QkahJmev/0l2ndaqIrwp3nyzJnr1R9kXrYJX/t90/1p2KLOuyKWhgEyq7cOpAa1auGlt76gBAcuVp8MrXZVH1KhN6zqrHFX4pabRh8hxLO/c9EHVVDXG8U4pS5LVWvE9CYy8maK3FvmjiVWH1eu6gr89PVmRY3He56sJpvd87FmXYYAOdemZw4VUM233CODMqN1A4bs7g4Hlq5ImVezo1tVCvMMKFUeEjsA3MOTBva4uvlFLM9tln0WvrsWHdV1UNgMaqfcHp71WAsue2ENc58HHCOXCRxx/OiauxSzEqfcbPgip/zElCMbD+NxhtW2M5PJ+ZIZM4QpwCXGh71WrBrtpvhrWX7/PVvmKqBi24rUtQvSHrIS40CLwyAtWozOUiw8xc831brK/5M26NU8Qm91Iu8tVNH5IFM26MotvF5LQ5 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR04MB9591.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(346002)(396003)(376002)(136003)(39860400002)(451199015)(8936002)(5660300002)(36756003)(186003)(66476007)(6916009)(41300700001)(4326008)(66556008)(316002)(8676002)(38100700002)(83380400001)(2616005)(26005)(6512007)(86362001)(478600001)(6486002)(66946007)(52116002)(1076003)(38350700002)(6666004)(6506007)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6NGiBhtuJE5ccfxsN5BIVn1n0yaaPaP5wbFS4KuhK2Ro0N7mKoOiKhQ95b3eoaxtE7BzPGjaaxtMjsXrw1E1HyVxQ9S+Txd5zKnU5IXEHepNfZIm+3pMDyNGIL8J7e9NsS/WJaE2DqCcf6P7XKBr5RApNoJR6coV/Uaql4xtvfX3CbSDXyN1shDFcBAR0C+oCGroh6EyOeL5HgOio9iDcBkcMHTd0ewCS/1120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ou8KxkEjUNp7MQE+yRp5PlzMdB8pDKEI+C6ZTRl4KTIxUdPSf9ddbmqBhnEoVvafeeZOxxxr/hpmyQEumNMbibeukhyDEeYRD8lwWnfiERqv52YyFOae6lzSDtmG0I9PwK7/oLFYBLb8KiD1o998BsXggDOVGbJdqqraKFOPnTgpmzOnvCItCd8+UMeoTJhSKqfMzfhdsEDcfLcACXdc27ju40zAEgUOrbXjOHjEUCiW1ftBr9LjE/R3Y6KNRk/Hu8T2hok0xzpj8OK7hMqAM0NqXF4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73d943ef-07c4-4b30-ffd3-08dad2a15c93 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9591.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 07:06:11.2848 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eIVgcOvAtxZwZxl8iL3+1L0da8ng9KJdzcIQVMipShgWdNUownjFjkcopw/EW3glEFJIR7FyJr86KrbOBLVnog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7227 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The user may call role_store() when driver is handling ci_handle_id_switch() which is triggerred by otg event or power lost event. Unfortunately, the controller may go into chaos in this case. Fix this by protecting it with mutex lock. Fixes: a932a8041ff9 ("usb: chipidea: core: add sysfs group") cc: Signed-off-by: Xu Yang --- drivers/usb/chipidea/ci.h | 2 ++ drivers/usb/chipidea/core.c | 8 +++++++- drivers/usb/chipidea/otg.c | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 005c67cb3afb..3424ec0d0b20 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -208,6 +208,7 @@ struct hw_bank { * @in_lpm: if the core in low power mode * @wakeup_int: if wakeup interrupt occur * @rev: The revision number for controller + * @mutex: protect code from concorrent running */ struct ci_hdrc { struct device *dev; @@ -260,6 +261,7 @@ struct ci_hdrc { bool in_lpm; bool wakeup_int; enum ci_revision rev; + struct mutex mutex; }; static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index fcb175b22188..d7efde30d59f 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -987,8 +987,12 @@ static ssize_t role_store(struct device *dev, if (role == CI_ROLE_END) return -EINVAL; - if (role == ci->role) + mutex_lock(&ci->mutex); + + if (role == ci->role) { + mutex_unlock(&ci->mutex); return n; + } pm_runtime_get_sync(dev); disable_irq(ci->irq); @@ -998,6 +1002,7 @@ static ssize_t role_store(struct device *dev, ci_handle_vbus_change(ci); enable_irq(ci->irq); pm_runtime_put_sync(dev); + mutex_unlock(&ci->mutex); return (ret == 0) ? n : ret; } @@ -1033,6 +1038,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) return -ENOMEM; spin_lock_init(&ci->lock); + mutex_init(&ci->mutex); ci->dev = dev; ci->platdata = dev_get_platdata(dev); ci->imx28_write_fix = !!(ci->platdata->flags & diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 622c3b68aa1e..60a3648461e2 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -169,6 +169,7 @@ void ci_handle_id_switch(struct ci_hdrc *ci) { enum ci_role role = ci_otg_role(ci); + mutex_lock(&ci->mutex); if (role != ci->role) { dev_dbg(ci->dev, "switching from %s to %s\n", ci_role(ci)->name, ci->roles[role]->name); @@ -198,6 +199,7 @@ void ci_handle_id_switch(struct ci_hdrc *ci) if (role == CI_ROLE_GADGET) ci_handle_vbus_change(ci); } + mutex_unlock(&ci->mutex); } /** * ci_otg_work - perform otg (vbus/id) event handle From patchwork Wed Nov 30 07:06:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 630606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D7DCC433FE for ; Wed, 30 Nov 2022 07:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233683AbiK3HGo (ORCPT ); Wed, 30 Nov 2022 02:06:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233628AbiK3HGl (ORCPT ); Wed, 30 Nov 2022 02:06:41 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2084.outbound.protection.outlook.com [40.107.21.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F49358BE6 for ; Tue, 29 Nov 2022 23:06:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BaZjbQvx2BYoGCBP1ZVu9j2GB6uu9sPV+rLUrIAxHmaSEq6BViqqMtcVYcdEvh+uxZ3n/wdwqZfgmU54/bZKewb54QK1nZOxaH38jYQXGsMxrNoFrXjr1CyUpLF9bD4f/ckpRv3TCfEw2pKThPNBk8b0sSKdf1r1Yzzgvkg9h+C67tm+B+Riamgo+BZ67o32gMNGsLsN6eBAEKV554ai8LHz98MwUn5+XyrvQ5xp7esdtIPVOjl9IZJ4xqlbCAs4FqR6g8jTjOxMaF/i98UNY3Gd8etVEbA0lGmpdfVbgLPbbijEzOAVhc2l9VNPuYZf9NAN+1dam4TpeIxMPR3/GA== 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=nrFC/ZeawTLzjiRX8VpIupW9bUpdYyYzulhyOL0f0yM=; b=UaM7Xs/LJviGFrC5SF2FwsECs/+5PepRJ0T0loPvspBOQeRyzIqsQy6vqR7eLbL4UYA+cKqEVQziUlWviCy/qdn3q7tY1XhcP5qmGHA9kSeCBgSkwKndrsW6i2+JwIYw1ZSQNl2wYkq4UZGX84hvRdTEKsdeDnNnEyIISx8YjrxirUaipCcAqZBDpqhcAY38e4VagPA/URnrz5C+jfRcSDc1WBSg3DJufMQyIgZcZNXrASCDPy+/PWoivvHpKqMJIzQeqSzziT+UQwoYBFFsixXAH6GXXeq7rNoYnsdSBH1oPs2vYXGGQCmR7ecjIZjPdMYUk1VRYxKmI8RUENqZww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nrFC/ZeawTLzjiRX8VpIupW9bUpdYyYzulhyOL0f0yM=; b=Nd8W/AgsmTN7gK1KJ2SRn3bCLQxnwelSo2X7yqEybJBSE7obYLW2it5yKhGS7Zd8qCD0mwz4rgnEy3pT/Ex9h7S2E4rEQNTc1HxpfSb9n7cEcr5IPmsNsTLlKQxaRo2FaFwEg5qLmxcZZLyufxErdlDU8IXSV8RCB5Mj2lP4p20= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PA4PR04MB9591.eurprd04.prod.outlook.com (2603:10a6:102:270::18) by PR3PR04MB7227.eurprd04.prod.outlook.com (2603:10a6:102:82::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 07:06:37 +0000 Received: from PA4PR04MB9591.eurprd04.prod.outlook.com ([fe80::8184:d5e2:3c61:b493]) by PA4PR04MB9591.eurprd04.prod.outlook.com ([fe80::8184:d5e2:3c61:b493%6]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 07:06:37 +0000 From: Xu Yang To: peter.chen@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-imx@nxp.com, jun.li@nxp.com, xu.yang_2@nxp.com Subject: [PATCH 3/3] usb: chipidea: debug: remove redundant 'role' debug file Date: Wed, 30 Nov 2022 15:06:57 +0800 Message-Id: <20221130070657.2447756-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR02CA0017.apcprd02.prod.outlook.com (2603:1096:4:194::17) To PA4PR04MB9591.eurprd04.prod.outlook.com (2603:10a6:102:270::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9591:EE_|PR3PR04MB7227:EE_ X-MS-Office365-Filtering-Correlation-Id: c78bd6ba-0ced-46b5-af6b-08dad2a16c5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 62Tq1/C3W0IUxUDbtDfEGs3axodDR2O6nNjuarqaQfLUQKb74t1p4sPGTvFTDUCtTOt38Ja4e+8v/acqd6lvZYKuK1m3dfZfJqzliYYa59E8lBm9s2dmsXK5wel4On1az13giv1wGPOqACvyuJZPKu5xLWfz0qV+KxmItpwMpWdOEbM9Fh8WAaUK5sKjbVXZ3b/ufLU86qtyZGrpgHbwEC/EAVj1r+k15wfuaI8APYyLcPZHwOLBHJiCHzKxN86nq8V8AEX2oVM81KQ/GPwUt2Unu/QryT5rG2cCfgnh4MsI3KfHXK4ZVYkBJb3g0YJ29/CTfbwvleTp4P0aAwqRvyKbN5EhToiYdVfiYO63Wz14cldjulH7YewbZz1VtAFGeYA+0qWVydJotdCBOSmfC27yXlS0eJPjGbhAtKjOhDcVB1BZCzw4wbc55PbY7QFLbsjgRtPJUFoXJ5THFqep9XMHbO1T+JjPe90FtDQMg0IaayzJMbcbXbgd94/NG37CJDzhIHALtG3qp/E9Kpw8ah0oWS6sikDRmQX+UwVdbJvDfIVEHX5G8W30jCf8/pzxtYxGI94b+PAcXIJCur9LVwKOhyc6yGbnq3KeferzR9PkbVrZVuiOvdY4iFQVshHcYSIVaA+6srJf9DJNB/dWOiKvAKqZf0qIDJMknnq4wueJw91bszte0TBZcMtefXlIV7Ig1B3Srok8588a8+EQEw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR04MB9591.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(366004)(451199015)(2906002)(6506007)(66476007)(41300700001)(6916009)(4326008)(66556008)(36756003)(186003)(316002)(8676002)(8936002)(5660300002)(86362001)(478600001)(26005)(6512007)(2616005)(6486002)(38350700002)(1076003)(6666004)(66946007)(52116002)(38100700002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CmcYS90sGZiYPjbxWaGwsEBnL3c021GYbd+iZ00r4zaQUtdHA8ihT5WPUCJh59XvmMbwtp17XpXkxmZ3jbnCR4cIYAQh8NdDObcyO8T63nXLZMqmmwJm8NpaMZ4iRVNf/RkAlvVf9/O0XVbOepJT8Ls58RMs7qmexGj2fg6aaNNMWEP4i/IlvdnEYK83zxQEZ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rSrXVccXPDgiegXP9hhJixnFGfjk7D4hgcIIpj9WvCLZzA9xkOvHKLnQz0qUfHvb/4YmYrr6Ja/W7+jjk1vUj5uSIEwbwtoOLVYoNUQkIrkPy0dXn7isyrDn4MP0mgrIevKaESH5ZfFo18an99/O+yvNBVRrydIYps22QXUkV7c1q5qYfH0241T0k9T0OUFptoJGDahr5FaFu+R70+0Kb1eNfDl1rLohymbAEYSGYpb67Dv4+p28jgrKd5ugKN7vviT8nxrAHhOwowxp2jetreu1kjpka8uwRFuNSKOxcS6wgW9AzppzAfIb79WvDAzr X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c78bd6ba-0ced-46b5-af6b-08dad2a16c5e X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9591.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 07:06:37.8558 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NxefVX4yeD/gnvrsrQS+7cbJph93fidsL8ssEJ9Iz20/eI1GA7A7Bks/APRQbhKDZR7WmUivVxIVVgIZGYdLIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7227 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Two 'role' file exist in different position but with totally same function. 1. /sys/devices/platform/soc@0/xxxxxxxx.usb/ci_hdrc.0/role 2. /sys/kernel/debug/usb/ci_hdrc.0/role This will remove the 2rd redundant 'role' debug file (under debugfs) and keep the one which is more closer to user. Signed-off-by: Xu Yang --- drivers/usb/chipidea/debug.c | 55 ------------------------------------ 1 file changed, 55 deletions(-) diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index faf6b078b6c4..37da83de3cba 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c @@ -247,60 +247,6 @@ static int ci_otg_show(struct seq_file *s, void *unused) } DEFINE_SHOW_ATTRIBUTE(ci_otg); -static int ci_role_show(struct seq_file *s, void *data) -{ - struct ci_hdrc *ci = s->private; - - if (ci->role != CI_ROLE_END) - seq_printf(s, "%s\n", ci_role(ci)->name); - - return 0; -} - -static ssize_t ci_role_write(struct file *file, const char __user *ubuf, - size_t count, loff_t *ppos) -{ - struct seq_file *s = file->private_data; - struct ci_hdrc *ci = s->private; - enum ci_role role; - char buf[8]; - int ret; - - if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) - return -EFAULT; - - for (role = CI_ROLE_HOST; role < CI_ROLE_END; role++) - if (ci->roles[role] && - !strncmp(buf, ci->roles[role]->name, - strlen(ci->roles[role]->name))) - break; - - if (role == CI_ROLE_END || role == ci->role) - return -EINVAL; - - pm_runtime_get_sync(ci->dev); - disable_irq(ci->irq); - ci_role_stop(ci); - ret = ci_role_start(ci, role); - enable_irq(ci->irq); - pm_runtime_put_sync(ci->dev); - - return ret ? ret : count; -} - -static int ci_role_open(struct inode *inode, struct file *file) -{ - return single_open(file, ci_role_show, inode->i_private); -} - -static const struct file_operations ci_role_fops = { - .open = ci_role_open, - .write = ci_role_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - static int ci_registers_show(struct seq_file *s, void *unused) { struct ci_hdrc *ci = s->private; @@ -354,7 +300,6 @@ void dbg_create_files(struct ci_hdrc *ci) if (ci_otg_is_fsm_mode(ci)) debugfs_create_file("otg", S_IRUGO, dir, ci, &ci_otg_fops); - debugfs_create_file("role", S_IRUGO | S_IWUSR, dir, ci, &ci_role_fops); debugfs_create_file("registers", S_IRUGO, dir, ci, &ci_registers_fops); }