Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2655739pxa; Mon, 17 Aug 2020 15:40:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqC8BqenuA5Hji1hcJXgXA9m5a+dxJm7MKotwVV9EeEGzXahq+K4fET4lkk0rPRnAEK1ic X-Received: by 2002:a50:bf07:: with SMTP id f7mr17357718edk.356.1597704014391; Mon, 17 Aug 2020 15:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704014; cv=none; d=google.com; s=arc-20160816; b=sq6cTpVKGCbS8D7pfLmZcv3I57xe4IihzfdR1eGnO1zuaSDjwWdNv6YloAzAD5rQkK r8tWFp9scc7hH6XvT4BFaJDmd7LlfofLB6PUaAlmlzh7xJs3zyI34FJ6wnCGSEzERLbJ 6B+vyETUltkzPa7giKtcANFWeq6OTA7H2+jipnLzfna9OE0euLy/6//jb+z31wIwk+78 7IO7g2qKn2fph+dnJG0GTvjktuYHw+M/DoVGKAlSPpAF/uNb3MG9I4Vp2WNpq/SrmGMt RVfIZyRWDWyxa1w14TPmiNuuQT+05WYAl8ldol8r/gbCSuHQhDTQCopK0VFCePxHe5M2 0OsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=y+qeoq49QePS/Vj83NR1G91nN4kB5nA+7WNZ9s9JnTU=; b=TLpr3w/2lf5Y4I6x+MrPUZ454yIB83Cj+yJvdt5ARTYG1haVSMcYxzmramBbSde5p0 osdeqg+yJr6VOfwv3wyaJN23ogmOfEqtKGZS0zUJxzqx6iI0MSxsq5ZxzCMLqXoAHBIY Ccc2IqYMaGKwBO8aqmwfw1HRANHqH1MBCKCxP8xQ1x0vBK/nUG8/2cDIPHPLxEEvUaat yBD5Mqb4UXbRv2JBonHpLLkILjklRZEe81IiJnoZpVvQ0rOwWIa/qtQ/b1KnUcS9eT1u Mjr/b5MJPlqazAKm+pDQTGtxC+DGZfiDNK+SLRhM6QqIqcRXnMi75CDMxwyZvGDvlDOW MiAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vf1AlNK7; 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 n19si12176631ejc.243.2020.08.17.15.39.51; Mon, 17 Aug 2020 15:40:14 -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=vf1AlNK7; 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 S2390546AbgHQSNB (ORCPT + 99 others); Mon, 17 Aug 2020 14:13:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:54112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388261AbgHQQHZ (ORCPT ); Mon, 17 Aug 2020 12:07:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 0DEB720657; Mon, 17 Aug 2020 16:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680419; bh=u2l8rYnpqO1GxowdoZloj+Y5TmSk8RmfO86+JjBpaeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vf1AlNK74UTneIhxgIRXftmbr5Es5M9f4iUFyJ3a1/bzc+3YgGpDKzRqliWR8gCdV iOoPO7msDr3A60Di3IuBzxi29FckXKjQwIsqV7rda2YgSXcEUbiuuPImIYEWTWZ6TY ZAJPB4uMo9I0o5IWWv22t26ff2DFSVcaHDeFtscs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver OHalloran , Michael Ellerman , Sasha Levin Subject: [PATCH 5.4 179/270] selftests/powerpc: Squash spurious errors due to device removal Date: Mon, 17 Aug 2020 17:16:20 +0200 Message-Id: <20200817143804.722146803@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oliver O'Halloran [ Upstream commit 5f8cf6475828b600ff6d000e580c961ac839cc61 ] For drivers that don't have the error handling callbacks we implement recovery by removing the device and re-probing it. This causes the sysfs directory for the PCI device to be removed which causes the following spurious error to be printed when checking the PE state: Breaking 0005:03:00.0... ./eeh-basic.sh: line 13: can't open /sys/bus/pci/devices/0005:03:00.0/eeh_pe_state: no such file 0005:03:00.0, waited 0/60 0005:03:00.0, waited 1/60 0005:03:00.0, waited 2/60 0005:03:00.0, waited 3/60 0005:03:00.0, waited 4/60 0005:03:00.0, waited 5/60 0005:03:00.0, waited 6/60 0005:03:00.0, waited 7/60 0005:03:00.0, Recovered after 8 seconds We currently try to avoid this by checking if the PE state file exists before reading from it. This is however inherently racy so re-work the state checking so that we only read from the file once, and we squash any errors that occur while reading. Fixes: 85d86c8aa52e ("selftests/powerpc: Add basic EEH selftest") Signed-off-by: Oliver O'Halloran Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20200727010127.23698-1-oohall@gmail.com Signed-off-by: Sasha Levin --- tools/testing/selftests/powerpc/eeh/eeh-functions.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/powerpc/eeh/eeh-functions.sh b/tools/testing/selftests/powerpc/eeh/eeh-functions.sh index f52ed92b53e74..00dc32c0ed75c 100755 --- a/tools/testing/selftests/powerpc/eeh/eeh-functions.sh +++ b/tools/testing/selftests/powerpc/eeh/eeh-functions.sh @@ -5,12 +5,17 @@ pe_ok() { local dev="$1" local path="/sys/bus/pci/devices/$dev/eeh_pe_state" - if ! [ -e "$path" ] ; then + # if a driver doesn't support the error handling callbacks then the + # device is recovered by removing and re-probing it. This causes the + # sysfs directory to disappear so read the PE state once and squash + # any potential error messages + local eeh_state="$(cat $path 2>/dev/null)" + if [ -z "$eeh_state" ]; then return 1; fi - local fw_state="$(cut -d' ' -f1 < $path)" - local sw_state="$(cut -d' ' -f2 < $path)" + local fw_state="$(echo $eeh_state | cut -d' ' -f1)" + local sw_state="$(echo $eeh_state | cut -d' ' -f2)" # If EEH_PE_ISOLATED or EEH_PE_RECOVERING are set then the PE is in an # error state or being recovered. Either way, not ok. -- 2.25.1