Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CC43C10F12 for ; Mon, 15 Apr 2019 19:08:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69B5F2087C for ; Mon, 15 Apr 2019 19:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355318; bh=zgKO8f0vcTqT5wsVvqDgxtIkRZEZy4VoRLP///CsgQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1Flg360VQ2A8d7ZB1VqsvlsDonr6RRr74PLQ24mnVHlOJVyk/Zq0BTB3In6QioqYe hG0hjfCgRWoRothNP/Xgyg1/YwKcwwyHKbFBX7844hWHnVPNesdqpZBYGcG4x7MxCW J8RK6FgY6cdw21RpQ/d9Nrp8QY0VZ8C5NlMhzXys= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730508AbfDOTIg (ORCPT ); Mon, 15 Apr 2019 15:08:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:44090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730500AbfDOTIf (ORCPT ); Mon, 15 Apr 2019 15:08:35 -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 AFE6920880; Mon, 15 Apr 2019 19:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355315; bh=zgKO8f0vcTqT5wsVvqDgxtIkRZEZy4VoRLP///CsgQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FRS/6op0XwwThhBTw8LLx2KFk0DausgSaxQSZIEP5AEl4PB6aktHeFhWFMUxjVBBn p3TEEgPEXZLLVJ2aCCEJhP+oNap5fjCAqqJ7qkUC0+/5hiH+ebRxJ9ByU0Oy1ZW0VA dGBuIuP6a8CN7aPYfMC6VAXnaQpv3x+zOy/NoQQk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Micah Parrish , Sergey Miroshnichenko , Bjorn Helgaas , Lukas Wunner Subject: [PATCH 4.19 092/101] PCI: pciehp: Ignore Link State Changes after powering off a slot Date: Mon, 15 Apr 2019 20:59:30 +0200 Message-Id: <20190415183745.238600302@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sergey Miroshnichenko commit 3943af9d01e94330d0cfac6fccdbc829aad50c92 upstream. During a safe hot remove, the OS powers off the slot, which may cause a Data Link Layer State Changed event. The slot has already been set to OFF_STATE, so that event results in re-enabling the device, making it impossible to safely remove it. Clear out the Presence Detect Changed and Data Link Layer State Changed events when the disabled slot has settled down. It is still possible to re-enable the device if it remains in the slot after pressing the Attention Button by pressing it again. Fixes the problem that Micah reported below: an NVMe drive power button may not actually turn off the drive. Link: https://bugzilla.kernel.org/show_bug.cgi?id=203237 Reported-by: Micah Parrish Tested-by: Micah Parrish Signed-off-by: Sergey Miroshnichenko [bhelgaas: changelog, add bugzilla URL] 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_ctrl.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -117,6 +117,10 @@ static void remove_board(struct slot *p_ * removed from the slot/adapter. */ msleep(1000); + + /* Ignore link or presence changes caused by power off */ + atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC), + &ctrl->pending_events); } /* turn off Green LED */