Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3289543pxk; Mon, 21 Sep 2020 09:48:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbE6kJPYljdpKQY3lj/TnbSLTx98n4/iUeh5M8aq/WJoiZ7GanoU43n317+SNUWslg65HP X-Received: by 2002:a50:eb0a:: with SMTP id y10mr567035edp.89.1600706885376; Mon, 21 Sep 2020 09:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706885; cv=none; d=google.com; s=arc-20160816; b=L+vi5csI5T0WXT85V2L5ZhKbJ9T/h0coI1dNZ4lmzY7MM4AACKsbt/oCUYVUwgw8yc kFjG0kRnfhYRX6aXYPl8mUS0lX+NtCOGGR4PQfmDmWdTyq9Fo1dolUU53s70rJoqe8z8 1620bYtOsfjD52FV6u4rohZ+uHLXYonsbBQeekSN3DDqMc8giJFy+EcxQmH5PtiqaS4r 1rUTNviZPbsxW0BREelaq0dGNhem+UERgZoNSJ6WjSvU30JKzMU7UyZfr3SdN0/GdeVV xC0TS5ZJwcWxnaJXqKJaa1UZdb02S9mL6lr28edyl+1ywtxEjzLsYPzYV1p9SCC5ssPn zH1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sf1/hgy5Pn4ampxLxfXbbGzsi4DqFQYSH5XbWdD8LUo=; b=Vf6TX6JyH3QNKbVhjn4R0yG9NPiNOEpTpcNGKzuq6GIRsYeApT3Xo74Gk23URCGKHs kX9G0D/ZRDbnPNXkRhN4HTw68r1ZvaYAmfymINwLWcDMzGGH1lafIE7Ehdh6VxuZ3DQR ljzB3OJofp9aX1zVks3KXkdRfGVGAd0OKI+VPH2Ksh3pniPDyZAP0hgSvEK32OyrgoN8 vYH73FevOUxBgya8o4oqOfahg+qi2EIxc+nGCJx4mJtlgdAIbq5143wR2M38Q5TRNlJ2 OwbbQX4C+vKH2m6cm3zhVm6XtHZSwtA7TsQr8nEQnhAUBwkcfqrcaETsPWCjIAaksikx ecdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MJd0cyVu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm16si8476890edb.114.2020.09.21.09.47.41; Mon, 21 Sep 2020 09:48:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MJd0cyVu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729751AbgIUQqw (ORCPT + 99 others); Mon, 21 Sep 2020 12:46:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:52978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727333AbgIUQqf (ORCPT ); Mon, 21 Sep 2020 12:46:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7F1AE2223E; Mon, 21 Sep 2020 16:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706795; bh=pKSsipCzyCNmft1hAUmQoYh2br4qEHGJ8HzT9uh/vvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJd0cyVu5cpXSh2rRNkhqkInFgDkHHL+DCQKlb6RNt5kqyYkC9pv6BnsDxZFvu6W7 fXOdtRScX+Iq8yHHx1WWIbIaBPMUYdF2fYU5jSBA+ypGXVFOkRzA03pXcIP49mu5Ey qve2oN9Ef+nBoLbby5M4tyafpBzaP6/YJdtKGQoI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai-Heng Feng , Mika Westerberg Subject: [PATCH 5.8 098/118] thunderbolt: Retry DROM read once if parsing fails Date: Mon, 21 Sep 2020 18:28:30 +0200 Message-Id: <20200921162040.925938340@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mika Westerberg commit f022ff7bf377ca94367be05de61277934d42ea74 upstream. Kai-Heng reported that sometimes DROM parsing of ASUS PA27AC Thunderbolt 3 monitor fails. This makes the driver to fail to add the device so only DisplayPort tunneling is functional. It is not clear what exactly happens but waiting for 100 ms and retrying the read seems to work this around so we do that here. Link: https://bugzilla.kernel.org/show_bug.cgi?id=206493 Reported-by: Kai-Heng Feng Tested-by: Kai-Heng Feng Cc: stable@vger.kernel.org Signed-off-by: Mika Westerberg Signed-off-by: Greg Kroah-Hartman --- drivers/thunderbolt/eeprom.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) --- a/drivers/thunderbolt/eeprom.c +++ b/drivers/thunderbolt/eeprom.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include "tb.h" @@ -389,8 +390,8 @@ static int tb_drom_parse_entries(struct struct tb_drom_entry_header *entry = (void *) (sw->drom + pos); if (pos + 1 == drom_size || pos + entry->len > drom_size || !entry->len) { - tb_sw_warn(sw, "drom buffer overrun, aborting\n"); - return -EIO; + tb_sw_warn(sw, "DROM buffer overrun\n"); + return -EILSEQ; } switch (entry->type) { @@ -526,7 +527,8 @@ int tb_drom_read(struct tb_switch *sw) u16 size; u32 crc; struct tb_drom_header *header; - int res; + int res, retries = 1; + if (sw->drom) return 0; @@ -611,7 +613,17 @@ parse: tb_sw_warn(sw, "drom device_rom_revision %#x unknown\n", header->device_rom_revision); - return tb_drom_parse_entries(sw); + res = tb_drom_parse_entries(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"); + msleep(100); + res = tb_drom_read_n(sw, 0, sw->drom, size); + if (!res) + goto parse; + } + + return res; err: kfree(sw->drom); sw->drom = NULL;