Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3767476pxt; Tue, 10 Aug 2021 10:51:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDjQzOkyfQVZZkt7/9BNY6EgdtT9TsZSwvyca73ns6b2MwfWPqtX1hBhfSY6ayyI1MaXqY X-Received: by 2002:a02:2307:: with SMTP id u7mr28458820jau.28.1628617874581; Tue, 10 Aug 2021 10:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617874; cv=none; d=google.com; s=arc-20160816; b=aRWZlaJuqDWWWqDbrPmVNdnonK1fTuiHYwilCMIVyAktiSkks4Ib9wHAeuNpJK1kme R29ACdtynOxpgLaMXREPYuNxWeAcsZHtZyDywERJX9Dv4dmLglDdL7zi5CjzMQoIgmwv lKKQA/qxs7OwWcBUefUOz/W55AMifPBT2R/88iHXO1/hVKNaIu4n/Ux4DMWDD9INI8w7 il8VcYZ+WkdmqV1/hbdRjlrzdRpFRfRlvTl7fJb+WVzbdJMJOp/jJcdUYXTGStjPb3Cb fLG8HSiEjFqiOX425OKPM/TxeZhy3y4Z4oI1vHHE9qWd1WKZtLJw4zdTvy2dodRtgDEV e25g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IJw8kQ7EWG4lKsfLjzvpdow8AkllW2MvPsFp1DnLxis=; b=Wk4NI5r4KxokLi6hEEhMB+aiEY8GA5K5HbdQiT0BnIzWjvplWfgzUoft+PwdkCzdQa iqPLSfEmP6Sm5dt5IZY0wxCEV9YSyg09OKMEWwHd/fE+9jmUMA7cBfDrTlgG/xmpxZVQ Z04yK0DVPv/y0i84Yy9QEna9PhyivAWdTJeI3VyzJAxEYOP7D86pupwDsCyPElfgxc69 idoHrQYH0XoMgz4VNpEoDp+lRSJ52p3eIbjD475/P2Gj27NJepfQqmvKXglWvAXAIwU9 H062AxWsxpANCS1t9UH6fzPi2pPmfiAFPJCYE+i0JYja3kGPm3CTidlOtWcmg6mQZ9dA fxbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jo+Hz9ig; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si25652277ilu.13.2021.08.10.10.51.03; Tue, 10 Aug 2021 10:51:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jo+Hz9ig; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234400AbhHJRtA (ORCPT + 99 others); Tue, 10 Aug 2021 13:49:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:50910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235730AbhHJRqD (ORCPT ); Tue, 10 Aug 2021 13:46:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D27561251; Tue, 10 Aug 2021 17:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617222; bh=s0g1xmmZwpz0X/vZ9KJFPr4XM+vbvQa7yuAIxalVp1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jo+Hz9igLqy9jYSDQUhHcIPPZMaai2VHVHQCRUYwTfFWxbtMH1h1pstrHT6xtJBzx 4AVGWLpecIZehYqgkGaJjp8IOSKdRSE7b2j47vJLQ1KifEbc+hlJkGN7spfWq3wTTP mctD5Y1lP3WSdaOmK8Eeyz+V/LcZmZy5I2LYyt/k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ralf Ramsauer , Andy Shevchenko , Mario Kleiner Subject: [PATCH 5.10 099/135] serial: 8250_pci: Avoid irq sharing for MSI(-X) interrupts. Date: Tue, 10 Aug 2021 19:30:33 +0200 Message-Id: <20210810172959.123092016@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mario Kleiner commit 341abd693d10e5f337a51f140ae3e7a1ae0febf6 upstream. This attempts to fix a bug found with a serial port card which uses an MCS9922 chip, one of the 4 models for which MSI-X interrupts are currently supported. I don't possess such a card, and i'm not experienced with the serial subsystem, so this patch is based on what i think i found as a likely reason for failure, based on walking the user who actually owns the card through some diagnostic. The user who reported the problem finds the following in his dmesg output for the relevant ttyS4 and ttyS5: [ 0.580425] serial 0000:02:00.0: enabling device (0000 -> 0003) [ 0.601448] 0000:02:00.0: ttyS4 at I/O 0x3010 (irq = 125, base_baud = 115200) is a ST16650V2 [ 0.603089] serial 0000:02:00.1: enabling device (0000 -> 0003) [ 0.624119] 0000:02:00.1: ttyS5 at I/O 0x3000 (irq = 126, base_baud = 115200) is a ST16650V2 ... [ 6.323784] genirq: Flags mismatch irq 128. 00000080 (ttyS5) vs. 00000000 (xhci_hcd) [ 6.324128] genirq: Flags mismatch irq 128. 00000080 (ttyS5) vs. 00000000 (xhci_hcd) ... Output of setserial -a: /dev/ttyS4, Line 4, UART: 16650V2, Port: 0x3010, IRQ: 127 Baud_base: 115200, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal skip_test This suggests to me that the serial driver wants to register and share a MSI/MSI-X irq 128 with the xhci_hcd driver, whereas the xhci driver does not want to share the irq, as flags 0x00000080 (== IRQF_SHARED) from the serial port driver means to share the irq, and this mismatch ends in some failed irq init? With this setup, data reception works very unreliable, with dropped data, already at a transmission rate of only a 16 Bytes chunk every 1/120th of a second, ie. 1920 Bytes/sec, presumably due to rx fifo overflow due to mishandled or not used at all rx irq's? See full discussion thread with attempted diagnosis at: https://psychtoolbox.discourse.group/t/issues-with-iscan-serial-port-recording/3886 Disabling the use of MSI interrupts for the serial port pci card did fix the reliability problems. The user executed the following sequence of commands to achieve this: echo 0000:02:00.0 | sudo tee /sys/bus/pci/drivers/serial/unbind echo 0000:02:00.1 | sudo tee /sys/bus/pci/drivers/serial/unbind echo 0 | sudo tee /sys/bus/pci/devices/0000:02:00.0/msi_bus echo 0 | sudo tee /sys/bus/pci/devices/0000:02:00.1/msi_bus echo 0000:02:00.0 | sudo tee /sys/bus/pci/drivers/serial/bind echo 0000:02:00.1 | sudo tee /sys/bus/pci/drivers/serial/bind This resulted in the following log output: [ 82.179021] pci 0000:02:00.0: MSI/MSI-X disallowed for future drivers [ 87.003031] pci 0000:02:00.1: MSI/MSI-X disallowed for future drivers [ 98.537010] 0000:02:00.0: ttyS4 at I/O 0x3010 (irq = 17, base_baud = 115200) is a ST16650V2 [ 103.648124] 0000:02:00.1: ttyS5 at I/O 0x3000 (irq = 18, base_baud = 115200) is a ST16650V2 This patch attempts to fix the problem by disabling irq sharing when using MSI irq's. Note that all i know for sure is that disabling MSI irq's fixed the problem for the user, so this patch could be wrong and is untested. Please review with caution, keeping this in mind. Fixes: 8428413b1d14 ("serial: 8250_pci: Implement MSI(-X) support") Cc: Ralf Ramsauer Cc: stable Reviewed-by: Andy Shevchenko Signed-off-by: Mario Kleiner Link: https://lore.kernel.org/r/20210729043306.18528-1-mario.kleiner.de@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_pci.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -3970,6 +3970,7 @@ pciserial_init_ports(struct pci_dev *dev if (pci_match_id(pci_use_msi, dev)) { dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n"); pci_set_master(dev); + uart.port.flags &= ~UPF_SHARE_IRQ; rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES); } else { dev_dbg(&dev->dev, "Using legacy interrupts\n");