From patchwork Wed Mar 2 22:07:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 12766854 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 19654C433EF for ; Wed, 2 Mar 2022 22:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242609AbiCBWK2 (ORCPT ); Wed, 2 Mar 2022 17:10:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239678AbiCBWKY (ORCPT ); Wed, 2 Mar 2022 17:10:24 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2040.outbound.protection.outlook.com [40.107.244.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6A0CD0042; Wed, 2 Mar 2022 14:09:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDiBEWmBGjAq9xK5g5zZwn7VLXBkJoeZLyLdxjTzlGXPLglgH2dmp7A6a63OQUlB04PyWQ264qByL1keg63U7IT2MlXwfQqrQOzLd2vGNzcmVbo6jW33k5GP69SxWk1s2aGwiDQkBXxgnEVTWG94yh2ygbbCVpFrZE5ZohjM+C5G4hvPuI7vuyET21Bg8/PupbailxK76T53NYd7W7+yg++nJGIhdv490Va8pDt8pXE0uAsrwj3Llpl7EAUVzr3Sv9Blk/yV+xyOriwWM8zlYKoZOiW8HQht+P3WLDbJ9nxiUPahj9tFNqFEUZiGme2kYc7HDoSv6zKYh+IYV8l9Vw== 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=Hvvkz22cI/82moHwP8advDJCS98rfENENo3muQ1o8Z0=; b=aP3+lRS/i93/l7gzoDVfcBWT/GsCNiGob5ldpqUfG1PP4kcdDafojRfvkvtZ4uB1+5G0IkVmTvOe6i0ZHaHoyw3L43NiyvOixOTicpSei6eBWV7ndEZXNMrWXx7h40pszXvRMgYYSn7Db1GaqVULDfv5QxQ65yuPgnPqm23xZQwBAxzotzbGjx7UXHJnelJzAFcZ5ss8vCzYlswEic+/4JTsSCRNDkgUblaxmsw54CeCKcs+kBZSRQgjRpGcYnrIxS9YJMWOrem8KjxqvWUqqqGVIqfLLlbSuXBiThvc9yW0tuAcqumiheG5b2CV4kNFhA1Bd8Way4DkrbxiT1JWrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hvvkz22cI/82moHwP8advDJCS98rfENENo3muQ1o8Z0=; b=wzI0S9R43BnTJfgc4+RUP4umiv7IUfayPFBfd6vXM7VYRqoN6QvXk7UlB1epgX+VnCGujLIdJlV0GHh8VXDYJ8m9ndzJhaMQXZrEpJguXj2ZJ3OIVHcarU0IEVDl3HLzw9k3oWrMUnGC9PZJsv6gucskp5EWPyD4whxyxmAafP4= Received: from BN6PR22CA0026.namprd22.prod.outlook.com (2603:10b6:404:37::12) by DM5PR12MB1564.namprd12.prod.outlook.com (2603:10b6:4:f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Wed, 2 Mar 2022 22:09:19 +0000 Received: from BN8NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:404:37:cafe::5) by BN6PR22CA0026.outlook.office365.com (2603:10b6:404:37::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT044.mail.protection.outlook.com (10.13.177.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:19 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 2 Mar 2022 16:09:18 -0600 From: Mario Limonciello To: Mika Westerberg CC: "open list:THUNDERBOLT DRIVER" , , , Mario Limonciello Subject: [PATCH 1/5] drivers/thunderbolt: Retry DROM reads for more failure scenarios Date: Wed, 2 Mar 2022 16:07:05 -0600 Message-ID: <20220302220709.3138846-1-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74af3e69-31c3-4b6f-2013-08d9fc994c7b X-MS-TrafficTypeDiagnostic: DM5PR12MB1564:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cnu4x8tjpSUf5FZjc5iebXAlLYDsWJAAQtL8bIH96m5+uSK5mrkNrFFJMEdwQxm3+sldOrUxJEiM55OBQBqkqnDEor5ARmr5RAJxfk75Kbo6Oh1lAyv/FqkNAKyuya7MODM+1E1IHB5KgMlXGU/weoWOybA/PD2keuBYJ/Th38PPIJxl2EyLJPmH3f1driQw+NCtwlJGSHCubBAmnZIEmxk6k/x1g8CdlodWgb8DEwBY/a8rgyEAVGT0+leSRRkgNmESrixwzKyeFsTNeiXEfdjlLnATmOS8vbP+ZlcssjBITlTJqUcT/QPnnwD9ZzAmHfmarJ/Hi4fL3ygh7IITThMRSmkusq87Ul6hrbX1ifAKKQpCAZb7ep5xIgxA6t9LzEa9koLrZbuWUB5CT3MmUIxL83QT9QpJnMz0LCMq7/9kbAFYJ5hGYr1OOQKfI0g1h1oNMHt18qpJtdFKvT2gYCEhHf2dwpOfY/IKT2XHxWKxgSYCt32N7I492zz7vK6o+k089+abD0KEvp9z7U4v0Q3fNdWF5k4+yEk2Kg5iwo0XBHR9ncF+kFkjeHAvvWHAj1ZFcW4cI3yr/i640lhskkW1+eK34MSkMs1i7yEULqhU5+0926LYmKZrtMiD/Z0q11H08iIzzlLg0yzQagP9qPrwl1k3HffKKevI7SJICV68z7G/Vbq5uEZaLzKkKkdK6c8Fnf/hZGvY9CryrOeAdA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(83380400001)(47076005)(36756003)(36860700001)(426003)(336012)(54906003)(6916009)(186003)(44832011)(2906002)(5660300002)(26005)(6666004)(8936002)(16526019)(1076003)(2616005)(316002)(82310400004)(508600001)(4326008)(81166007)(356005)(86362001)(8676002)(70206006)(70586007)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2022 22:09:19.2344 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74af3e69-31c3-4b6f-2013-08d9fc994c7b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1564 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Currently DROM reads are only retried in the case that parsing failed. However if the size or CRC fails, then there should also be a retry. This helps with reading the DROM on TBT3 devices connected to AMD Yellow Carp which will sometimes fail on the first attempt. Signed-off-by: Mario Limonciello --- drivers/thunderbolt/eeprom.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c index 470885e6f1c8..10cdbcb55df9 100644 --- a/drivers/thunderbolt/eeprom.c +++ b/drivers/thunderbolt/eeprom.c @@ -553,9 +553,9 @@ static int tb_drom_parse(struct tb_switch *sw) crc = tb_crc8((u8 *) &header->uid, 8); if (crc != header->uid_crc8) { tb_sw_warn(sw, - "DROM UID CRC8 mismatch (expected: %#x, got: %#x), aborting\n", + "DROM UID CRC8 mismatch (expected: %#x, got: %#x)\n", header->uid_crc8, crc); - return -EINVAL; + return -EILSEQ; } if (!sw->uid) sw->uid = header->uid; @@ -654,6 +654,7 @@ int tb_drom_read(struct tb_switch *sw) sw->drom = kzalloc(size, GFP_KERNEL); if (!sw->drom) return -ENOMEM; +read: res = tb_drom_read_n(sw, 0, sw->drom, size); if (res) goto err; @@ -662,7 +663,11 @@ int tb_drom_read(struct tb_switch *sw) header = (void *) sw->drom; if (header->data_len + TB_DROM_DATA_START != size) { - tb_sw_warn(sw, "drom size mismatch, aborting\n"); + tb_sw_warn(sw, "drom size mismatch\n"); + if (retries--) { + msleep(100); + goto read; + } goto err; } @@ -683,11 +688,9 @@ int tb_drom_read(struct tb_switch *sw) /* If the DROM parsing fails, wait a moment and retry once */ if (res == -EILSEQ && retries--) { - tb_sw_warn(sw, "parsing DROM failed, retrying\n"); + tb_sw_warn(sw, "parsing DROM failed\n"); msleep(100); - res = tb_drom_read_n(sw, 0, sw->drom, size); - if (!res) - goto parse; + goto read; } if (!res) From patchwork Wed Mar 2 22:07:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 12766853 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 1A26DC4332F for ; Wed, 2 Mar 2022 22:09:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243711AbiCBWK1 (ORCPT ); Wed, 2 Mar 2022 17:10:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239783AbiCBWKY (ORCPT ); Wed, 2 Mar 2022 17:10:24 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2082.outbound.protection.outlook.com [40.107.244.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2427AC9A1E; Wed, 2 Mar 2022 14:09:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ie2AJ8/FTeniFcDKKcP8S8mT4a4WyBHeNpMxAP9y1WDgDdjFpgs2WrKGqMM3M9jIwi1t0VaPkIB+LuqJiwBH54qabH9TrmISYkrCYp8Y/sdBPprpWj0NXoNO75aJ9YxYgCcCMgx7DEUCxwkh9y8ZQHNy0S7/bNjqMznk6/KU5rpIbIey8qh8zD8RyvSDqb1XHNEvACLLd3LBPpIcca8snlhcEOPeROZGKUFOSdJLKoEpkvwFqLrBUgwjjHeXxBmiXzMT2mV9P3O4joxt3v74bTMJ5ar812sQvbEQewzVBzrhkRcws6XEX4Dks+LmHHz/15pTjObbwByvuoaWoKPu3Q== 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=zCqrZxd0x4LHePB1u+6qaISBjHoGsYqMHfzHZnmCBVg=; b=JBXmyJdjFCcwJsK92pPWeuv6r2B9lObehuQ1NsTE4LejWctOs5U0leWM2cKph5xNx7ES3jDzby2z0ofRRaFLMhxOED5obbwGQAPr5w7bf901hCg7Q/YazLQfoImiOGG41yaXdAlZ1GH0Wj6ul/FqHT93muZEV4IYavqg0Qmh/knhbkc3/g9VWh+GdxRDs8sGX02qYHHG+Alz7rkYdTnTAXLgUsZPyeQ4cIo41CBqY88sJzguArJ0/1XcIWDfzcT8NEe60PEDdCiIbprDgHFPbJ8MlgEl4nkXWT1Slpn04TL4P9LZhUdZbI6KIg/FpwNfO8JzzP/E6H5mUeZ6nZ1jNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zCqrZxd0x4LHePB1u+6qaISBjHoGsYqMHfzHZnmCBVg=; b=sVKb3mq6wRwO5DFz0XbKB4mPgnnQd40JV56DLpePuLgO2ZMBPvhsTIUXqv8LSxEHYQu38eP9aImEArfAIZfNVqaVl4w+zLl95E9sDi9imVMNLBdmuIyEbfsxkajy0xgyHEaiVq98aIbMMuO7ZUb6tf2j0NzQDE26lwnzge+Ye14= Received: from BN6PR22CA0037.namprd22.prod.outlook.com (2603:10b6:404:37::23) by BN8PR12MB3524.namprd12.prod.outlook.com (2603:10b6:408:68::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Wed, 2 Mar 2022 22:09:20 +0000 Received: from BN8NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:404:37:cafe::b1) by BN6PR22CA0037.outlook.office365.com (2603:10b6:404:37::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT044.mail.protection.outlook.com (10.13.177.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:20 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 2 Mar 2022 16:09:18 -0600 From: Mario Limonciello To: Mika Westerberg CC: "open list:THUNDERBOLT DRIVER" , , , Mario Limonciello Subject: [PATCH 2/5] drivers/thunderbolt: don't resume switches without uid set Date: Wed, 2 Mar 2022 16:07:06 -0600 Message-ID: <20220302220709.3138846-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302220709.3138846-1-mario.limonciello@amd.com> References: <20220302220709.3138846-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b88c5a6b-ed1e-45de-7831-08d9fc994d18 X-MS-TrafficTypeDiagnostic: BN8PR12MB3524:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BwAE/BQsGYJ7cXf0PbsQVY3TdnnxNALTakd+wWLSUz3P/8T48TdYyIAzNELp6NxSv8QKmC+WSTUQz7hDDwNK74bE0tO2LSHyc5Lz2Q0Ws4qGBLWAsvk3M0xPIOSSvZppkQk2wBs1mQ4IZbQ4SA9KlMGMCCSpM90ktO+D2aGaw1OHfxSkkugDYOfcI/q9poBi7VOx9cUhdcJqY/cml9rlK3MGQ52UubQ5gncY38b6BLhf59Kot0ND7MmPgOyHg0k5+v7Sxc4uv2jXluI1x4sCCKm/Hdeu0j8/cC7kw8YXGvD1h9wtuP3K5lC/IdtTfvW57qDlqLdopZIC9ah9mU+YegwmUI/RbeKqDBcxiuHfaXSao3h4FhLDmIWnX46XsYKLCg6LH4ApSIHNNROm1R+R47kZ0FwMW5IJmx63W/8uKMnRORNzv80rO+HjcJ5DtwdxoZEH5x+x/7drnu0YhF1nuzjGgrVd3zi4/SdABk200KODQrwnxV+UqAtQdDqA5/Op9id6CaNLdM2hwtm1dm+0t2dyV5mz3Eo/RW6x1rWTB06tSZekh9zhSQWJkBlHLIbT/xvbv8kKlWGemjzMRDydPMZhd0GC4tY9jzgX9K76GAjni/FocySRtvHFEo6p2K0BiojhYWderDiYe1LAkE6BzPDSj+CC4Uca9TIiOeQUmWJrXRFAZaNiBcV+SxLtYl2SCDDw72H875DDVXaAkns04g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(1076003)(36756003)(36860700001)(426003)(336012)(54906003)(6916009)(44832011)(2906002)(83380400001)(16526019)(47076005)(2616005)(8936002)(26005)(6666004)(5660300002)(186003)(316002)(82310400004)(508600001)(4326008)(81166007)(356005)(86362001)(70586007)(8676002)(70206006)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2022 22:09:20.2499 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b88c5a6b-ed1e-45de-7831-08d9fc994d18 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3524 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Switches might not have a uid set if the DROM read failed during initialization previously. Normally upon resume the uid is re-read to confirm it's the same device connected. * If the DROM read failed during init but then succeeded during resume it could either be a new device or faulty device * If the DROM read failed during init and also failed during resume it might be a different device plugged in all together. Detect this situation and prevent re-using the same configuration in these cirucmstances. Signed-off-by: Mario Limonciello --- drivers/thunderbolt/switch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index b5fb3e76ed09..294518af4ee4 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -2980,6 +2980,10 @@ int tb_switch_resume(struct tb_switch *sw) return err; } + /* We don't have any way to confirm this was the same device */ + if (!sw->uid) + return -ENODEV; + if (tb_switch_is_usb4(sw)) err = usb4_switch_read_uid(sw, &uid); else From patchwork Wed Mar 2 22:07:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 12766852 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 A9B01C433F5 for ; Wed, 2 Mar 2022 22:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235532AbiCBWKZ (ORCPT ); Wed, 2 Mar 2022 17:10:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238808AbiCBWKY (ORCPT ); Wed, 2 Mar 2022 17:10:24 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2075.outbound.protection.outlook.com [40.107.237.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B25F0C9A20; Wed, 2 Mar 2022 14:09:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ReJ875eHhGgvgts2QPrXUl2tvSkJpV9GP0os4cxm+/VGShnZKiQmfdBAeX9tiZ99X0TYzVG4ZbJn6RpwO4kna0VIVu8ecJUzVcz+O1G32DeqfPIX7LrUvEuVjp4cISC9q0Rs7UfQVkCW/M1smO7+yW1icqxONlGGBeUiGxYEpuwlsTsR7B7tsDyKI7vCKOwkUE+MrnunybOkB1tLXcPdkjSCndTfpv8+l3A50MXe8SA96G6O8rqEbu4BfiXWnwfx6LejR3xg+ikq4lUnVOmYb/F+VJtrhw1bQo2gcQfDwZYcoilP6Tx0LTFSBOsco+bQm+r8hmvIQDWPExMED41oYA== 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=Spa9pu8/1SaHXsaj9AeAFRMW1FYo419JQ+uIyb6cJ5o=; b=H3a4BRKQToxw9AiDq0Tol+vYhk+4VB5KPnWbyBh7DC4n9bK1/i11rLfpK+dgT9gZdHZoo4lNCjLx5ScsxNmgVfvJFVW/9RbVe5yHFlMuxx+2BAgDCXMvUVHmnnI0P8xGxmAm9CkFjxyEShbbdgYbqaPTBxEdes9FdIggX9aXEdI0/ZwESfu27oiSQvpgPWJk2R5zNgmTgEG27Nq2SDdzSHARfWLRtrbOpIKImC49sr7iB8hKc912HaH2WLj7k+2lFULESEOkPqs0bEPRGbPzX1967T5lOzDsKLVhChocKjfntG7lhFI6hanzgSxq4y9ioGgXgcYxOuCv7njeymzVBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Spa9pu8/1SaHXsaj9AeAFRMW1FYo419JQ+uIyb6cJ5o=; b=SxU87e8EfOHUkkd2FdxhPrY1Khhg5xwEcSNOpuWt7rDEF3aKKTpyrAPYjN3YCzGjZS0ZD4HkKB6HG8XlKANlaJrvkFr64TdfBrsjynlf17a0XcoslmlHna2spTkCR3sMScRjokJhMusWOER9ClpebbPqtqAltQB4odIq9UWqL7s= Received: from BN6PR22CA0039.namprd22.prod.outlook.com (2603:10b6:404:37::25) by BN6PR12MB1443.namprd12.prod.outlook.com (2603:10b6:405:e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Wed, 2 Mar 2022 22:09:21 +0000 Received: from BN8NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:404:37:cafe::85) by BN6PR22CA0039.outlook.office365.com (2603:10b6:404:37::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT044.mail.protection.outlook.com (10.13.177.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:20 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 2 Mar 2022 16:09:19 -0600 From: Mario Limonciello To: Mika Westerberg CC: "open list:THUNDERBOLT DRIVER" , , , Mario Limonciello Subject: [PATCH 3/5] drivers/thunderbolt: Don't make DROM read success compulsory Date: Wed, 2 Mar 2022 16:07:07 -0600 Message-ID: <20220302220709.3138846-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302220709.3138846-1-mario.limonciello@amd.com> References: <20220302220709.3138846-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30e43578-4ea3-4075-98fe-08d9fc994d7c X-MS-TrafficTypeDiagnostic: BN6PR12MB1443:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iVYhvtG8W1TZkJtOZBWVvTo+uB85n7U3GYAyUgUyjJ5XK8NqaVV/pdAKnyL/ArPupy+gV2XALKL+RD9kB3FNaaj8e4J0iwB2TRXJn0V3V3/LVmJ2NJBz/GOwQ36kdTHYkjNUAszPi0PvFsApfwc4Cu7MIyQRDrES0EF4pkv8tTcVpUpi6WJGlnPmYCbcQXClykAVy7t8N1LQNNy7Za9iteuSOit+TeAYV27yPEAhOKc5ZMMqOFNFE9DYvy7OVzilQuGdCm5Ar46yvzArG7nlgJnaf4KWmgeQt9ZpQECOLgokXU9Mv5q0ps4PdzmBdh6kEvPrsvnEA+BxbtnOQTR1LuxEbAVHVwDIVMafmAKNm/La+ku7awqZLOYcX0ZIe5XQBKvbVA7fOZjhc3P4sVI5S6/eBBJaSmzRlV1O9obpntEO+k0GMUhw4gndzr43a3Mi42MXzlgn3B0ircZlVWjW6/mqGc0iHG7DGT4IRjzxkg6SghWrDWMtirtId7o9xdkx5aj1Dl1kjDE2RxL6fR19R9YxIx9L5pboWmFYIvg4KxF2WKcej782UUIw3FaddQu7Q9XDUMnA4DJvsX3ZLx3O3Vvf3xdSfREg9DmigmBts3fopZpQ+zt/RQHr0EOblDT4olcVdko1fnfr1ObKVfRQ9FMfV8+OvE+rKfo62V4Dq1zQAoE3iqHe6lMN+d2yo8CFIeQ3M0LLV0f72xHtYzZ/iKTPQ7tvVywMgbvidHFavsUDUiSEw9kW07vemrIGDsCHr4x3Qvcu0vUnzDrgajDRr/BvsH5CqUezf9/pz2cs8Rs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(508600001)(86362001)(2906002)(44832011)(36756003)(82310400004)(5660300002)(966005)(40460700003)(70586007)(6666004)(8676002)(70206006)(4326008)(36860700001)(81166007)(356005)(66574015)(16526019)(47076005)(26005)(186003)(54906003)(336012)(1076003)(6916009)(2616005)(426003)(83380400001)(316002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2022 22:09:20.9217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30e43578-4ea3-4075-98fe-08d9fc994d7c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1443 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The USB4 specification doesn't make any requirements that reading a device router's DROM is needed for the operation of the device. On page 207 of the USB4 1.0 spec it does mention that a CM may use the DROM to make decision though: ``` After enumerating a Router, the Connection Manager may read the contents of the Router’s DROM. If, after reading the contents of DROM, the Connection Manager decides that it does not want the Router in its Domain... ``` Other connection manager solutions don't necessarily read it or gate the usability of the device on whether it was read. So make failures when reading the DROM show warnings but not fail the initialization of the switch. Link: https://www.usb.org/sites/default/files/USB4%20Specification%2020211116.zip Signed-off-by: Mario Limonciello --- drivers/thunderbolt/switch.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 294518af4ee4..ac87e8b50e52 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -2784,10 +2784,8 @@ int tb_switch_add(struct tb_switch *sw) /* read drom */ ret = tb_drom_read(sw); - if (ret) { - dev_err(&sw->dev, "reading DROM failed\n"); - return ret; - } + if (ret) + dev_warn(&sw->dev, "reading DROM failed: %d\n", ret); tb_sw_dbg(sw, "uid: %#llx\n", sw->uid); tb_check_quirks(sw); From patchwork Wed Mar 2 22:07:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 12766856 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 7AF62C433FE for ; Wed, 2 Mar 2022 22:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245386AbiCBWKb (ORCPT ); Wed, 2 Mar 2022 17:10:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244455AbiCBWK2 (ORCPT ); Wed, 2 Mar 2022 17:10:28 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2040.outbound.protection.outlook.com [40.107.212.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98D8FD76D8; Wed, 2 Mar 2022 14:09:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLAmvqFwnzj08FkuDGLUMuhqnsN2hKn+e/qukp1xDzkXLNNBWN/+PTP9EwEH4C7hqOOngnqguJXMCgs8T+O35pyQFCAJ9Vk/L5EMaHHp71rVku5CaWa/Lp9bbGjwMp67StxjD1OcCIot4/7XM5ocjQgedIklQJsWSWmZ+V17HnUhMY9w6AWnPB2VDvEsVp4pI+FyP5rZW3M0hl+rv516L9ToPBU56qTA1zlby0ht0m6BuKNbyTgdBhgQnJAFPqvpjR/7SDWX/S3koF1mfanFveC7vmG9xuZu4gHvFxG0YVobwqIOSumImBmXuizqXpYiuhSTCc6w84adx2Yz3nCHHQ== 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=iargjDpNmatEDQGnWAO2Dk+3PE3O4vlBH9Ssb40hmFM=; b=V2hdkxJTacUpWTooMv9WKXUYjsOY1ARxUnXxi1M6ToBm/WsPp60nm2W+IxLx2Ym7zScIGoQabyLKr8i/C4MXGBYB/nxf1hkMGlGutlwx5Ce0DJ4URTF6zwJr3vbrGKKy7ruGTnft2zOPgTFeupMNb+kcpQqq572/yuJlFe0LLf7DZuS4ANgmYBf/vfwxSsJAtF1/p1/eTsTtvTF4F0UxyJdjKNkYgZUuF0Rk+97cw0zSpdQhWLVR7MaItEQcp/R/LiYB1Iae3VWtnMdpHNNNBbT5B+oX1pTXSz5Wyjp2HKcp6jyTYaMGUyfgps8IzwAfuQIStWmjOowIlr50Zu+DjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iargjDpNmatEDQGnWAO2Dk+3PE3O4vlBH9Ssb40hmFM=; b=NeGC3cFeP+usGrmlVdtYOLj9kHrgfgrkflEg6oi04QMIMgoaMbQi+0mLUQK8Zn1/xoFUebZ7Xv/KtyXvUvVruI4I2Vf4gC4iSJDBKvT3Az+/dEE8HdMWLcyYS6XfPxDJGyvdc6k2XBR9AoM57Jvy7Zf23Gc5aaZUIX4t/wjiXuo= Received: from BN6PR22CA0032.namprd22.prod.outlook.com (2603:10b6:404:37::18) by BYAPR12MB3351.namprd12.prod.outlook.com (2603:10b6:a03:de::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.24; Wed, 2 Mar 2022 22:09:22 +0000 Received: from BN8NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:404:37:cafe::ac) by BN6PR22CA0032.outlook.office365.com (2603:10b6:404:37::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.13 via Frontend Transport; Wed, 2 Mar 2022 22:09:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT044.mail.protection.outlook.com (10.13.177.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:21 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 2 Mar 2022 16:09:19 -0600 From: Mario Limonciello To: Mika Westerberg CC: "open list:THUNDERBOLT DRIVER" , , , Mario Limonciello Subject: [PATCH 4/5] drivers/thunderbolt: Clarify/correct register offsets for tb_cap_plug_events Date: Wed, 2 Mar 2022 16:07:08 -0600 Message-ID: <20220302220709.3138846-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302220709.3138846-1-mario.limonciello@amd.com> References: <20220302220709.3138846-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd764558-0fe8-4bdd-430b-08d9fc994dea X-MS-TrafficTypeDiagnostic: BYAPR12MB3351:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LWtV5Y2eAXIkUu615tieCBgbnLEKhEEre6iLM/vmTea6wdAFp97OuXoRM8+Kb1W4lv9FZC8NC9kS+3m3xREHA31HlEOjIRk3Nj33ZCQVXplx+aTE6oYvqNnABM6iAZK17ieF24fTlVMWmZ5yqsUMl1KXBKqrjPUrpDMpdofbsamSHLQZcCi9dXPj4j2C8PJpAvJljhiYBxpm2PBzsQDa1Z/Y7JGAomBsBuVJSoP8on6lZfTtUye7piyOllJkarbEI2xN9k/lWHwwh6/iQNiN/Y8USwqcJKlGCm+BYqcJI1kyptqO3wxRM4kmUY1XAr52jM6tCiae3zbOw3MnMYGvDMo6gS3s0UZ0zQJraz4o5f6vdjk+IOAfSTyiqDnB9IzsXin2IO+hGXNHWqg1cJliVfu4hXpQUVOaA+efAPmxW9b3mz3J0pEpv/rylkIGUl7lNPJIpnvjZyUQjiuOd1v+Xsja02/suqTDf7exBTlwLXbEelJGNipVJbN8w2HOJngYqdjEd78VMY9bMjbtoKClNf2MvVwr8R4xxeZQ2Aie3rktJRcMdedH18ezbmUIhs3LYnhEltVYi4ue64wOJeEYXCWiXlnMCqbjIBW9RSjEm1Sl1mTyge3Jszl7MxMrt/FICQJtoao7750Y9ABV+NMnJWH7Q1NM2cnkY5He0GtViih97k1VNr+9LO9AsPnSXf6y36EOcARjqS9CdX3wvYWYvwQdOs9AICT5Kprpmy5qj8MEosidbJIwBXckv4uwqgeHBl//UC/9l2+sZ0bPSzCtjo3g/qGiuUD7PHp7j1oXPRY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(2906002)(2616005)(8936002)(1076003)(86362001)(8676002)(426003)(5660300002)(82310400004)(44832011)(186003)(4326008)(16526019)(26005)(6666004)(336012)(316002)(81166007)(356005)(966005)(70586007)(508600001)(83380400001)(40460700003)(54906003)(36860700001)(6916009)(47076005)(36756003)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2022 22:09:21.6404 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd764558-0fe8-4bdd-430b-08d9fc994dea X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3351 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The USB4 1.0 specification outlines the `cap_plug_events` structure in table 13-14 located on page 507. This shows that there was a mistake in VSC_CS_1 where plug events disable should be 4 bits and "TBT3-Compatible" should be 3 bits. While correcting the mistake, update the names and comments to more closely match the specification. This should not change anything functionally. Link: https://www.usb.org/sites/default/files/USB4%20Specification%2020211116.zip Signed-off-by: Mario Limonciello --- drivers/thunderbolt/tb_regs.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/thunderbolt/tb_regs.h b/drivers/thunderbolt/tb_regs.h index 70795a2aa9bb..8c42f8bc679e 100644 --- a/drivers/thunderbolt/tb_regs.h +++ b/drivers/thunderbolt/tb_regs.h @@ -146,14 +146,14 @@ struct tb_eeprom_ctl { struct tb_cap_plug_events { struct tb_cap_extended_short cap_header; - u32 __unknown1:2; - u32 plug_events:5; - u32 __unknown2:25; - u32 __unknown3; - u32 __unknown4; + u32 __unknown1:3; /* VSC_CS_1 */ + u32 plug_events:4; /* VSC_CS_1 */ + u32 __unknown2:25; /* VSC_CS_1 */ + u32 vsc_cs_2; + u32 vsc_cs_3; struct tb_eeprom_ctl eeprom_ctl; - u32 __unknown5[7]; - u32 drom_offset; /* 32 bit register, but eeprom addresses are 16 bit */ + u32 __unknown5[7]; /* VSC_CS_5 -> VSC_CS_11 */ + u32 drom_offset; /* VSC_CS_12: 32 bit register, but eeprom addresses are 16 bit */ } __packed; /* device headers */ @@ -464,6 +464,10 @@ struct tb_regs_hop { /* Plug Events registers */ #define TB_PLUG_EVENTS_USB_DISABLE BIT(2) +#define USB4_PLUG_EVENTS_LANE_DISABLE BIT(3) +#define USB4_PLUG_EVENTS_DPOUT_DISABLE BIT(4) +#define USB4_PLUG_EVENTS_LOW_DPIN_DISABLE BIT(5) +#define USB4_PLUG_EVENTS_HIGH_DPIN_DISABLE BIT(6) #define TB_PLUG_EVENTS_PCIE_WR_DATA 0x1b #define TB_PLUG_EVENTS_PCIE_CMD 0x1c From patchwork Wed Mar 2 22:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 12766855 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 DE8DBC4332F for ; Wed, 2 Mar 2022 22:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245341AbiCBWK3 (ORCPT ); Wed, 2 Mar 2022 17:10:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234152AbiCBWK0 (ORCPT ); Wed, 2 Mar 2022 17:10:26 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2057.outbound.protection.outlook.com [40.107.101.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5AFFD109C; Wed, 2 Mar 2022 14:09:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kOYsVIQBbfs6UBuUsTsKLsU+cbQJjo4pCiPo1l/VZkJpy6R8PPVDzkL9p2qnrwpx3xonAhlp5RdPpcu8AGSfG207mTKfJtQMuprvn7XdhMLltfKYAZOEEbAJocg9vJru3QOjEN5ifXrnZGynWNDeF4QvTnvAC3IB8jFTD+XfIO4RQ6LXHTS8l9shJEEixuMGtn07o6D/JsW3Sndw/kQyHW5WjBIBBYZLY9ADX3A7h/xaYnaRsvtMRmx2Y9V1mo4V3FC8R7rVx35c797dOMByW5Sa3gNY639u9PohSLWHX1p3p31BH3wBuoNG58LgRNwNmAHeMugsU5rkLhMSEmnxBw== 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=QxowHVgZdoZMhs9XiUyKIrhkZPWp+x3L7Wm7eDtKpHk=; b=jbgbKneM6j/Q7bzUql6q/fFK9AznLBa8JIE5UW7IpxAkNPx+3tn482uINeEWY9pfCak6QrmkzVyMnt1MSF3n5M7rBUrK6ff6wBdwFgavmepSmwM16JC94QU5WDs/xV87Oc1mJSTtu77rqdqkqMwzJggCpjYJlW/FZsiVLPeXAK+PVUtIxA9duVXpVzoAKK33oQ5RUITY0ziq1S5ocyZUe2zbnW59LjzECyrIv3nhX+pyhLw+xJPXwvxy/+J5KOUXlD9VwLKzoxDz5IchPurMwtfy8hKwqDDG6o/oZ6QSg8+wrT+vYuj8vb4DZS1etj4nfjD0QxRdkJYN8OW8ldS8pA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QxowHVgZdoZMhs9XiUyKIrhkZPWp+x3L7Wm7eDtKpHk=; b=stDzonHoA8+KnZGlydxf1N3mjoVu5oqm9Di/5cqF4HOdrH1clviFr8e1WxW5Z2J87eQ9VnynrLsQ1W+GWbe1l0tahfyU6hLuCehBtfKVL/QQlTxlNbb70FQob51mEZKuqANA2i+v51kMPvMj5NyP+XzUVVWgFLDT6sivhP1UvB8= Received: from BN6PR19CA0096.namprd19.prod.outlook.com (2603:10b6:404:133::34) by DM6PR12MB3947.namprd12.prod.outlook.com (2603:10b6:5:148::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.24; Wed, 2 Mar 2022 22:09:23 +0000 Received: from BN8NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:404:133:cafe::ca) by BN6PR19CA0096.outlook.office365.com (2603:10b6:404:133::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT044.mail.protection.outlook.com (10.13.177.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 22:09:22 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 2 Mar 2022 16:09:20 -0600 From: Mario Limonciello To: Mika Westerberg CC: "open list:THUNDERBOLT DRIVER" , , , Mario Limonciello Subject: [PATCH 5/5] drivers/thunderbolt: Rename EEPROM handling bits to match USB4 spec Date: Wed, 2 Mar 2022 16:07:09 -0600 Message-ID: <20220302220709.3138846-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302220709.3138846-1-mario.limonciello@amd.com> References: <20220302220709.3138846-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 41470ac5-a27c-4248-86ae-08d9fc994e93 X-MS-TrafficTypeDiagnostic: DM6PR12MB3947:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PYmb9m0mf8Jjh1GHdDDx6QW7UGDr2Kxx3rHB7GujOY9m3s8YEx0kIgatQS7hOeKiJk/91tOblrFuhiloM/+wH+6Z8AxpELidJplC/eb6tRwl+PKRPdo//EExsR/WB7g66g4mToizKOQE2FUyQDMR+SDOkWmm3emKmYM/xdGm42E8INp9l8MEK00q1TrnH64qEBzj1u0JwvypMIVxtwRBoH/xmpeEmuM3XaqXjzVA/mi5fAKN62dMoZ808UK23331/HQb4E42IcF/gFTCtie0bynaXV5KSTg+pGCOwNDkXv1pqd+1dhW2+RGfTcgCK8l6dX76xnmkYea5+1NJtNhhqnAwDgAdZe8wA+yzDRzXlUtoZkAJF/3QB2O6liIHE9ZnQldM8mnu5I9Bw1H+FUhD/3m3lweR0dgVtju80RsK1/knG56TJ8cjWUlyRNNgWZbxnApXT8ApDDkNIj+SDIWT4crNT1BCLBke+rGy49Azi3K4qBAcpNJ1zMRe1UFSGUgYY6eq1Xi1w5PGmmDXzNJBR3HU4Dhzt3BY689NnIK3K6lOOezgf9LdnYB0kQ+OXhKzcnfcYlIro6vQE7458+H74xuzJ+meVHhS9n0Jusan5bcEmoOwxvGuXM57iv614G0Qdp4oVkIT5N1WLsvZypXpL+MRxdXbsroqMNtNvAjUBnH9LA3DZaqWyCfsOJvWpOnq8umakHre9Exvtm1no5LSzw6KS1u9B/w1ch9MtpzGlNCtYoJQ4AUzeYFLzHf1J4XKCF+8M9pdwb/DnVI/L6qCCsRlA9O/EFMl/i7cn/caAog= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(66574015)(47076005)(70206006)(4326008)(70586007)(316002)(2906002)(86362001)(36756003)(36860700001)(6916009)(54906003)(44832011)(82310400004)(8676002)(8936002)(356005)(81166007)(5660300002)(6666004)(1076003)(2616005)(508600001)(186003)(16526019)(26005)(966005)(336012)(426003)(40460700003)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2022 22:09:22.7497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41470ac5-a27c-4248-86ae-08d9fc994e93 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3947 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The structure `tb_eeprom_ctl` is used to show the bits accessed when reading/writing EEPROM. As this structure detail is specified in VSC_CS_4 on page 510 of the USB4 specification in table 13-14, update the names and use of members to match the specification. This should not change anything functionally. Link: https://www.usb.org/sites/default/files/USB4%20Specification%2020211116.zip Signed-off-by: Mario Limonciello --- drivers/thunderbolt/eeprom.c | 24 ++++++++++++------------ drivers/thunderbolt/tb_regs.h | 10 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c index 10cdbcb55df9..c90d22f56d4e 100644 --- a/drivers/thunderbolt/eeprom.c +++ b/drivers/thunderbolt/eeprom.c @@ -17,7 +17,7 @@ */ static int tb_eeprom_ctl_write(struct tb_switch *sw, struct tb_eeprom_ctl *ctl) { - return tb_sw_write(sw, ctl, TB_CFG_SWITCH, sw->cap_plug_events + 4, 1); + return tb_sw_write(sw, ctl, TB_CFG_SWITCH, sw->cap_plug_events + ROUTER_CS_4, 1); } /* @@ -25,7 +25,7 @@ static int tb_eeprom_ctl_write(struct tb_switch *sw, struct tb_eeprom_ctl *ctl) */ static int tb_eeprom_ctl_read(struct tb_switch *sw, struct tb_eeprom_ctl *ctl) { - return tb_sw_read(sw, ctl, TB_CFG_SWITCH, sw->cap_plug_events + 4, 1); + return tb_sw_read(sw, ctl, TB_CFG_SWITCH, sw->cap_plug_events + ROUTER_CS_4, 1); } enum tb_eeprom_transfer { @@ -46,18 +46,18 @@ static int tb_eeprom_active(struct tb_switch *sw, bool enable) if (res) return res; if (enable) { - ctl.access_high = 1; + ctl.bit_banging_enable = 1; res = tb_eeprom_ctl_write(sw, &ctl); if (res) return res; - ctl.access_low = 0; + ctl.fl_cs = 0; return tb_eeprom_ctl_write(sw, &ctl); } else { - ctl.access_low = 1; + ctl.fl_cs = 1; res = tb_eeprom_ctl_write(sw, &ctl); if (res) return res; - ctl.access_high = 0; + ctl.bit_banging_enable = 0; return tb_eeprom_ctl_write(sw, &ctl); } } @@ -65,8 +65,8 @@ static int tb_eeprom_active(struct tb_switch *sw, bool enable) /* * tb_eeprom_transfer - transfer one bit * - * If TB_EEPROM_IN is passed, then the bit can be retrieved from ctl->data_in. - * If TB_EEPROM_OUT is passed, then ctl->data_out will be written. + * If TB_EEPROM_IN is passed, then the bit can be retrieved from ctl->fl_do. + * If TB_EEPROM_OUT is passed, then ctl->fl_di will be written. */ static int tb_eeprom_transfer(struct tb_switch *sw, struct tb_eeprom_ctl *ctl, enum tb_eeprom_transfer direction) @@ -77,7 +77,7 @@ static int tb_eeprom_transfer(struct tb_switch *sw, struct tb_eeprom_ctl *ctl, if (res) return res; } - ctl->clock = 1; + ctl->fl_sk = 1; res = tb_eeprom_ctl_write(sw, ctl); if (res) return res; @@ -86,7 +86,7 @@ static int tb_eeprom_transfer(struct tb_switch *sw, struct tb_eeprom_ctl *ctl, if (res) return res; } - ctl->clock = 0; + ctl->fl_sk = 0; return tb_eeprom_ctl_write(sw, ctl); } @@ -101,7 +101,7 @@ static int tb_eeprom_out(struct tb_switch *sw, u8 val) if (res) return res; for (i = 0; i < 8; i++) { - ctl.data_out = val & 0x80; + ctl.fl_di = val & 0x80; res = tb_eeprom_transfer(sw, &ctl, TB_EEPROM_OUT); if (res) return res; @@ -126,7 +126,7 @@ static int tb_eeprom_in(struct tb_switch *sw, u8 *val) res = tb_eeprom_transfer(sw, &ctl, TB_EEPROM_IN); if (res) return res; - *val |= ctl.data_in; + *val |= ctl.fl_do; } return 0; } diff --git a/drivers/thunderbolt/tb_regs.h b/drivers/thunderbolt/tb_regs.h index 8c42f8bc679e..872d8977d5e9 100644 --- a/drivers/thunderbolt/tb_regs.h +++ b/drivers/thunderbolt/tb_regs.h @@ -133,11 +133,11 @@ struct tb_cap_phy { } __packed; struct tb_eeprom_ctl { - bool clock:1; /* send pulse to transfer one bit */ - bool access_low:1; /* set to 0 before access */ - bool data_out:1; /* to eeprom */ - bool data_in:1; /* from eeprom */ - bool access_high:1; /* set to 1 before access */ + bool fl_sk:1; /* send pulse to transfer one bit */ + bool fl_cs:1; /* set to 0 before access */ + bool fl_di:1; /* to eeprom */ + bool fl_do:1; /* from eeprom */ + bool bit_banging_enable:1; /* set to 1 before access */ bool not_present:1; /* should be 0 */ bool unknown1:1; bool present:1; /* should be 1 */