Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2986502imm; Sun, 1 Jul 2018 09:45:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe+QwFGeDZQGxNbZ5skGMiYoA9khWRIHIzul+S1+8u14qY7WU6VdnxE7l0Ya1GPi6yQBmiM X-Received: by 2002:a63:2e81:: with SMTP id u123-v6mr15556363pgu.225.1530463509773; Sun, 01 Jul 2018 09:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530463509; cv=none; d=google.com; s=arc-20160816; b=fhz4hX6dhNIkA/u6J3GnYiyWK0PaIPUlPnlx52slx0WjCDE1q8HpKXV0iTKi7dfeFB pA6/0N/iTkacfuoOl9Ju71wD2wprTAzXp7WrJLar0Fu6YnG9zhYNYfU/yRFnX6HVnFIM Z5B/9NYTfSvEpJjzcwSLdDy9TOzZtA/mt2mRLgOJlL0nYqUKDq6aHCCS1jiZ+b5qZYPJ hX7kXI5rpqvtqKN+EgwMc09GsJ+79wvMBoJsyeytYespPC3oPFhCDXMp7yIwoITuSTjv Atzhj9vv4T7yJnZos4TuZVwgln5XCiwPnHuZMSUeu1EzAnmClJX8TuPKUpuR8CJxiNQ9 WP5g== 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=ZcW/kpUov+xzwwmLVns8qsn+PLELfXypw8o1wLZWvHU=; b=upCQHfeI5PnJ1LZ9OUDmmOBcKchyK2o/0NDss/8Ds/kdyCTjVxmDbJmvZa6ztMQkOO bvEjdmeaLl9tzNF+BgE9rIEQPmYYW5DCqvgDFN4aCpuZiBTr5vOZaEiGLB5u/dWvCyp2 2OXn2i3biS6iMsNG2+BCQn16wQ6xVzEwvvzR/B3GFpRICo2U8gV0nQGvwv21mstawI65 H4Wfdv3ons5B3tzhpDBQubLqLn3snSrcSh/9VhY+Zv0/WSWaPJOcePIaBvrT6oS7CNO2 LY9+3UGQkFbxy81FIZ4YGfvyhVeR+Q3ixaDJmT7mL4Q8PqtDN8+z4YOy+yOjjSsoAlJf hvtw== 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 e98-v6si14303348plb.150.2018.07.01.09.44.55; Sun, 01 Jul 2018 09:45:09 -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 S1032368AbeGAQnb (ORCPT + 99 others); Sun, 1 Jul 2018 12:43:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37832 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031970AbeGAQn0 (ORCPT ); Sun, 1 Jul 2018 12:43:26 -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 36B20A73; Sun, 1 Jul 2018 16:43:26 +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.17 115/220] PCI: pciehp: Clear Presence Detect and Data Link Layer Status Changed on resume Date: Sun, 1 Jul 2018 18:22:19 +0200 Message-Id: <20180701160913.169471742@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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.17-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 @@ -121,7 +121,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 @@ -283,7 +283,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 @@ -659,7 +659,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; @@ -697,6 +697,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;