From patchwork Mon Oct 19 20:06:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Pedrosa X-Patchwork-Id: 3677 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id D2F771C219B for ; Mon, 19 Oct 2026 22:11:43 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-26750-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-26750-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 94A7238D74 for ; Mon, 19 Oct 2026 20:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792440422; b=TFpEnPdmQV16LtTyGdhkP+EJwLs9aCa0F60tMEh8/kQvQgTzTszSFgF8P3JjFWxTV/zd LFjHeh6bVyfrFKsLtp6jBedqIIotORm2vhY/XASgQfrPLAaK5PAvAxnLYlTYjJA7sGSr0 Zj4UWIkgE4XB+L8qRzzZ5eZkngMsueEoLmxo9mFwUX5Hcp7QqF26eJTcicg9nRjP7doeY ffopbqSalPEq/XFDXIwXY8qeKpz7uD5pDs3EIlUCN3Gf9RH3iLquIntHkz4T4O/5iCY62 NzrX6PVyXP7BfWnVPufLNxoxNdXg/3DgtAmSv5AzqKpclQL07t7T9LWBY/2hZE0npnA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792440422; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding; bh=MQXVI025privUEtANhdwM89LTKKhsWNz40cUmpuugYc=; b=VpXR3kQtJ2Pr4g5NYjXN+aXtjd93F/Kwtz6loeUJbEA+a36J5pSloVRpSTi7upI3Z6SQ f3FsiYFdrKd7PC0UlbW6C+Yo23aIngSiz1026RQ2/ZiT2Feqdasalssr6h96bZdaa9xa7 IROPvEcKQv//ALrGnSAEMi/megte1iRIoEjk80QUSu8sTu1D20DaCmDzC99z9IzesZt0b N/vsYPad536eNXIrA06sXFP+vNjcE2BMGpGV+gnBBBAcdvMQK1aJOgWu9fgNL5PoWaLgl dD49C/uReDRp3JtTwb6iPkk8rd4bxKWYSTSVxkZZd4AAe0wDIsozoBgZ0FT2IDki4DQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=BHBBkb2+; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A287606A320; Mon, 19 Oct 2026 20:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=BHBBkb2+ X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792440422; b=VuMgiHCBw1zHnwY69oizUaOKYAkQS++iqOSsDVUt1ctD67h/RYnQcrzWuQCl3QufnZfb 8ad9xSWnj0Xd84FUCLnO63wXQjDDVGdRHm5iVLME26IFQNPqT36OKFHKfAfCumArAvU01 uAhosy2ciio0jJ1TU5ef0LBSJg7WfXFQfK0AwPBi+puFkwqLKNRI1EMoAN7Ib4D+SYek+ DzV2e40gSKG40FDJaV5xVfq275JKU84XlpuOe0Rr3luTeFrzRnxzNjQD5JNPAvX0KtV4o 6704qRtF/bbFF5SxR5bnTZdtLenjh4edHxfFqGwSAAH8+MsgTkMjsx83E8nz6WQGi+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792440422; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=MQXVI025privUEtANhdwM89LTKKhsWNz40cUmpuugYc=; b=koyzUHxdViWwDdzbHmZcBwMMOamuwz2pwxs8r/FrYFmPpeMsKu2hcfBrJSPUscdLUebm hHC/x3eZWlJIE9JtJAlRy6Y0QkO6Gq1AO9ZniLL2Sjj8XNVjXmxQHZpgHsN6FmTR5LRIN v/OguIh0ng1w4vYgE1pRzCv6VCSysE8Tw0Ep0Wff8IhjNoTQPgJVxM0hZoOSS9/WX7HPt OmJQkZdaUbTcPCkJEON5Wf4XvJnWf9jbXRHHIkAXdowk9NxxU7eXZRjyJzHy4UDbbkmH5 9FQpziEANbQWS9vekJNlPr8whGfympgu4S2HnOP5r8Sk+QPE8K4kyxZwmczwsLGsJWA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=BHBBkb2+; arc=none smtp.remote-ip=209.85.221.179 Received: from mail-vk1-f179.google.com (mail-vk1-f179.google.com [209.85.221.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2242606A31F for ; Mon, 19 Oct 2026 20:07:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F2242606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f179.google.com with SMTP id 71dfb90a1353d-5eac7220e9cso681351e0c.3 for ; Mon, 19 Oct 2026 13:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792440421; x=1793045221; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=MQXVI025privUEtANhdwM89LTKKhsWNz40cUmpuugYc=; b=BHBBkb2+hwIvmtwy9Orfk79/j7qL3s/SasNq5YEGhojsoO7j7SDvORwDaXhEREySrq m2CvMIxxFnAqtmzzm7y8KQKLw97essZ8Kje6R9/PkKVfCl77iQsAP5Mk89pF1mHI5L0r PNi06FZVsu8SrYhr6Ne/EOnwTMGB1ihqUF2KCQ75yzzTcvdM5N4P5FfW659JbyQ9Rl88 zIkQIBDWjZtyWQ77duUQonc/9PxCo5DIh4Oe3OeXY7vmNdtPNV+x2XtiMUhxOFCMCQTe /ySEJunip3DzxV8IKop/eb9MOGI18jhYQbVJxhT4Z2U637CsuU6XlPfXj0bflZkUUhEd JMPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792440421; x=1793045221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=MQXVI025privUEtANhdwM89LTKKhsWNz40cUmpuugYc=; b=tgkwsP61rJW/WiG2rYA9fJ2wijfYxF8RwPVjlxglzMh03Ena8eNIipfiY4a7AhdQM2 4vIfcfbsev3TVz1oJ++MsuuaoyNNpepVDvJ9e8GgsEZu1agCMLzjEcmRwOUO4AJgunhr UNCjOeQrr0vLxOodN+TI+SoY1iRejBcM9scgVFoLHo8fwm++bID1sUl6qUHO0nYsI7ml DPni1znLLLAGHK6Kq8t2cNFLAV+NeJFG9USLE2BZDFstDoBsN0xanpk7Eig9vb5B1nLO J28L+AktvloUWPhU/OTWoZm30k0qVhdwoYG4gOomaxeN2lCFNQVHnpyWWDfhBjn/bKT4 0CPQ== X-Forwarded-Encrypted: i=1; AKwUvBzCRUxXwJVVJbaiCX+50wekxjkCQEsqGSGSBwr6XohDqTHP/VKSqAtnv5I4adZ4uQt3jCwQBl3KH4nRaw==@lists.linux.dev X-Gm-Message-State: AFq9FYLKgWaR49TJYjJTKB7DBP3jJrdizZsuY0UTqxejL5JbkbZ7UmtG g4BrBgi82JNe4RDTykDLtF3+szM3Yl3xlWFtSg5ol7Q1aDPX+AcU8ZnM X-Gm-Gg: AYBFou1ZVEmtFobF/1Ikyw/BzBYS7PLrcN7yWMPSsk/VuXlBmPaSZl3+ut0FJ8yCGDz /Cfcx4Y0RhNGJt9d+kSqxm4mlHNGuspwhl34bJXoTWFIWKJVdDHC1defmxpUftiIdeLp3BkID3R p7FNVh+/RJgXpzYmsJ8a1MmFuM6uc66DojL3DOMgkKnXF7ZBgfubfXu8ZjUtIgV3jmLXb2fTqiq QIH0zjpFssLXNp22hdLJUT6EDmiG9sfH/TPv0ivkdWAhMKfYFad30CXWLqK8TA92OSOq9m80dud JyOm02dw1NlEB4WxZmW6ySp9FCur2LAjc4fNUCtGup9Ao4qTwyOFSfZH3wGc0yGubtWDX86UZHS 8bf4P1xKDg11d7+pnwBjr29JJ9vUVWChvAzpxxxNNF9ED90Pd2U4/19gUFGQ7kvbJHxK9Tot+PY TbsLRIR71JiVlXCk8qFHaHDf6YkuA/9N65by3ptCrQWPiF8de7T1sa2rn+VQEN5qnQjPYFSaStR PP9dKYyE60+p468bxV0A8vhdkNOC98WRX/UCtICp01jVKEuDgdqf2I9aOVl23vYQSxCm8vSC3g5 4bIWfjA= X-Received: by 2002:a05:6122:4004:b0:5ea:7126:38a7 with SMTP id 71dfb90a1353d-5eaaa62c43cmr2437882e0c.13.1792440421005; Mon, 19 Oct 2026 13:07:01 -0700 (PDT) Received: from MaquinaLab.. ([179.179.244.163]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5ea9b4776b5sm10451611e0c.3.2026.10.19.13.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 13:07:00 -0700 (PDT) From: Vinicius Pedrosa To: linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andriy.shevchenko@linux.intel.com, ilpo.jarvinen@linux.intel.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Andre Przywara , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Enzo Adriano Subject: [PATCH v2 2/4] serial: 8250_dw: Only accept a contiguous DLF readback Date: Mon, 19 Oct 2026 17:06:11 -0300 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [4.81 / 15.00]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[dt]; FREEMAIL_CC(0.00)[linuxfoundation.org,kernel.org,linux.intel.com,vger.kernel.org,lists.linux.dev,arm.com,gmail.com,sholland.org]; FORGED_SENDER_MAILLIST(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[arm.com:email,sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; RCPT_COUNT_TWELVE(0.00)[16]; RCVD_COUNT_FIVE(0.00)[6]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; TAGGED_FROM(0.00)[bounces-26750-noreply=patchwork.local]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[209.85.221.179:received,100.77.114.92:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; FROM_NEQ_ENVFROM(0.00)[viniciuseduardopedrosa@gmail.com,linux-sunxi@lists.linux.dev]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; RECEIVED_SPAMHAUS_PBL(0.00)[179.179.244.163:received]; MID_RHS_MATCH_FROM(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: D2F771C219B X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= dw8250_setup_port() writes all ones to offset 0xc0 and treats any nonzero readback as the DLF register. DLF is a bit field starting at bit 0, so a real one reads back as a contiguous 2^n - 1 mask. On some Allwinner SoCs offset 0xc0 is the RS485 control register instead (UART_485_CTL in the A733 User Manual), whose implemented bits are not contiguous. The probe still takes its readback for a DLF of fls(readback) bits, and every later divisor change writes the fractional divisor into the RS485 control register. Only accept a readback of the form 2^n - 1. The probe itself is unchanged: it still writes all ones to offset 0xc0 and then restores the old value, so this only changes how the readback is interpreted. The A733 reads back 0x19f, and Andre Przywara observed 0x9f on the A523. Without this check the A733 RS485 control register reads 0xb after boot; with it, the register stays 0 across 300 termios toggle and restore cycles. Suggested-by: Andre Przywara Signed-off-by: Vinicius Pedrosa --- drivers/tty/serial/8250/8250_dwlib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c index 325793f20256..1b0192efe162 100644 --- a/drivers/tty/serial/8250/8250_dwlib.c +++ b/drivers/tty/serial/8250/8250_dwlib.c @@ -225,7 +225,11 @@ void dw8250_setup_port(struct uart_port *p) reg = dw8250_readl_ext(p, DW_UART_DLF); dw8250_writel_ext(p, DW_UART_DLF, old_dlf); - if (reg) { + /* + * DLF is a bit field starting at bit 0, so a real one reads back as + * 2^n - 1. Any other value means this offset is something else. + */ + if (reg && !(reg & (reg + 1))) { pd->dlf_size = fls(reg); p->get_divisor = dw8250_get_divisor; /* Keep a hook the driver has already installed */