Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp1299158pxw; Sat, 9 Apr 2022 19:09:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXAZ/txk2uvFwTnwuUGJC2w9u4r3dmA1SnZEqRjQotJt1jlcHEtq7s2AQ16qqm4GgAvup8 X-Received: by 2002:a17:902:f542:b0:156:b46e:2403 with SMTP id h2-20020a170902f54200b00156b46e2403mr26594254plf.62.1649556566453; Sat, 09 Apr 2022 19:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649556566; cv=none; d=google.com; s=arc-20160816; b=NrHxlfvCR7NuskIMQYZf8VP5FM+LLa96kar/dRkW2Th/wPhYt/YLqzOeFXnB7I0Kym RgxHQKrXIpOVCY0o6mJDVbzzL0HIcUvmVYdPLj4qzCrYaHX8kNDTCQNKmr/SOTSgFk74 v98Gk8MZ7GKHsCFV8o/mQd3PCn18FP3451ZyzW7uXwuOjxxBm2RCJS5UKZVUw8QMHXRu 43FHEXjXwTkz+CXwFg+RSvenE7QIHSoxsWmdnnD9CO0AzOh/UWIOgmrUDzAUTaxs7/Yw Ro2MmwABp/DJnEgOQioAmdRGLmv4yhdE6j69WZAxWbOdvlduEdznDvA7DRhGp5wbYOYJ 275w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Kequ+WpirKIQ59/ycDNPta1nBeWyAXU4lA/Djd7Ix7c=; b=lGQ7LRhKSHGbFf7VEXxoC2FZtLosj4GO8lXJrDMvywnsofTXalbb7qRbHFqsOHvTk+ Yh40V5M8f6hXy3iplX89sElHXQaG3/AphgytOdjhca5J1oEpXltlHtkbLSOxAhuNnFbR Rop3DEipkKCs4g1tOWO9zGZEK2uYWnSjn7yRCwLUO8xvQaa2WlrBQcIkRZcjpecC30Qc g9/W5ZENZd7zBTHKzTCTkssM5OsvyzGMe/9jDoBcIL/jGWzLhCqJgccjlM3kwJvGGgif 6rorBRV3+tnHpdRQg0xF45lcRp7BLwQBu+Bd5MqNoyVYUo9rHeS5/J2G0BBYwApC2G1h i40A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v11-20020a63f20b000000b0039849ba63aasi5466286pgh.566.2022.04.09.19.09.12; Sat, 09 Apr 2022 19:09:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234111AbiDIIPZ (ORCPT + 99 others); Sat, 9 Apr 2022 04:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbiDIIPZ (ORCPT ); Sat, 9 Apr 2022 04:15:25 -0400 Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97B7B102D; Sat, 9 Apr 2022 01:13:17 -0700 (PDT) Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id BE3B81C0B8F; Sat, 9 Apr 2022 10:13:15 +0200 (CEST) Date: Sat, 9 Apr 2022 10:13:15 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Liguang Zhang , Bjorn Helgaas , Lukas Wunner Subject: Re: [PATCH 5.10 126/599] PCI: pciehp: Clear cmd_busy bit in polling mode Message-ID: <20220409081314.GA19452@amd> References: <20220405070258.802373272@linuxfoundation.org> <20220405070302.589741179@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bg08WKrSYDhXBjb5" Content-Disposition: inline In-Reply-To: <20220405070302.589741179@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Liguang Zhang >=20 > commit 92912b175178c7e895f5e5e9f1e30ac30319162b upstream. >=20 > Writes to a Downstream Port's Slot Control register are PCIe hotplug > "commands." If the Port supports Command Completed events, software must > wait for a command to complete before writing to Slot Control again. >=20 > pcie_do_write_cmd() sets ctrl->cmd_busy when it writes to Slot Control. = If > software notification is enabled, i.e., PCI_EXP_SLTCTL_HPIE and > PCI_EXP_SLTCTL_CCIE are set, ctrl->cmd_busy is cleared by pciehp_isr(). >=20 > But when software notification is disabled, as it is when pcie_init() > powers off an empty slot, pcie_wait_cmd() uses pcie_poll_cmd() to poll for > command completion, and it neglects to clear ctrl->cmd_busy, which leads = to > spurious timeouts: I'm pretty sure this fixes the problem, but... it is still not fully correct. > +++ b/drivers/pci/hotplug/pciehp_hpc.c > @@ -98,6 +98,8 @@ static int pcie_poll_cmd(struct controll > if (slot_status & PCI_EXP_SLTSTA_CC) { > pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, > PCI_EXP_SLTSTA_CC); > + ctrl->cmd_busy =3D 0; > + smp_mb(); > return 1; > } Is the memory barrier neccessary? I don't see corresponding memory barrier for reading. If it is neccessary, should we have WRITE_ONCE at the very least, or probably normal atomic operations? Best regards, Pavel --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --bg08WKrSYDhXBjb5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmJRQBoACgkQMOfwapXb+vJmSACgki8gGnt/pbitsMqI7fSOXeB6 KMcAn3tpJEX3NYiHw6SwAKOoI6HrVXiR =5uvu -----END PGP SIGNATURE----- --bg08WKrSYDhXBjb5--