From nobody Wed Apr 15 16:26:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8314EC433FE for ; Wed, 16 Nov 2022 21:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234150AbiKPVf5 (ORCPT ); Wed, 16 Nov 2022 16:35:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233153AbiKPVfx (ORCPT ); Wed, 16 Nov 2022 16:35:53 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2710CD2F1 for ; Wed, 16 Nov 2022 13:35:53 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 7EAC792009C; Wed, 16 Nov 2022 22:35:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 788DC92009B; Wed, 16 Nov 2022 21:35:52 +0000 (GMT) Date: Wed, 16 Nov 2022 21:35:52 +0000 (GMT) From: "Maciej W. Rozycki" To: Sudip Mukherjee cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/6] parport_pc: Remove stale `parport_pc_ecp_read_block_pio' reference In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Complement commit 991214386dee ("parport: remove unused dead code from=20 lowlevel drivers") and remove a stale piece of commented-out code that=20 refers to a function removed with said commit. Signed-off-by: Maciej W. Rozycki --- drivers/parport/parport_pc.c | 2 -- 1 file changed, 2 deletions(-) linux-parport-pc-ecp-read-block-pio-call.diff Index: linux-macro/drivers/parport/parport_pc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/drivers/parport/parport_pc.c +++ linux-macro/drivers/parport/parport_pc.c @@ -2119,8 +2119,6 @@ struct parport *parport_pc_probe_port(un p->ops->compat_write_data =3D parport_pc_compat_write_block_pio; #ifdef CONFIG_PARPORT_1284 p->ops->ecp_write_data =3D parport_pc_ecp_write_block_pio; - /* currently broken, but working on it.. (FB) */ - /* p->ops->ecp_read_data =3D parport_pc_ecp_read_block_pio; */ #endif /* IEEE 1284 support */ if (p->dma !=3D PARPORT_DMA_NONE) { pr_cont(", dma %d", p->dma); From nobody Wed Apr 15 16:26:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74881C4332F for ; Wed, 16 Nov 2022 21:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231421AbiKPVgE (ORCPT ); Wed, 16 Nov 2022 16:36:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234120AbiKPVf6 (ORCPT ); Wed, 16 Nov 2022 16:35:58 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CC683EE1B for ; Wed, 16 Nov 2022 13:35:57 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 1083492009C; Wed, 16 Nov 2022 22:35:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 0A81492009B; Wed, 16 Nov 2022 21:35:57 +0000 (GMT) Date: Wed, 16 Nov 2022 21:35:56 +0000 (GMT) From: "Maciej W. Rozycki" To: Sudip Mukherjee cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/6] parport_pc: Let chipset drivers mask unsupported modes In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename `parport_pc_probe_port' to `__parport_pc_probe_port' and add a=20 `mode_mask' parameter so that callers can specify a mask of unsupported=20 modes to exclude even if mode probing seems to indicate otherwise. Add=20 a `parport_pc_probe_port' wrapper with an implicit mask of 0 for the=20 current callers to use. No functional change at this point, but the configuration of data write=20 handlers is now no longer intertwined with determination and reporting=20 of available modes. Signed-off-by: Maciej W. Rozycki --- drivers/parport/parport_pc.c | 45 +++++++++++++++++++++++++++++++-------= ----- 1 file changed, 33 insertions(+), 12 deletions(-) linux-parport-pc-mode-mask.diff Index: linux-macro/drivers/parport/parport_pc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/drivers/parport/parport_pc.c +++ linux-macro/drivers/parport/parport_pc.c @@ -2000,11 +2000,12 @@ static int parport_dma_probe(struct parp static LIST_HEAD(ports_list); static DEFINE_SPINLOCK(ports_lock); =20 -struct parport *parport_pc_probe_port(unsigned long int base, - unsigned long int base_hi, - int irq, int dma, - struct device *dev, - int irqflags) +static struct parport *__parport_pc_probe_port(unsigned long int base, + unsigned long int base_hi, + int irq, int dma, + struct device *dev, + int irqflags, + unsigned int mode_mask) { struct parport_pc_private *priv; struct parport_operations *ops; @@ -2116,18 +2117,28 @@ struct parport *parport_pc_probe_port(un p->dma !=3D PARPORT_DMA_NOFIFO && priv->fifo_depth > 0 && p->irq !=3D PARPORT_IRQ_NONE) { p->modes |=3D PARPORT_MODE_ECP | PARPORT_MODE_COMPAT; + if (p->dma !=3D PARPORT_DMA_NONE) + p->modes |=3D PARPORT_MODE_DMA; + } else + /* We can't use the DMA channel after all. */ + p->dma =3D PARPORT_DMA_NONE; +#endif /* Allowed to use FIFO/DMA */ + + p->modes &=3D ~mode_mask; + +#ifdef CONFIG_PARPORT_PC_FIFO + if ((p->modes & PARPORT_MODE_COMPAT) !=3D 0) p->ops->compat_write_data =3D parport_pc_compat_write_block_pio; #ifdef CONFIG_PARPORT_1284 + if ((p->modes & PARPORT_MODE_ECP) !=3D 0) p->ops->ecp_write_data =3D parport_pc_ecp_write_block_pio; -#endif /* IEEE 1284 support */ - if (p->dma !=3D PARPORT_DMA_NONE) { +#endif + if ((p->modes & (PARPORT_MODE_ECP | PARPORT_MODE_COMPAT)) !=3D 0) { + if ((p->modes & PARPORT_MODE_DMA) !=3D 0) pr_cont(", dma %d", p->dma); - p->modes |=3D PARPORT_MODE_DMA; - } else + else pr_cont(", using FIFO"); - } else - /* We can't use the DMA channel after all. */ - p->dma =3D PARPORT_DMA_NONE; + } #endif /* Allowed to use FIFO/DMA */ =20 pr_cont(" ["); @@ -2237,6 +2248,16 @@ do { \ platform_device_unregister(pdev); return NULL; } + +struct parport *parport_pc_probe_port(unsigned long int base, + unsigned long int base_hi, + int irq, int dma, + struct device *dev, + int irqflags) +{ + return __parport_pc_probe_port(base, base_hi, irq, dma, + dev, irqflags, 0); +} EXPORT_SYMBOL(parport_pc_probe_port); =20 void parport_pc_unregister_port(struct parport *p) From nobody Wed Apr 15 16:26:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74328C433FE for ; Wed, 16 Nov 2022 21:36:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233153AbiKPVgL (ORCPT ); Wed, 16 Nov 2022 16:36:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234174AbiKPVgE (ORCPT ); Wed, 16 Nov 2022 16:36:04 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 65845FAF0 for ; Wed, 16 Nov 2022 13:36:02 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id C1D3F92009D; Wed, 16 Nov 2022 22:36:01 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id BBC7D92009C; Wed, 16 Nov 2022 21:36:01 +0000 (GMT) Date: Wed, 16 Nov 2022 21:36:01 +0000 (GMT) From: "Maciej W. Rozycki" To: Sudip Mukherjee cc: linux-kernel@vger.kernel.org Subject: [PATCH 3/6] parport_pc: Let chipset drivers mask ECR bits on writes In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Provide an `ecr_writable' parameter to `__parport_pc_probe_port' so that=20 callers can specify a mask of bits to modify on ECR writes. To avoid the need for separate bit set and bit clear masks always set=20 bit 0 whenever a non-zero mask has been set, as all the currently known=20 cases where a mask is required, that is Oxford Semiconductor devices, do=20 require this bit to be set. If further cases are discovered where the=20 bit is required to be clear, we can update code accordingly, but chances=20 are very low as the bit is supposed to be read-only[1]. Skip ECR probing, which can be problematic as the Oxford Semiconductor=20 OX12PCI840 part has been reported to lock up on setting bit 2, whenever=20 a non-zero mask has been requested by a port subdriver, assuming that=20 the ECR must be there if the subdriver has requested a specific way to=20 access it. References: [1] "Extended Capabilities Port Protocol and ISA Interface Standard",=20 Microsoft Corporation, Revision: 1.14, July 14, 1993, Table 14=20 "Extended Control Register" Signed-off-by: Maciej W. Rozycki --- drivers/parport/parport_pc.c | 46 +++++++++++++++++++++++++++-----------= ----- include/linux/parport_pc.h | 3 ++ 2 files changed, 32 insertions(+), 17 deletions(-) linux-parport-pc-ecr-write.diff Index: linux-macro/drivers/parport/parport_pc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/drivers/parport/parport_pc.c +++ linux-macro/drivers/parport/parport_pc.c @@ -106,15 +106,22 @@ static int pnp_registered_parport; static void frob_econtrol(struct parport *pb, unsigned char m, unsigned char v) { + const struct parport_pc_private *priv =3D pb->physport->private_data; + unsigned char ecr_writable =3D priv->ecr_writable; unsigned char ectr =3D 0; + unsigned char new; =20 if (m !=3D 0xff) ectr =3D inb(ECONTROL(pb)); =20 - pr_debug("frob_econtrol(%02x,%02x): %02x -> %02x\n", - m, v, ectr, (ectr & ~m) ^ v); + new =3D (ectr & ~m) ^ v; + if (ecr_writable) + /* All known users of the ECR mask require bit 0 to be set. */ + new =3D (new & ecr_writable) | 1; =20 - outb((ectr & ~m) ^ v, ECONTROL(pb)); + pr_debug("frob_econtrol(%02x,%02x): %02x -> %02x\n", m, v, ectr, new); + + outb(new, ECONTROL(pb)); } =20 static inline void frob_set_mode(struct parport *p, int mode) @@ -1479,21 +1486,24 @@ static int parport_ECR_present(struct pa struct parport_pc_private *priv =3D pb->private_data; unsigned char r =3D 0xc; =20 - outb(r, CONTROL(pb)); - if ((inb(ECONTROL(pb)) & 0x3) =3D=3D (r & 0x3)) { - outb(r ^ 0x2, CONTROL(pb)); /* Toggle bit 1 */ + if (!priv->ecr_writable) { + outb(r, CONTROL(pb)); + if ((inb(ECONTROL(pb)) & 0x3) =3D=3D (r & 0x3)) { + outb(r ^ 0x2, CONTROL(pb)); /* Toggle bit 1 */ =20 - r =3D inb(CONTROL(pb)); - if ((inb(ECONTROL(pb)) & 0x2) =3D=3D (r & 0x2)) - goto no_reg; /* Sure that no ECR register exists */ - } + r =3D inb(CONTROL(pb)); + if ((inb(ECONTROL(pb)) & 0x2) =3D=3D (r & 0x2)) + /* Sure that no ECR register exists */ + goto no_reg; + } =20 - if ((inb(ECONTROL(pb)) & 0x3) !=3D 0x1) - goto no_reg; + if ((inb(ECONTROL(pb)) & 0x3) !=3D 0x1) + goto no_reg; =20 - ECR_WRITE(pb, 0x34); - if (inb(ECONTROL(pb)) !=3D 0x35) - goto no_reg; + ECR_WRITE(pb, 0x34); + if (inb(ECONTROL(pb)) !=3D 0x35) + goto no_reg; + } =20 priv->ecr =3D 1; outb(0xc, CONTROL(pb)); @@ -2005,7 +2015,8 @@ static struct parport *__parport_pc_prob int irq, int dma, struct device *dev, int irqflags, - unsigned int mode_mask) + unsigned int mode_mask, + unsigned char ecr_writable) { struct parport_pc_private *priv; struct parport_operations *ops; @@ -2054,6 +2065,7 @@ static struct parport *__parport_pc_prob priv->ctr =3D 0xc; priv->ctr_writable =3D ~0x10; priv->ecr =3D 0; + priv->ecr_writable =3D ecr_writable; priv->fifo_depth =3D 0; priv->dma_buf =3D NULL; priv->dma_handle =3D 0; @@ -2256,7 +2268,7 @@ struct parport *parport_pc_probe_port(un int irqflags) { return __parport_pc_probe_port(base, base_hi, irq, dma, - dev, irqflags, 0); + dev, irqflags, 0, 0); } EXPORT_SYMBOL(parport_pc_probe_port); =20 Index: linux-macro/include/linux/parport_pc.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/include/linux/parport_pc.h +++ linux-macro/include/linux/parport_pc.h @@ -26,6 +26,9 @@ struct parport_pc_private { /* Whether or not there's an ECR. */ int ecr; =20 + /* Bitmask of writable ECR bits. */ + unsigned char ecr_writable; + /* Number of PWords that FIFO will hold. */ int fifo_depth; From nobody Wed Apr 15 16:26:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34FF5C4332F for ; Wed, 16 Nov 2022 21:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234332AbiKPVgP (ORCPT ); Wed, 16 Nov 2022 16:36:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234191AbiKPVgH (ORCPT ); Wed, 16 Nov 2022 16:36:07 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5DECFF5B1 for ; Wed, 16 Nov 2022 13:36:06 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id B96BA92009C; Wed, 16 Nov 2022 22:36:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id B268892009B; Wed, 16 Nov 2022 21:36:05 +0000 (GMT) Date: Wed, 16 Nov 2022 21:36:05 +0000 (GMT) From: "Maciej W. Rozycki" To: Sudip Mukherjee cc: linux-kernel@vger.kernel.org Subject: [PATCH 4/6] parport_pc: Add a mode mask field for PCI devices In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a mode mask field for PCI devices and use `__parport_pc_probe_port'=20 in place of `parport_pc_probe_port' to apply it. Signed-off-by: Maciej W. Rozycki --- drivers/parport/parport_pc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) linux-parport-pc-pci-mode-mask.diff Index: linux-macro/drivers/parport/parport_pc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/drivers/parport/parport_pc.c +++ linux-macro/drivers/parport/parport_pc.c @@ -2659,6 +2659,9 @@ static struct parport_pc_pci { /* -1 if not there, >6 for offset-method (max BAR is 6) */ } addr[4]; =20 + /* Bit field of parport modes to exclude. */ + unsigned int mode_mask; + /* If set, this is called immediately after pci_enable_device. * If it returns non-zero, no probing will take place and the * ports will not be used. */ @@ -2862,9 +2865,10 @@ static int parport_pc_pci_probe(struct p id->vendor, id->device, io_lo, io_hi, irq); } data->ports[count] =3D - parport_pc_probe_port(io_lo, io_hi, irq, - PARPORT_DMA_NONE, &dev->dev, - IRQF_SHARED); + __parport_pc_probe_port(io_lo, io_hi, irq, + PARPORT_DMA_NONE, &dev->dev, + IRQF_SHARED, + cards[i].mode_mask, 0); if (data->ports[count]) count++; } From nobody Wed Apr 15 16:26:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15650C4332F for ; Wed, 16 Nov 2022 21:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233869AbiKPVgT (ORCPT ); Wed, 16 Nov 2022 16:36:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233809AbiKPVgL (ORCPT ); Wed, 16 Nov 2022 16:36:11 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C0E9AFCD3 for ; Wed, 16 Nov 2022 13:36:10 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id B607D92009C; Wed, 16 Nov 2022 22:36:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id B272192009B; Wed, 16 Nov 2022 21:36:09 +0000 (GMT) Date: Wed, 16 Nov 2022 21:36:09 +0000 (GMT) From: "Maciej W. Rozycki" To: Sudip Mukherjee cc: linux-kernel@vger.kernel.org Subject: [PATCH 5/6] parport_pc: Add an ECR mask field for PCI devices In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a bitmask field specifying writable ECR bits for PCI devices and=20 apply it via `__parport_pc_probe_port'. Signed-off-by: Maciej W. Rozycki --- drivers/parport/parport_pc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) linux-parport-pc-pci-ecr-write.diff Index: linux-macro/drivers/parport/parport_pc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/drivers/parport/parport_pc.c +++ linux-macro/drivers/parport/parport_pc.c @@ -2662,6 +2662,10 @@ static struct parport_pc_pci { /* Bit field of parport modes to exclude. */ unsigned int mode_mask; =20 + /* If non-zero, sets the bitmask of writable ECR bits. In that + * case additionally bit 0 will be forcibly set on writes. */ + unsigned char ecr_writable; + /* If set, this is called immediately after pci_enable_device. * If it returns non-zero, no probing will take place and the * ports will not be used. */ @@ -2868,7 +2872,8 @@ static int parport_pc_pci_probe(struct p __parport_pc_probe_port(io_lo, io_hi, irq, PARPORT_DMA_NONE, &dev->dev, IRQF_SHARED, - cards[i].mode_mask, 0); + cards[i].mode_mask, + cards[i].ecr_writable); if (data->ports[count]) count++; } From nobody Wed Apr 15 16:26:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5B89C4332F for ; Wed, 16 Nov 2022 21:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235024AbiKPVgc (ORCPT ); Wed, 16 Nov 2022 16:36:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234372AbiKPVgR (ORCPT ); Wed, 16 Nov 2022 16:36:17 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2B3E9EE0D for ; Wed, 16 Nov 2022 13:36:16 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 8A90392009D; Wed, 16 Nov 2022 22:36:15 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 8610A92009C; Wed, 16 Nov 2022 21:36:15 +0000 (GMT) Date: Wed, 16 Nov 2022 21:36:15 +0000 (GMT) From: "Maciej W. Rozycki" To: Sudip Mukherjee cc: linux-kernel@vger.kernel.org Subject: [PATCH 6/6] parport_pc: Set up mode and ECR masks for Oxford Semiconductor devices In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" No Oxford Semiconductor PCI or PCIe parallel port device supports the=20 Parallel Port FIFO mode. All support the PS/2 Parallel Port mode and=20 the Enhanced Parallel Port mode via the ECR register. The original 5V=20 PCI OX16PCI954 device does not support the Extended Capabilities Port=20 mode, the Test mode or the Configuration mode, but all the other OxSemi=20 devices do, including in particular the 3.3V PCI OXmPCI954 device and=20 the universal voltage PCI OXuPCI954 device. All the unsupported modes=20 are marked reserved in the relevant datasheets. Accordingly enable the `base_hi' BAR for the 954 devices to enable PS2=20 and EPP mode support via the ECR register, however mask the COMPAT mode=20 and, until we have a way to determine what chip variant it is that we=20 poke at, also the ECP mode, and mask the COMPAT mode only for all the=20 remaining OxSemi devices, fixing errors like: parport0: FIFO is stuck FIFO write timed out and a non-functional port when the Parallel Port FIFO mode is selected. Complementing the fix apply an ECR mask for all these devices, which are=20 documented to only permit writing to the mode field of the ECR register=20 with a bit pattern of 00001 required to be written to bits 4:0 on mode=20 field writes. No nFault or service interrupts are implemented, which=20 will therefore never have to be enabled, though bit 2 does report the=20 FIFO threshold status to be polled for in the ECP mode where supported. We have a documented case of writing 1 to bit 2 causing a lock-up with=20 at least one OX12PCI840 device (from old drivers/parport/ChangeLog): 2001-10-10 Tim Waugh * parport_pc.c: Support for OX12PCI840 PCI card (reported by mk@daveg.com). Lock-ups diagnosed by Ronnie Arosa (and now we just don't trust its ECR). which commit adbd321a17cc ("parport_pc: add base_hi BAR for oxsemi_840")=20 must have broken and by applying an ECR mask here we prevent the lock-up=20 from triggering. This could have been the reason for requiring 00001 to=20 be written to bits 4:0 of ECR. Update the inline comment accordingly; it has come from Linux 2.4.12=20 back in 2001 and predates the introduction of OXmPCI954 and OXuPCI954=20 devices that do support ECP. References: [1] "OX16PCI954 Integrated Quad UART and PCI interface", Oxford=20 Semiconductor Ltd., Data Sheet Revision 1.3, Feb. 1999, Chapter 9=20 "Bidirectional Parallel Port", pp. 53-55 [2] "OX16PCI952 Data Sheet, Integrated High Performance Dual UARTs, Parallel Port and 5.0v PCI interface", Oxford Semiconductor Ltd.,=20 DS_B008A_00, Datasheet rev 1.1, June 2001, Chapter 8 "Bi-directional=20 Parallel Port", pp. 52-56 [3] "OXmPCI954 DATA SHEET Integrated High Performance Quad UARTs, 8-bit=20 Local Bus/Parallel Port. 3.3v PCI/miniPCI interface.", Oxford=20 Semiconductor Ltd., DS-0019, June 2005, Chapter 10 "Bidirectional=20 Parallel Port", pp. 86-90 [4] "OXmPCI952 Data Sheet, Integrated High Performance Dual UARTs, 8-bit=20 Local Bus/Parallel Port. 3.3v PCI/miniPCI interface.", Oxford=20 Semiconductor Ltd., DS-0020, June 2005, Chapter 8 "Bidirectional=20 Parallel Port", pp. 73-77 [5] "OX12PCI840 Integrated Parallel Port and PCI interface", Oxford Semiconductor Ltd., DS-0021, Jun 2005, Chapter 5 "Bi-directional Parallel Port", pp. 18-21 [6] "OXPCIe952 PCI Express Bridge to Dual Serial & Parallel Port", Oxford Semiconductor, Inc., DS-0046, Mar 06 08, Chapter "Parallel Port Function", pp. 59-62 [7] "OXPCIe840 PCI Express Bridge to Parallel Port", Oxford=20 Semiconductor, Inc., DS-0049, Mar 06 08, Chapter "Parallel Port=20 Function", pp. 15-18 [8] "OXuPCI954 Data Sheet, Integrated High Performance Quad UARTs, 8-bit=20 Local Bus/Parallel Port, 3.3 V and 5 V (Universal Voltage) PCI=20 Interface.", Oxford Semiconductor, Inc., DS-0058, 26 Jan 2009,=20 Chapter 8 "Bidirectional Parallel Port", pp. 62-65 [9] "OXuPCI952 Data Sheet, Integrated High Performance Dual UARTs, 8-bit=20 Local Bus/Parallel Port, 3.3 V and 5.0 V Universal Voltage PCI=20 Interface.", Oxford Semiconductor, Inc., DS-0059, Sep 2007, Chapter=20 8 "Bidirectional Parallel Port", pp. 61-64 Signed-off-by: Maciej W. Rozycki --- drivers/parport/parport_pc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) linux-parport-pc-pci-oxsemi-modes.diff Index: linux-macro/drivers/parport/parport_pc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/drivers/parport/parport_pc.c +++ linux-macro/drivers/parport/parport_pc.c @@ -2696,12 +2696,19 @@ static struct parport_pc_pci { /* titan_010l */ { 1, { { 3, -1 }, } }, /* avlab_1p */ { 1, { { 0, 1}, } }, /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} }, - /* The Oxford Semi cards are unusual: 954 doesn't support ECP, - * and 840 locks up if you write 1 to bit 2! */ - /* oxsemi_952 */ { 1, { { 0, 1 }, } }, - /* oxsemi_954 */ { 1, { { 0, -1 }, } }, - /* oxsemi_840 */ { 1, { { 0, 1 }, } }, - /* oxsemi_pcie_pport */ { 1, { { 0, 1 }, } }, + /* The Oxford Semi cards are unusual: older variants of 954 don't + * support ECP, and 840 locks up if you write 1 to bit 2! None + * implement nFault or service interrupts and all require 00001 + * bit pattern to be used for bits 4:0 with ECR writes. */ + /* oxsemi_952 */ { 1, { { 0, 1 }, }, + PARPORT_MODE_COMPAT, ECR_MODE_MASK }, + /* oxsemi_954 */ { 1, { { 0, 1 }, }, + PARPORT_MODE_ECP | + PARPORT_MODE_COMPAT, ECR_MODE_MASK }, + /* oxsemi_840 */ { 1, { { 0, 1 }, }, + PARPORT_MODE_COMPAT, ECR_MODE_MASK }, + /* oxsemi_pcie_pport */ { 1, { { 0, 1 }, }, + PARPORT_MODE_COMPAT, ECR_MODE_MASK }, /* aks_0100 */ { 1, { { 0, -1 }, } }, /* mobility_pp */ { 1, { { 0, 1 }, } }, /* netmos_9900 */ { 1, { { 0, -1 }, } },