From patchwork Fri Mar 1 16:12:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Miroshnichenko X-Patchwork-Id: 10835637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D93C4922 for ; Fri, 1 Mar 2019 16:13:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C78522FE65 for ; Fri, 1 Mar 2019 16:13:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAC5D2FEBB; Fri, 1 Mar 2019 16:13:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A77EC2FE65 for ; Fri, 1 Mar 2019 16:13:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388879AbfCAQND (ORCPT ); Fri, 1 Mar 2019 11:13:03 -0500 Received: from mta-01.yadro.com ([89.207.88.251]:35650 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387940AbfCAQND (ORCPT ); Fri, 1 Mar 2019 11:13:03 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 922DA4198A; Fri, 1 Mar 2019 16:13:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :x-mailer:message-id:date:date:subject:subject:from:from :received:received:received; s=mta-01; t=1551456780; x= 1553271181; bh=Ew+NvM5YpqeWK6n2hIIQvzHcHCPz9CIq8PNP0lNS7gQ=; b=f t3xK4ppF1pQICG6DYuviweYHJXDTHmmcvAXNwak7sRkQLxxwJBZpii+vH98aOH8k lIC7irrXkPnhXBMpoAMekJ2XQV4wajlHeV9HdXER1MGRH0wK2podvvbvQYX+RVVO N92woM1VyXKGARYUraiwliRczOQU2raY/KMqNNR22U= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aSHsHRMzshPL; Fri, 1 Mar 2019 19:13:00 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 686A94196B; Fri, 1 Mar 2019 19:13:00 +0300 (MSK) Received: from NB-148.yadro.com (172.17.15.60) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 1 Mar 2019 19:13:00 +0300 From: Sergey Miroshnichenko To: CC: , Sergey Miroshnichenko , Lukas Wunner Subject: [PATCH] PCI: pciehp: Fix re-enabling the slot marked for safe removal Date: Fri, 1 Mar 2019 19:12:51 +0300 Message-ID: <20190301161251.26774-1-s.miroshnichenko@yadro.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Originating-IP: [172.17.15.60] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During the safe removal procedure, a Data Link Layer State Changed event may occur after pciehp_power_off_slot(), and it is handled when the slot is already set to OFF_STATE. This results in re-enabling the device and makes it impossible to actually safely remove it. Add a check for a Presence Detect Changed bit to filter out this interrupt. It is still possible to re-enable the device if it remains in the slot after pressing the Attention Button by pressing it again. Signed-off-by: Sergey Miroshnichenko Cc: Lukas Wunner --- drivers/pci/hotplug/pciehp_ctrl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 3f3df4c29f6e..941f77b71df4 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -251,6 +251,14 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) return; } + /* Handle the DLLSC from the slot which just has been turned off */ + if ((events & PCI_EXP_SLTSTA_DLLSC) && + !(events & PCI_EXP_SLTSTA_PDC) && + present && !link_active) { + mutex_unlock(&ctrl->state_lock); + return; + } + switch (ctrl->state) { case BLINKINGON_STATE: cancel_delayed_work(&ctrl->button_work);