Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp850488pxb; Wed, 6 Apr 2022 01:55:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIKs/TwiHhQ9LejPofmO7ZIi56kyCEKRM2xa+I73MTHeuvYaeHbfIka7JuDnvvv1aMjhkj X-Received: by 2002:a63:541f:0:b0:399:3007:e7a2 with SMTP id i31-20020a63541f000000b003993007e7a2mr6291929pgb.568.1649235310122; Wed, 06 Apr 2022 01:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649235310; cv=none; d=google.com; s=arc-20160816; b=T15liKWlWE0wDFsf8ssftqq6pAmTHVo7ILk5gvWEijLW9/8YtxeHgVQ2NMlzUqisxT hQGSHiyWJLa6c34kZf9oYREn+YyJT/fS6ToWS2rL83Nvfc+a7IcKV08+7H/5KHAyQEh8 1EvgdI78DIX3TQ6dZu1ocQGv6BFOvU/tUQ/QLU/kewRLje7VCTqNS01W1x+UFQ+arhqO KnGP5JKZxjkqINAKbUWtxJS+CWeQJDAC75wCVtbCu2qUVCx5Vm2FibgHFfqy8gFwPZ+W g9Ml6nkr85Klr0Brv4ydlQAco0VhcnKLxflb/3Nsw+Ha94g5wTDeZcRGSYuAfTavb6Yb uT/A== 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=s+K4oDQXDr7w09gZ4+q3lF4JUvOkAWLdp+9Q4eA4cPM=; b=blSo57Bujm3wMBZ0vI8CwpkpC6zeGMW8j+IhILEy4wUTZM/T5p19Kr/sgIPT+e8G0p fUCnQWoMOo5QdGhyLZAPaWfXTMp6BqvMdrPDpql20qNwSL4+aPoDPqY1kR6mUA5Annjw eqB3bQVW8zn7TkP7YWqlz/7266o+pAgnokhMZupHgO5DP1ba12ltByCTmPdsArGgTIko HMPUmYxL6BcfUUrLQtJjzuL9pF+rgiw/qJOIunUIJGjNzPRKjy0dscqlJy0BAnuJmXcZ dssHkHDO2wlNSwVVBxMulCwnvhgIM1Qj/x2UGpiv20NW7pc95IsUVFunJE4li6PAyunk FIqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qzJIlIte; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j4-20020a056a00130400b004fa79753128si14997181pfu.62.2022.04.06.01.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 01:55:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qzJIlIte; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C88E588C5E; Wed, 6 Apr 2022 01:47:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1583978AbiDEX5d (ORCPT + 99 others); Tue, 5 Apr 2022 19:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356219AbiDEKXa (ORCPT ); Tue, 5 Apr 2022 06:23:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B10354AE3E; Tue, 5 Apr 2022 03:07:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4C1D06172B; Tue, 5 Apr 2022 10:07:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CA61C385A2; Tue, 5 Apr 2022 10:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649153273; bh=x/BbDqLS16fO//8ZLAlr4JSJFLAy2lcDbX54ZoBLp9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qzJIlItemYtHABHJH3NE5rupX2FkYiB8h5e1eJyRBc53TuC0AoBZnBSY8MfxV/8dd o60D9XDdxNf+9DPn5/hvePDZm3eobhkPDXr5qbWIcLgvNid8Ikd9+r1WXy3uP5bDXS T5ZaRTdVczrnheXrszcRARR0j6rCgjRwPoeH/imM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liguang Zhang , Bjorn Helgaas , Lukas Wunner Subject: [PATCH 5.10 126/599] PCI: pciehp: Clear cmd_busy bit in polling mode Date: Tue, 5 Apr 2022 09:27:00 +0200 Message-Id: <20220405070302.589741179@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 From: Liguang Zhang commit 92912b175178c7e895f5e5e9f1e30ac30319162b upstream. 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. 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(). 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: pcieport 0000:00:03.0: pciehp: Timeout on hotplug command 0x01c0 (issued 2264 msec ago) pcieport 0000:00:03.0: pciehp: Timeout on hotplug command 0x05c0 (issued 2288 msec ago) Clear ctrl->cmd_busy in pcie_poll_cmd() when it detects a Command Completed event (PCI_EXP_SLTSTA_CC). [bhelgaas: commit log] Fixes: a5dd4b4b0570 ("PCI: pciehp: Wait for hotplug command completion where necessary") Link: https://lore.kernel.org/r/20211111054258.7309-1-zhangliguang@linux.alibaba.com Link: https://bugzilla.kernel.org/show_bug.cgi?id=215143 Link: https://lore.kernel.org/r/20211126173309.GA12255@wunner.de Signed-off-by: Liguang Zhang Signed-off-by: Bjorn Helgaas Reviewed-by: Lukas Wunner Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/pciehp_hpc.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/pci/hotplug/pciehp_hpc.c +++ 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 = 0; + smp_mb(); return 1; } msleep(10);