From patchwork Mon Dec 11 17:13:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 176821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7205616vqy; Mon, 11 Dec 2023 09:14:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkNJvZzneSxhexp1yeqMz9Cx+iSLFSvKYLm3rkC6W3epMJwBf8/0k30HDhBvLn1GZLK6Dr X-Received: by 2002:a17:90a:ad01:b0:286:d59b:5921 with SMTP id r1-20020a17090aad0100b00286d59b5921mr1989561pjq.29.1702314881017; Mon, 11 Dec 2023 09:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702314881; cv=none; d=google.com; s=arc-20160816; b=kY3bKjD7GRYwYrZGEWcOBjrAoZ/TlR6hGYtDDou9kBqr40ol5rfCxgMxh+3/fdQOsN Cq+/yOKvuSFx9FHxzO6fm3OObVlgtaYPtOzm3pFIqVXHeeXJ5p39mQJ1k24YJtgFqwf3 Vg6kY6XLG9P6ZybHkAk2nXHrRn0d/wMOjdreKlylsGTCBtrtYRJQ6qYKYanlsxUQ0b7T GawG8Ic3rTjJlcNh9riXgmv9A+MslZTHpJOqMVSNMiJU8qvXa2/6+KMhNhsRCYHZ8y1A h0ilZ1IbkWzfY9+kKoL6etF9XCdY5Mr49MMmGeOGy86uz61jYxMaBvJMmCPEwE9sQauz Gnmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=xxIt/w1kc+j/AwMPEIjsWTLQoLPMTkOHcLF8iblisas=; fh=Qi6QlO2FjtC4agQOlKQZuiYC/gSB+DjbcPQ9tqrzTiE=; b=JJeNYkQ3O6j8rcrkWK2DPkhW2djtX7S08j28qaELLHEiKvIkdnZS/vyt8ALWds1pPl +rzPsrh0acdvr7keydlYDTxi/8bClCVdcbOOGIBdYTDhyx6A57zIAVOn1AmLSm68eg+9 aUI9E/rTB902YAzHqsMwPcFWJn6tZvtqPQY0T4CdiTnOSHG1tOmWdKOM7ImF7PET+atM 1JoPdTe9dFuU5lzYpECefES+kv5ZUtMAqJuvDgJbZRV7Z9w4n0UOAm0U8Jsqwog04l2X KkcZtrCfmrDQ4ZSXUGmIG20COzj7LtHvDGq3YhPsAegdp7dutPwnkrxq+CfnCyubdDmx UbHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=pxwSLNoU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bf20-20020a17090b0b1400b0028a2944a218si372698pjb.111.2023.12.11.09.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 09:14:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=pxwSLNoU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 836EE809F883; Mon, 11 Dec 2023 09:14:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344540AbjLKROJ (ORCPT + 99 others); Mon, 11 Dec 2023 12:14:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235001AbjLKROF (ORCPT ); Mon, 11 Dec 2023 12:14:05 -0500 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5228DD8; Mon, 11 Dec 2023 09:14:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=xxIt/w1kc+j/AwMPEIjsWTLQoLPMTkOHcLF8iblisas=; b=pxwSLNoUqThTKTrGXJRiPaeGmT YsUZWVzdEWmYYGfbrY93lHLxnEwdQ4zRfW7wQgCe1tBDiFB1F0QX1JyQfQP1JD99qGydJQfVYrSxd EL2LmerRK0FBckjjMkFDDUwcb/rFYK+70QjFVyCLs2hEn0JkbzCAsJlO7b2IhfEwz9W0=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:56730 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rCjr3-0003yC-T8; Mon, 11 Dec 2023 12:14:06 -0500 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org, hvilleneuve@dimonoff.com, jringle@gridpoint.com, tomasz.mon@camlingroup.com Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, stable@vger.kernel.org Date: Mon, 11 Dec 2023 12:13:52 -0500 Message-Id: <20231211171353.2901416-6-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231211171353.2901416-1-hugo@hugovil.com> References: <20231211171353.2901416-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 Subject: [PATCH v2 5/6] serial: sc16is7xx: convert from _raw_ to _noinc_ regmap functions for FIFO X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 11 Dec 2023 09:14:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785006528630103506 X-GMAIL-MSGID: 1785006528630103506 From: Hugo Villeneuve The SC16IS7XX IC supports a burst mode to access the FIFOs where the initial register address is sent ($00), followed by all the FIFO data without having to resend the register address each time. In this mode, the IC doesn't increment the register address for each R/W byte. The regmap_raw_read() and regmap_raw_write() are functions which can perform IO over multiple registers. They are currently used to read/write from/to the FIFO, and although they operate correctly in this burst mode on the SPI bus, they would corrupt the regmap cache if it was not disabled manually. The reason is that when the R/W size is more than 1 byte, these functions assume that the register address is incremented and handle the cache accordingly. Convert FIFO R/W functions to use the regmap _noinc_ versions in order to remove the manual cache control which was a workaround when using the _raw_ versions. FIFO registers are properly declared as volatile so cache will not be used/updated for FIFO accesses. Fixes: dfeae619d781 ("serial: sc16is7xx") Cc: stable@vger.kernel.org Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 0bda9b74d096..7e4b9b52841d 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -381,9 +381,7 @@ static void sc16is7xx_fifo_read(struct uart_port *port, unsigned int rxlen) struct sc16is7xx_port *s = dev_get_drvdata(port->dev); struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); - regcache_cache_bypass(one->regmap, true); - regmap_raw_read(one->regmap, SC16IS7XX_RHR_REG, s->buf, rxlen); - regcache_cache_bypass(one->regmap, false); + regmap_noinc_read(one->regmap, SC16IS7XX_RHR_REG, s->buf, rxlen); } static void sc16is7xx_fifo_write(struct uart_port *port, u8 to_send) @@ -398,9 +396,7 @@ static void sc16is7xx_fifo_write(struct uart_port *port, u8 to_send) if (unlikely(!to_send)) return; - regcache_cache_bypass(one->regmap, true); - regmap_raw_write(one->regmap, SC16IS7XX_THR_REG, s->buf, to_send); - regcache_cache_bypass(one->regmap, false); + regmap_noinc_write(one->regmap, SC16IS7XX_THR_REG, s->buf, to_send); } static void sc16is7xx_port_update(struct uart_port *port, u8 reg, @@ -492,6 +488,11 @@ static bool sc16is7xx_regmap_precious(struct device *dev, unsigned int reg) return false; } +static bool sc16is7xx_regmap_noinc(struct device *dev, unsigned int reg) +{ + return reg == SC16IS7XX_RHR_REG; +} + static int sc16is7xx_set_baud(struct uart_port *port, int baud) { struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); @@ -1709,6 +1710,10 @@ static struct regmap_config regcfg = { .cache_type = REGCACHE_RBTREE, .volatile_reg = sc16is7xx_regmap_volatile, .precious_reg = sc16is7xx_regmap_precious, + .writeable_noinc_reg = sc16is7xx_regmap_noinc, + .readable_noinc_reg = sc16is7xx_regmap_noinc, + .max_raw_read = SC16IS7XX_FIFO_SIZE, + .max_raw_write = SC16IS7XX_FIFO_SIZE, .max_register = SC16IS7XX_EFCR_REG, };