Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2825577pxb; Mon, 18 Apr 2022 09:02:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsUv1As5rtdeU2liQ7DPynKytBcy5eS8zhWOZc+H003Vb+0tSE43PvJm/rRKQRS/2DA1bn X-Received: by 2002:a05:6830:23b3:b0:604:23a7:1a26 with SMTP id m19-20020a05683023b300b0060423a71a26mr4221103ots.14.1650297738268; Mon, 18 Apr 2022 09:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650297738; cv=none; d=google.com; s=arc-20160816; b=y4hXku+u9IfJINplDnR0TrSmvb2ilpX1tQgN3XzkGDWueqSTZNn93wo82rq6j9i40I 9bAjmlH2lxUKy5ZfCqNtGU+/BDAfVBeU5PvLB/NMzedKeNYAHa3/EtHq56GOwB5pLat1 SDc3rbtDHpcH5AhUgMZyqezTYFpTOmzRDEjjKxiCt1ZCzqgTWX98giuF5sgHMzFkhOLl YpFosdPsufwtaE2+7DqTIQyEIIDKIrkbZieWYphKdoeJ9OQpZgb3JpFKKjlzG5zn00/u ajmkfcPNs8iFSesgJmvcYRZOHECE92+EUsTBCi6PPwE/V0K+OotL5qTZvuFNxGb4b7Th eiaA== 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=B5FkooDmPF3UJgDPKBxmkPsiWqmeT92LJBXKjbu5zfs=; b=RsYjTapCpY4omNiBNs9IcLwRijmB9+w80985V3xHq62vIAXj2/DbT6eMx/KVS59wlj 5poJFTi+PatDoFHsjm8RLbNBexGrfaIdnhosrxT1QmPaGv2+4HqM0XxbCqFCJ0DAM+Ue lYH/pi6+EsSULGO+qR/jtL3lr+1B2yEtUVL1uh49W9tnlEzQBiyeawKEsSNgYGiGckdT 8oL8tqkTDHbgbtdzQHU+L5WKKvsckLwyJbYY1PcBxQkhOG1UZlysoSQtnFn0GzrKZIhf xvKfTd70dJqnuXxf0vAX+prSobGJe2T75m0+MLhihqKO+j5ygzUwhvDicBEmOPuwThUV GUPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TxsF93e5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w125-20020aca6283000000b002f768c4f40bsi4032322oib.286.2022.04.18.09.02.01; Mon, 18 Apr 2022 09:02:18 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TxsF93e5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243911AbiDRNie (ORCPT + 99 others); Mon, 18 Apr 2022 09:38:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243438AbiDRNKI (ORCPT ); Mon, 18 Apr 2022 09:10:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FCF237BFF; Mon, 18 Apr 2022 05:49:39 -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 ams.source.kernel.org (Postfix) with ESMTPS id 253DAB80D9C; Mon, 18 Apr 2022 12:49:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7095EC385A9; Mon, 18 Apr 2022 12:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286172; bh=sBAlfitv7a3m15anPihIPdD3jKEWTRAgL6gHf+iR2EQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxsF93e5RLHypZZ8AOZHMboIjrlL6pn7VVTBXjPMxHiFejCFAzCVkuIXG0AJqiy0f uI4ZlV3nnwj3LFhXxTveACDMBDlTH2rvkTlVCzUeM5akPZjg6HUrairzRJSQsMdTS8 lyvIp1ebZUrXzTeme3bFHkINDcnPOQ8T4VMs9zpw= 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 4.14 052/284] PCI: pciehp: Clear cmd_busy bit in polling mode Date: Mon, 18 Apr 2022 14:10:33 +0200 Message-Id: <20220418121212.175619271@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -120,6 +120,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; } if (timeout < 0)