Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3010229imm; Sun, 1 Jul 2018 10:14:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKII7wQFiYhkAGxa5SpyY8BV2KFQyCNjv9O1M4W+FZk3qiIB31YEF160xJCwUpImvfVvEvD5 X-Received: by 2002:a65:4442:: with SMTP id e2-v6mr19165806pgq.53.1530465244200; Sun, 01 Jul 2018 10:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530465244; cv=none; d=google.com; s=arc-20160816; b=zBTIkrPGhXRJKGYpvoxFmlq3eaMhx4V8r5AJCZNchPg0HqjvRWKwS6DmTgqOTat7mx h/y/sWVt4VwQqEHxW0hC8I023TIwYHNueZq4bjSeYLoDmtsT3WvKoK8baaIEERjyf2r4 PpIoKLJISs5QhbmE3vsPHsiw/6jbcILXe7Ght9T/mCbc3IxcVQbMDs3stD6R+4GMqti3 13pIy5+dhfe38ctp22H6rPhQLxfQlus4KVAHHKnVovPj18TC7ObsOaBs9J3ud5E+Q0RA 0DIRhRTnAA/lfGXuIHpGJjOB1yDXglJgqI1hX9gXouTuoe5oLuYPykBiUPN5luwHnE0S qbeg== 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=jNfOHiX0DOCDjI7k7n1icFJR/bR/uo7hSEr8GC82G+I=; b=dHTbFoS2ZL0P3xwr6llAgLxOHE4bU8WNcQkBAA9B2LoMR2K9cmQlL306FC2B9ywO0K ATJvd6klGnh+5SD5WvW7KLQNMeOJblSzJUMthsa9EzJql5NkAFH9wXRZ2ES+VGNIfTAD NSw1HsRb/zvLyN/fIeg4odXOnSxk7xD6J1Za6fbYtioBiboyQi0nRdmhh4m5IQbbE9rG dSm1TpjkmXN549a5958qf8gl9Pl8Mk9i4PuXp10JRh/4SkuMUV5ifHfdz/POvrGPN9bJ 3XBb7sgZL31jieUzSxSqryqCdgVtPHSNNg4C2pHTUEMT8hHgbcf3muQyU87J/zotln7L 0QqA== 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 b66-v6si14089108pfe.265.2018.07.01.10.13.49; Sun, 01 Jul 2018 10:14:04 -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 S1753722AbeGARNM (ORCPT + 99 others); Sun, 1 Jul 2018 13:13:12 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37174 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031895AbeGAQkY (ORCPT ); Sun, 1 Jul 2018 12:40:24 -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 22F2CAA6; Sun, 1 Jul 2018 16:40:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Marciniszyn , Alex Estrin , Dennis Dalessandro , Doug Ledford Subject: [PATCH 4.17 085/220] IB/{hfi1, qib}: Add handling of kernel restart Date: Sun, 1 Jul 2018 18:21:49 +0200 Message-Id: <20180701160911.981173482@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: Alex Estrin commit 8d3e71136a080d007620472f50c7b3e63ba0f5cf upstream. A warm restart will fail to unload the driver, leaving link state potentially flapping up to the point the BIOS resets the adapter. Correct the issue by hooking the shutdown pci method, which will bring port down. Cc: # 4.9.x Reviewed-by: Mike Marciniszyn Signed-off-by: Alex Estrin Signed-off-by: Dennis Dalessandro Signed-off-by: Doug Ledford Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/hfi1/hfi.h | 1 + drivers/infiniband/hw/hfi1/init.c | 13 +++++++++++++ drivers/infiniband/hw/qib/qib.h | 1 + drivers/infiniband/hw/qib/qib_init.c | 13 +++++++++++++ 4 files changed, 28 insertions(+) --- a/drivers/infiniband/hw/hfi1/hfi.h +++ b/drivers/infiniband/hw/hfi1/hfi.h @@ -1856,6 +1856,7 @@ struct cc_state *get_cc_state_protected( #define HFI1_HAS_SDMA_TIMEOUT 0x8 #define HFI1_HAS_SEND_DMA 0x10 /* Supports Send DMA */ #define HFI1_FORCED_FREEZE 0x80 /* driver forced freeze mode */ +#define HFI1_SHUTDOWN 0x100 /* device is shutting down */ /* IB dword length mask in PBC (lower 11 bits); same for all chips */ #define HFI1_PBC_LENGTH_MASK ((1 << 11) - 1) --- a/drivers/infiniband/hw/hfi1/init.c +++ b/drivers/infiniband/hw/hfi1/init.c @@ -1058,6 +1058,10 @@ static void shutdown_device(struct hfi1_ unsigned pidx; int i; + if (dd->flags & HFI1_SHUTDOWN) + return; + dd->flags |= HFI1_SHUTDOWN; + for (pidx = 0; pidx < dd->num_pports; ++pidx) { ppd = dd->pport + pidx; @@ -1391,6 +1395,7 @@ void hfi1_disable_after_error(struct hfi static void remove_one(struct pci_dev *); static int init_one(struct pci_dev *, const struct pci_device_id *); +static void shutdown_one(struct pci_dev *); #define DRIVER_LOAD_MSG "Intel " DRIVER_NAME " loaded: " #define PFX DRIVER_NAME ": " @@ -1407,6 +1412,7 @@ static struct pci_driver hfi1_pci_driver .name = DRIVER_NAME, .probe = init_one, .remove = remove_one, + .shutdown = shutdown_one, .id_table = hfi1_pci_tbl, .err_handler = &hfi1_pci_err_handler, }; @@ -1816,6 +1822,13 @@ static void remove_one(struct pci_dev *p postinit_cleanup(dd); } +static void shutdown_one(struct pci_dev *pdev) +{ + struct hfi1_devdata *dd = pci_get_drvdata(pdev); + + shutdown_device(dd); +} + /** * hfi1_create_rcvhdrq - create a receive header queue * @dd: the hfi1_ib device --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -1228,6 +1228,7 @@ static inline struct qib_ibport *to_ipor #define QIB_BADINTR 0x8000 /* severe interrupt problems */ #define QIB_DCA_ENABLED 0x10000 /* Direct Cache Access enabled */ #define QIB_HAS_QSFP 0x20000 /* device (card instance) has QSFP */ +#define QIB_SHUTDOWN 0x40000 /* device is shutting down */ /* * values for ppd->lflags (_ib_port_ related flags) --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c @@ -841,6 +841,10 @@ static void qib_shutdown_device(struct q struct qib_pportdata *ppd; unsigned pidx; + if (dd->flags & QIB_SHUTDOWN) + return; + dd->flags |= QIB_SHUTDOWN; + for (pidx = 0; pidx < dd->num_pports; ++pidx) { ppd = dd->pport + pidx; @@ -1182,6 +1186,7 @@ void qib_disable_after_error(struct qib_ static void qib_remove_one(struct pci_dev *); static int qib_init_one(struct pci_dev *, const struct pci_device_id *); +static void qib_shutdown_one(struct pci_dev *); #define DRIVER_LOAD_MSG "Intel " QIB_DRV_NAME " loaded: " #define PFX QIB_DRV_NAME ": " @@ -1199,6 +1204,7 @@ static struct pci_driver qib_driver = { .name = QIB_DRV_NAME, .probe = qib_init_one, .remove = qib_remove_one, + .shutdown = qib_shutdown_one, .id_table = qib_pci_tbl, .err_handler = &qib_pci_err_handler, }; @@ -1549,6 +1555,13 @@ static void qib_remove_one(struct pci_de qib_postinit_cleanup(dd); } +static void qib_shutdown_one(struct pci_dev *pdev) +{ + struct qib_devdata *dd = pci_get_drvdata(pdev); + + qib_shutdown_device(dd); +} + /** * qib_create_rcvhdrq - create a receive header queue * @dd: the qlogic_ib device