From patchwork Thu Jan 18 21:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 125041 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp294812lja; Thu, 18 Jan 2018 13:01:31 -0800 (PST) X-Google-Smtp-Source: ACJfBotDhiST//MwIVqQGjiAPSp/P8QpPUSVNEEiJnhLwjBFdO2km+Jv558vE88nTPhJd5ocbQPX X-Received: by 10.99.188.17 with SMTP id q17mr24345040pge.43.1516309291351; Thu, 18 Jan 2018 13:01:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516309291; cv=none; d=google.com; s=arc-20160816; b=fNL6GGhXszpmBzePkDsfVfQbx/SgVWN+WsdvjkDkKFb18+/NW/fVOeUkXszYANbSTu buIg1Ymd3MSzzrOHXwpixDbw2fhb5i17Ko1/5HJWDW4TxoS1bOQON+aAoRhA7sDgRERG hjeCXsRh4h9/uHXDnynUR9ZcLBRv8A/kBw1m7OKPTUvykGKIb5mdvNmkh6xeescqzSJ1 GXzHhafXTTwZr64LdjhuKs0fjH2zcFybIfi9gEhxFHFtAD+6A/FibsHZ/tN2x8TtCeTn TWxsR3HS4pFuGcqae+DbOp3Zez7ElY97yXC12ycV4rwDHFIr0Gr3lgIthcAfQQ1mPa62 fLmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=nia1OB6fAmqnomSm3nQ8k6yyIU27+IdgD6hA26/zixM=; b=RezB0vfPQLyOM8k5KTxFFpC3UATkY1Bxxey1Nt61giCikqHHyYKS9LBhKkP55o/VDH tj3aqM/2dPo1NUBbUD7QxOh/z+Bv1K4FgmU5LZs/yosUCmL37CvSyDIbe4KCvO3V4p8s zKrGc+clCrjE9d1k06ZIInE09EAtO3QQMW6BH4ZtCeYZqBhc7cLRHd5HrGUi+vZTkQ7j SThht7aQ7EP0zf8EEzJsLiHmHoEqufsFVpV1nGGuQZ5vOK55D9+FBrpblpYGpk1fiThd dUxR+yKFKjWt5CwFsA6iE8L6Sa/EXyXCPSmCBNeGFMh5JViiTpY5eZfTg11BE8+6xPn5 zH7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=U19wvU6j; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c16si4933770pgu.706.2018.01.18.13.01.31; Thu, 18 Jan 2018 13:01:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=U19wvU6j; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755026AbeARVB3 (ORCPT + 10 others); Thu, 18 Jan 2018 16:01:29 -0500 Received: from mail-by2nam01on0130.outbound.protection.outlook.com ([104.47.34.130]:56213 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754894AbeARVBX (ORCPT ); Thu, 18 Jan 2018 16:01:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nia1OB6fAmqnomSm3nQ8k6yyIU27+IdgD6hA26/zixM=; b=U19wvU6j5sLd1yblJygn1Uyo8XTHl08Fc4Z4HkbNyEIzWHXf/LDVZuPP/uDbePmViIkwpEKU39++BGl/OQ5+hMog2HFBtIAsAp42GJHbkaaKZRnckowU30T776urblAkSQr96dBJKW5fHA+ucfTCqUxZ7WrNO2KH33j35HC7KN4= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0805.namprd21.prod.outlook.com (10.167.105.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.428.7; Thu, 18 Jan 2018 21:01:16 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0428.008; Thu, 18 Jan 2018 21:01:16 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Sumit Semwal , Gabriel Krisman Bertazi , Greg Kroah-Hartman , Sasha Levin Subject: [added to the 4.1 stable tree] serial: 8250_pci: Detach low-level driver during PCI error recovery Thread-Topic: [added to the 4.1 stable tree] serial: 8250_pci: Detach low-level driver during PCI error recovery Thread-Index: AQHTkJ9REcaGGVL/VE6F1HgZANg3Gg== Date: Thu, 18 Jan 2018 21:00:06 +0000 Message-ID: <20180118205908.3220-82-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [167.220.98.9] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0805; 7:ORPm7ah1m4iYs2Fd2rtalHoOZREVGtsjNnzpnDS2a2wXa/VC0RTMPm2SfOzFwh4OVQRakzuNssZWtqOxZH1F9cFsVrbz132le5eW1NXb/6yubptfaso++G7g7ZMIp4xaqG+w34vQL+vqrDop68tggRtS/TMT19T7NEaFbhgNEIOewzA/xvo4jd6BfuqmzAWgOyDvWs3Yy/5HnezuZrnQcbfc4XfX1JJiE0E5cvdTVLUDk9tVVrxEu2tv97we0L1w x-ms-office365-filtering-correlation-id: 39c8afda-467d-4d48-2014-08d55eb69dbe x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020); SRVR:DM5PR2101MB0805; x-ms-traffictypediagnostic: DM5PR2101MB0805: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(104084551191319); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(61425038)(6040495)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231046)(2400067)(944501161)(3002001)(6055026)(61426038)(61427038)(6041282)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:DM5PR2101MB0805; BCL:0; PCL:0; RULEID:(100000803126)(100110400120); SRVR:DM5PR2101MB0805; x-forefront-prvs: 05568D1FF7 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(39380400002)(366004)(376002)(346002)(396003)(189003)(199004)(2906002)(2900100001)(6512007)(86362001)(305945005)(97736004)(68736007)(10090500001)(2501003)(6666003)(7736002)(105586002)(5250100002)(2950100002)(5660300001)(6116002)(36756003)(6486002)(26005)(86612001)(54906003)(4326008)(3280700002)(3846002)(6346003)(6436002)(3660700001)(10290500003)(478600001)(107886003)(76176011)(66066001)(1076002)(81156014)(99286004)(81166006)(106356001)(53936002)(102836004)(22452003)(110136005)(59450400001)(14454004)(316002)(72206003)(25786009)(6506007)(8676002)(8936002)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0805; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: wMkCA9Uqmr8s54cRhQlpK/F6pkK8b7v9omSU2XICQE9+IshloHQOreari+roRpdilcAMibIOlWLAokHmQ88SUw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39c8afda-467d-4d48-2014-08d55eb69dbe X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2018 21:00:06.5877 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0805 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sumit Semwal This patch has been added to the stable tree. If you have any objections, please let us know. -- 2.11.0 =============== [ Upstream commit f209fa03fc9d131b3108c2e4936181eabab87416 ] During a PCI error recovery, like the ones provoked by EEH in the ppc64 platform, all IO to the device must be blocked while the recovery is completed. Current 8250_pci implementation only suspends the port instead of detaching it, which doesn't prevent incoming accesses like TIOCMGET and TIOCMSET calls from reaching the device. Those end up racing with the EEH recovery, crashing it. Similar races were also observed when opening the device and when shutting it down during recovery. This patch implements a more robust IO blockage for the 8250_pci recovery by unregistering the port at the beginning of the procedure and re-adding it afterwards. Since the port is detached from the uart layer, we can be sure that no request will make through to the device during recovery. This is similar to the solution used by the JSM serial driver. I thank Peter Hurley for valuable input on this one over one year ago. Signed-off-by: Gabriel Krisman Bertazi Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_pci.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 83a145f61f1f..bfd5e2afaeaf 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -58,6 +58,7 @@ struct serial_private { unsigned int nr; void __iomem *remapped_bar[PCI_NUM_BAR_RESOURCES]; struct pci_serial_quirk *quirk; + const struct pciserial_board *board; int line[0]; }; @@ -4155,6 +4156,7 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board) } } priv->nr = i; + priv->board = board; return priv; err_deinit: @@ -4165,7 +4167,7 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board) } EXPORT_SYMBOL_GPL(pciserial_init_ports); -void pciserial_remove_ports(struct serial_private *priv) +void pciserial_detach_ports(struct serial_private *priv) { struct pci_serial_quirk *quirk; int i; @@ -4185,7 +4187,11 @@ void pciserial_remove_ports(struct serial_private *priv) quirk = find_quirk(priv->dev); if (quirk->exit) quirk->exit(priv->dev); +} +void pciserial_remove_ports(struct serial_private *priv) +{ + pciserial_detach_ports(priv); kfree(priv); } EXPORT_SYMBOL_GPL(pciserial_remove_ports); @@ -5936,7 +5942,7 @@ static pci_ers_result_t serial8250_io_error_detected(struct pci_dev *dev, return PCI_ERS_RESULT_DISCONNECT; if (priv) - pciserial_suspend_ports(priv); + pciserial_detach_ports(priv); pci_disable_device(dev); @@ -5961,9 +5967,18 @@ static pci_ers_result_t serial8250_io_slot_reset(struct pci_dev *dev) static void serial8250_io_resume(struct pci_dev *dev) { struct serial_private *priv = pci_get_drvdata(dev); + const struct pciserial_board *board; - if (priv) - pciserial_resume_ports(priv); + if (!priv) + return; + + board = priv->board; + kfree(priv); + priv = pciserial_init_ports(dev, board); + + if (!IS_ERR(priv)) { + pci_set_drvdata(dev, priv); + } } static const struct pci_error_handlers serial8250_err_handler = {