Received: by 10.213.65.68 with SMTP id h4csp2112194imn; Sun, 8 Apr 2018 20:01:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx48a7CRmmoL7rdRaZp2ZVR/MtcttWW6i2Pfvm4YfVPJ5yhR9t3BfnHqRz5ExfoFuAT3HxuV+ X-Received: by 2002:a17:902:820a:: with SMTP id x10-v6mr27520741pln.306.1523242909279; Sun, 08 Apr 2018 20:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523242909; cv=none; d=google.com; s=arc-20160816; b=ALaezMrjQ30FYg78Sf4xwIZZQfe5CrExntdHVB1HaZyB2+cmS2eVopeh6ba5sb/nCN r294diUYCyl8/L/ENzIm3iyPq4ewguoyVVeFQYWQvOFyVK5vb2vsYkQjYhGweMDKJBlW GcuLF5u0jqHmddyla+hLA+xYENPF+P1TaF2puLgevAxixStYpPbuUotztZrMeoaEiv9P 4n2vJHmOj3av8N48sVeno5GnbMZ7xIW+bWRHfGHC78YCcVediIWzHdax4e7KxhLfqzYC 8m7euqrNs86H04szc6CLbngRK/2mo37CB+MiW876E3zKrGqS9qiQlao7c4FaWaykVzf/ /atw== 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=2aD7wUHULV7a08Pf56MqZe6WT/2KnqrszBHdFS+cE2I=; b=OG15to1UC3KH6RQZp38KDDSbTAxgdXTBLqP9j6eGM/17aNdZfcQ35DmMkce4Q1nvoj hXJhoWX133loyDBxiKi/bIyHE9OFE+HeoS2Su/iH2aA+iKtNQc341AMK9GUMRvV8+jve d1C8QE6rfadRbnifQYinJTAbgGiVfku3QvsgsT4G7Pv7c9E3s7/AWOKA+xYOUDNezaRO kCykB2aGng1h+276JrGOuflZizMAObqCEo7rS+t/d+rIKuVZG0Z2T7CyRU3hwYQ6sSjz GXgGYcNL4l9EGSWj2IkJubmnsQ+yOAhu851v1poN0VgdwTMQSd7JIwS/v/QAVQFNkRXA 2glg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=i2CCP/8P; 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; 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 b9-v6si1915896plx.699.2018.04.08.20.01.12; Sun, 08 Apr 2018 20:01:49 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=i2CCP/8P; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755013AbeDIAYD (ORCPT + 99 others); Sun, 8 Apr 2018 20:24:03 -0400 Received: from mail-by2nam03on0115.outbound.protection.outlook.com ([104.47.42.115]:29467 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754974AbeDIAX4 (ORCPT ); Sun, 8 Apr 2018 20:23:56 -0400 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=2aD7wUHULV7a08Pf56MqZe6WT/2KnqrszBHdFS+cE2I=; b=i2CCP/8PYupTacsDxq8hHYaCJAyEOhhk+0u+zkvHEhXzt6TiQbCc4OrqC7Y6WtFZLC5URSCSxc2GPWDQw4YGzdYLD8q9K2KZj4LBLw082BL0ppjlwXbOF+W1TzlPfWUab2hasALnlknGIP2NsRF85pkjoyAacbe9mqdbqHD21Qk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1080.namprd21.prod.outlook.com (52.132.130.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:23:52 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:23:52 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Aaron Sierra , Matt Schulte , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 076/161] tty: serial: exar: Relocate sleep wake-up handling Thread-Topic: [PATCH AUTOSEL for 4.14 076/161] tty: serial: exar: Relocate sleep wake-up handling Thread-Index: AQHTz5iceyNTfI2vjEG8mGhco3ZeKg== Date: Mon, 9 Apr 2018 00:20:48 +0000 Message-ID: <20180409001936.162706-76-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1080;7:OnMIdna4DesfoI+F6KB02pZ96IG/JvuPC8Ix+KfF1YCe68EV4Vnj+cMEZrYLe8fzaNTc/ea4yiPzDBuy3OKM2WbZP06jUzhSCNwIdV797RjtgDhNo+kRHg8AVTjUljls04rOAXoCiEK1Th811oE8Deo3UImyR72LtbCGsdu65nuT3QM3+XJLPpGRQvnFxkkAik9OKh6doj+WOgrdMfKE/7F94tCEMJuB2GMKylULLZhvAdaQdDUOR3bcyy6cMnGQ;20:jTJa6HplACIlu8p75bRblPSLRkouEzPl3pesWTHr5KhYwsCs3g7UWrGJMwUOXA1UXZztXJDUDyz7KnYmfZIt4HN8NOC+drDyYio73sLHbaCVishQ+h+P6LqQzPSQe7t9Jue0EiemjPyRuzeTaDf/N82MpUFKWsxNH0jkTJ5A/XM= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: a14abb37-dfcb-4367-03c2-08d59db02c24 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1080; x-ms-traffictypediagnostic: DM5PR2101MB1080: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231221)(944501327)(52105095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB1080;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1080; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(396003)(39380400002)(366004)(39860400002)(199004)(189003)(2501003)(5250100002)(8936002)(10090500001)(5660300001)(3660700001)(446003)(107886003)(14454004)(36756003)(6436002)(476003)(3280700002)(2616005)(11346002)(4326008)(6666003)(53936002)(6512007)(22452003)(305945005)(10290500003)(316002)(102836004)(2906002)(6116002)(66066001)(6506007)(3846002)(7736002)(486006)(54906003)(110136005)(186003)(72206003)(26005)(1076002)(105586002)(2900100001)(6486002)(97736004)(478600001)(81156014)(81166006)(86612001)(8676002)(106356001)(99286004)(86362001)(575784001)(76176011)(59450400001)(68736007)(25786009)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1080;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 2IjCWBMBiuhFTq0y5ORt41VORx+TYTWlYQJaYuVzKXWAVGRtq6QYf0j80qUSY8TB3VLVSEbUrVZtL++POy9oqEAVLYJ5sqYk4ANtGB/gfhCNMSnPUqclE5PHPJVFDVeiWHH/cxT/LGR/DF4PvzvUudQ/Albtua46CbwVCH3eIL2l/mIeqRJaEZM4ehXOTSG0bNvcatbXpEpmWcGuyNpUJ50beUwfWDtnBgvWEILvuPXJ/lJlelzGVhged0eofJEKzrhLkPpNOR3hvGO8miLQ5+DTgEmWz95JfYy0kG+RYCI+TRWOlPJkshVtYm5MFgMAtVEwWyo3QNzs6RgEMQSgMUksNQhU3LHLbgzhR0npTHklvwbSUylmDpKgIJazLbtql3KkSxlzBPKnSHyykN9JE6hmP0ll4HM0uaULb+V4hjo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: a14abb37-dfcb-4367-03c2-08d59db02c24 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:48.6753 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1080 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aaron Sierra [ Upstream commit c7e1b4059075c9e8eed101d7cc5da43e95eb5e18 ] Exar sleep wake-up handling has been done on a per-channel basis by virtue of INT0 being accessible from each channel's address space. I believe this was initially done out of necessity, but now that Exar devices have their own driver, we can do things more efficiently by registering a dedicated INT0 handler at the PCI device level. I see this change providing the following benefits: 1. If more than one port is active, eliminates the redundant bus cycles for reading INT0 on every interrupt. 2. This note associated with hooking in the per-channel handler in 8250_port.c is resolved: /* Fixme: probably not the best place for this */ Cc: Matt Schulte Signed-off-by: Aaron Sierra Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_exar.c | 34 ++++++++++++++++++++++++++++++---= - drivers/tty/serial/8250/8250_port.c | 26 -------------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/= 8250_exar.c index c55624703fdf..e0aa5f03004c 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -37,6 +37,7 @@ #define PCI_DEVICE_ID_EXAR_XR17V4358 0x4358 #define PCI_DEVICE_ID_EXAR_XR17V8358 0x8358 =20 +#define UART_EXAR_INT0 0x80 #define UART_EXAR_8XMODE 0x88 /* 8X sampling rate select */ =20 #define UART_EXAR_FCTR 0x08 /* Feature Control Register */ @@ -124,6 +125,7 @@ struct exar8250_board { struct exar8250 { unsigned int nr; struct exar8250_board *board; + void __iomem *virt; int line[0]; }; =20 @@ -134,12 +136,9 @@ static int default_setup(struct exar8250 *priv, struct= pci_dev *pcidev, const struct exar8250_board *board =3D priv->board; unsigned int bar =3D 0; =20 - if (!pcim_iomap_table(pcidev)[bar] && !pcim_iomap(pcidev, bar, 0)) - return -ENOMEM; - port->port.iotype =3D UPIO_MEM; port->port.mapbase =3D pci_resource_start(pcidev, bar) + offset; - port->port.membase =3D pcim_iomap_table(pcidev)[bar] + offset; + port->port.membase =3D priv->virt + offset; port->port.regshift =3D board->reg_shift; =20 return 0; @@ -423,6 +422,25 @@ static void pci_xr17v35x_exit(struct pci_dev *pcidev) port->port.private_data =3D NULL; } =20 +/* + * These Exar UARTs have an extra interrupt indicator that could fire for = a + * few interrupts that are not presented/cleared through IIR. One of whic= h is + * a wakeup interrupt when coming out of sleep. These interrupts are only + * cleared by reading global INT0 or INT1 registers as interrupts are + * associated with channel 0. The INT[3:0] registers _are_ accessible from= each + * channel's address space, but for the sake of bus efficiency we register= a + * dedicated handler at the PCI device level to handle them. + */ +static irqreturn_t exar_misc_handler(int irq, void *data) +{ + struct exar8250 *priv =3D data; + + /* Clear all PCI interrupts by reading INT0. No effect on IIR */ + ioread8(priv->virt + UART_EXAR_INT0); + + return IRQ_HANDLED; +} + static int exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) { @@ -451,6 +469,9 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci= _device_id *ent) return -ENOMEM; =20 priv->board =3D board; + priv->virt =3D pcim_iomap(pcidev, bar, 0); + if (!priv->virt) + return -ENOMEM; =20 pci_set_master(pcidev); =20 @@ -464,6 +485,11 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pc= i_device_id *ent) uart.port.irq =3D pci_irq_vector(pcidev, 0); uart.port.dev =3D &pcidev->dev; =20 + rc =3D devm_request_irq(&pcidev->dev, uart.port.irq, exar_misc_handler, + IRQF_SHARED, "exar_uart", priv); + if (rc) + return rc; + for (i =3D 0; i < nr_ports && i < maxnr; i++) { rc =3D board->setup(priv, pcidev, &uart, i); if (rc) { diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index 8dcfd4978a03..e9d4420869dd 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -445,7 +445,6 @@ static void io_serial_out(struct uart_port *p, int offs= et, int value) } =20 static int serial8250_default_handle_irq(struct uart_port *port); -static int exar_handle_irq(struct uart_port *port); =20 static void set_io_from_upio(struct uart_port *p) { @@ -1890,26 +1889,6 @@ static int serial8250_default_handle_irq(struct uart= _port *port) return ret; } =20 -/* - * These Exar UARTs have an extra interrupt indicator that could - * fire for a few unimplemented interrupts. One of which is a - * wakeup event when coming out of sleep. Put this here just - * to be on the safe side that these interrupts don't go unhandled. - */ -static int exar_handle_irq(struct uart_port *port) -{ - unsigned int iir =3D serial_port_in(port, UART_IIR); - int ret =3D 0; - - if (((port->type =3D=3D PORT_XR17V35X) || (port->type =3D=3D PORT_XR17D15= X)) && - serial_port_in(port, UART_EXAR_INT0) !=3D 0) - ret =3D 1; - - ret |=3D serial8250_handle_irq(port, iir); - - return ret; -} - /* * Newer 16550 compatible parts such as the SC16C650 & Altera 16550 Soft I= P * have a programmable TX threshold that triggers the THRE interrupt in @@ -3074,11 +3053,6 @@ static void serial8250_config_port(struct uart_port = *port, int flags) if (port->type =3D=3D PORT_UNKNOWN) serial8250_release_std_resource(up); =20 - /* Fixme: probably not the best place for this */ - if ((port->type =3D=3D PORT_XR17V35X) || - (port->type =3D=3D PORT_XR17D15X)) - port->handle_irq =3D exar_handle_irq; - register_dev_spec_attr_grp(up); up->fcr =3D uart_config[up->port.type].fcr; } --=20 2.15.1