Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3060761imm; Sun, 1 Jul 2018 11:19:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ6V0u3VKwng7y2iPRQayQ2/qMUywbpcMU8uLpq1LMJKvahrjRQDJoPtWfPo4SsESpbfIju X-Received: by 2002:a17:902:294a:: with SMTP id g68-v6mr23424476plb.58.1530469146387; Sun, 01 Jul 2018 11:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530469146; cv=none; d=google.com; s=arc-20160816; b=G/Ax2+CKY/Mm+rxh0O5ehPGZORXVbdFQ20K3ZHIfATraAUzqJ+AnbNalzvXrhyvmV1 04C7f2gh2Z7epKDsSZePy0ryUrgbRfXTKi98m3uSRgJF1P62RAoOOvjgqWKANISC6fsG V+qIB6QDG/A+VTyxx3BA34AbmVj6r2/PfoeTcOCkB7Io7LOY/azgwP2+5K2q/VfGYBI0 1wCZntZsOCHWPSpG+ASCXKFENli0XTWDL/z5uCUek5Enyva6a3qNh3zOhcUt/QjmOhzS dTBLJ+RsnlHOP6A66NaryANw32YiRkSTvVLNJkSBdxrbjg0tlrAmgfqpWUGnqHfQrRHO 4cIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VxRbeos75v4cQof7fJpus9g48eUZL9zAA7Tz6XKb7J4=; b=DcCwkIjA0+Rhxsbv1itKx2zXwi6gAOi8l7nXNmEeifr60Il4e97G1Qj2keELxPgpDM 2NASef/xrOXuh48jwsu8DN/pR87c1qQUGliS1yUvg8ue/Kwt+AQxJghJUb3EYkb1gqeh j/PqvHYx5XvcOsMGrxCd1zjcSBd8KGcJ8t8WY2FuEmcyn5V/+B+Dgj3ThKIhtQurGOjn JQFTQGbDd2HbxOYEg5UNXpA40Kb2fD05EgSTCJLWPSOnmXht0EO0lA5kdOzphYEpD0w2 IXcSgB91NMgaKrpQp/CIL7YseQZXyUq0xkC7Pz1IdxWq2rMhSMnG29tdEt+X/caOPYjQ SdNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5-v6si9090444pfo.54.2018.07.01.11.18.52; Sun, 01 Jul 2018 11:19:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965326AbeGAQ00 (ORCPT + 99 others); Sun, 1 Jul 2018 12:26:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33842 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965293AbeGAQ0S (ORCPT ); Sun, 1 Jul 2018 12:26:18 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A991FACD; Sun, 1 Jul 2018 16:26:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , Bjorn Helgaas , "Rafael J. Wysocki" , Andy Shevchenko Subject: [PATCH 4.9 048/101] PCI: pciehp: Clear Presence Detect and Data Link Layer Status Changed on resume Date: Sun, 1 Jul 2018 18:21:34 +0200 Message-Id: <20180701160759.070258006@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mika Westerberg commit 13c65840feab8109194f9490c9870587173cb29d upstream. After a suspend/resume cycle the Presence Detect or Data Link Layer Status Changed bits might be set. If we don't clear them those events will not fire anymore and nothing happens for instance when a device is now hot-unplugged. Fix this by clearing those bits in a newly introduced function pcie_reenable_notification(). This should be fine because immediately after, we check if the adapter is still present by reading directly from the status register. Signed-off-by: Mika Westerberg Signed-off-by: Bjorn Helgaas Reviewed-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/pciehp.h | 2 +- drivers/pci/hotplug/pciehp_core.c | 2 +- drivers/pci/hotplug/pciehp_hpc.c | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -134,7 +134,7 @@ struct controller *pcie_init(struct pcie int pcie_init_notification(struct controller *ctrl); int pciehp_enable_slot(struct slot *p_slot); int pciehp_disable_slot(struct slot *p_slot); -void pcie_enable_notification(struct controller *ctrl); +void pcie_reenable_notification(struct controller *ctrl); int pciehp_power_on_slot(struct slot *slot); void pciehp_power_off_slot(struct slot *slot); void pciehp_get_power_status(struct slot *slot, u8 *status); --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -297,7 +297,7 @@ static int pciehp_resume(struct pcie_dev ctrl = get_service_data(dev); /* reinitialize the chipset's event detection logic */ - pcie_enable_notification(ctrl); + pcie_reenable_notification(ctrl); slot = ctrl->slot; --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -673,7 +673,7 @@ static irqreturn_t pcie_isr(int irq, voi return handled; } -void pcie_enable_notification(struct controller *ctrl) +static void pcie_enable_notification(struct controller *ctrl) { u16 cmd, mask; @@ -711,6 +711,17 @@ void pcie_enable_notification(struct con pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd); } +void pcie_reenable_notification(struct controller *ctrl) +{ + /* + * Clear both Presence and Data Link Layer Changed to make sure + * those events still fire after we have re-enabled them. + */ + pcie_capability_write_word(ctrl->pcie->port, PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC); + pcie_enable_notification(ctrl); +} + static void pcie_disable_notification(struct controller *ctrl) { u16 mask;