Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3317650imu; Sun, 11 Nov 2018 12:14:25 -0800 (PST) X-Google-Smtp-Source: AJdET5dUY5ieR1EXk/Wg+ch5WaJQn0h6FOLpqtCG/e1imscU/Fz1M/T8K11glXOTN+gSxwBev6oX X-Received: by 2002:a62:1bd6:: with SMTP id b205-v6mr738978pfb.178.1541967265811; Sun, 11 Nov 2018 12:14:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967265; cv=none; d=google.com; s=arc-20160816; b=IkC8oVUQCwMz0MghOlf0pKodj246o93Oa/s5/ogngXU91k2T6SORiGG0TJSTWYykOM 9DCvMEtr7QTILqzUxgH5L2gqXMQvBA0O5gXHKlfhfnE2Jpz0LHFPU+OjHWE6zJSZxj3l vbdCV/2ZUuvlZr5Bxl2QvmgK7Z835rQm+YKgWMOo7SxK/yVYVFAE0SMdj+mOn1/Xgphi cYLbE9tqfkIO6WkPbXuaLU5iam87loI3SHiOOpEm5LydRyGSaIbdWsyVMncyiZKEe4U4 JsVqc/YdfNiH0wRYzlaiIrS57cnWt2tc2bLqyq5FT1XAwQ9LrFrErJFX8saqqeVNEOPc 7Qlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=G50whHGcWGhaOTJeDfYFMPwr5flRIE9KeFOFnimTK2g=; b=B6DNZE0gjFImce3m3wEG+btxPqQEoXo0DcCX4mXBbxAPrJ+o/6bzuqpfeuh+vt7lp0 s82SWhbqHkDdvNwFvZIz/MKgdJRrck+EBezVUdRQ+lZJNg0qKYZ84WMH6ShxroFxeLRn DgOaxlYTpQO+TrJXZiup8cgMyH1/t/Si170BhPRpp/8ClQMHiNq3sH/ftT8061w22HRy AF4ooyZfKqW9N/MVtLJZcdbMMbdG3cM0Mw7roxETXK0FCoOFOyUtl7re0Klt/hN2VUFc 8HWxaFcnpgW3Q8iDVOo0gsIo/FDa4GkKel2e19bpBf7Ji0aYd2z3V5+00nppe7X1IsBs NGkw== 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 t19-v6si15072119plr.334.2018.11.11.12.14.10; Sun, 11 Nov 2018 12:14:25 -0800 (PST) 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 S1730932AbeKLGDI (ORCPT + 99 others); Mon, 12 Nov 2018 01:03:08 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52726 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbeKLGDI (ORCPT ); Mon, 12 Nov 2018 01:03:08 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvt7-0000oP-M0; Sun, 11 Nov 2018 19:59:17 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsQ-0001SZ-4t; Sun, 11 Nov 2018 19:58:34 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Bjorn Helgaas" , "Andy Shevchenko" , "Mika Westerberg" , "Rafael J. Wysocki" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 081/366] PCI: pciehp: Clear Presence Detect and Data Link Layer Status Changed on resume In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 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 Signed-off-by: Ben Hutchings --- 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 @@ -143,7 +143,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 @@ -332,7 +332,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 @@ -580,7 +580,7 @@ static irqreturn_t pcie_isr(int irq, voi return IRQ_HANDLED; } -void pcie_enable_notification(struct controller *ctrl) +static void pcie_enable_notification(struct controller *ctrl) { u16 cmd, mask; @@ -618,6 +618,17 @@ void pcie_enable_notification(struct con pcie_write_cmd(ctrl, cmd, mask); } +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;