Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2974465pxb; Tue, 19 Jan 2021 10:21:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzX3PTEJ2QHNGPWY2evs8c3jBGDLEIh42eLZpYDNUnAw2mOdvqyzlqVvNZitOUJWvV4770U X-Received: by 2002:a17:906:6087:: with SMTP id t7mr3921967ejj.90.1611080467777; Tue, 19 Jan 2021 10:21:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611080467; cv=none; d=google.com; s=arc-20160816; b=ZZdvjxOGeyxcDOHvXNPr9cGsPRougHyHP90kj9FYJE8tl7LnWk/G9F9qwd1IhBSgTD r3VNeuGj+g9IIwX//4+VdGxjKpBkMi+HZEC0kKvbvYJItLGc0k8xF7U2SDdtvO7PRLXA YcNT9AB5sk6y3Bib/QcqgCP0FxQFLX2zd/XjHBBfMDjOaZwJICuvyLW8CrOVO1rLjFxh luCNsdWsr8hf3spm40FQGqDtWpx3uZs8FobCy7qAkymOq9Z8sM6WDRXvUclUmZvmkT6a yrruKjrfHDzPUJdFbD7IRZo78hU/8T3PxFmJuLsQ1f8QcVczNefNLtp/XcGWbgyMOg6L 2GbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=yO2k+wmEJJ8xH/LdKcVR5jElonjFD3LzbOdCVG89a24=; b=D53+UbsqAmVu47zFQBhXMbnWi0QFmmnsIT20Ouh/T0fOqbPLQ9QRjH8s7/4GJbcLQG LyZYHgbrQVfw9Ldk7lUqLfeHixg1r6ZwJRTR4r5AvpUWO/NcVFtHTd2Gg2MNxj6YF4MP a5PePckurpkQBJZNffFYENyNRzeez6bl+tjsJlToCOtHf2W+wLuR4I1FC5QYOmgvGGhZ cvCaPWk2pnrxhalHxot4Hu/+W+QH9VM3VVomfhFz/niv9bBYJu/C3o2JZ+HpBmpt9QLi Ej4DPorKEJTmRYP31DtcxQlyi0VeAdsVQW7kH71ZX8LuiCjFTLMjn5Gwiw7SUDnO7mOg W8BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JuAp4fE1; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn18si3885575edb.342.2021.01.19.10.20.43; Tue, 19 Jan 2021 10:21:07 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=JuAp4fE1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392457AbhASSRv (ORCPT + 99 others); Tue, 19 Jan 2021 13:17:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392438AbhASSQw (ORCPT ); Tue, 19 Jan 2021 13:16:52 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2379BC0617A0; Tue, 19 Jan 2021 10:16:20 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id q4so10974493plr.7; Tue, 19 Jan 2021 10:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=yO2k+wmEJJ8xH/LdKcVR5jElonjFD3LzbOdCVG89a24=; b=JuAp4fE1Om8r2jXXlMjO5EQi5ELsiLrAOz/7Zy1G6MLGJZu8BbcFwCxCtNHSUrn1jj MmAgtIXKIPipjExj1ugO237PHHtr7KE34SawUz5NB/gwppYKIcabT5jjH6rEn489hG83 Twr9iCkqfYBF6/5myQHtdrcFuDYyeMk+PZEoL1SnFS7OzMNVmYArnSDx6s+tCQlvDqCN 6xQVc4dtO2sI24n/ZN3pbXuADpSQFPslbOAnByTeZLqLeijMXFupmKD0uTal0iwxDJsM DGSJKnbxDZGnib4SEKELE+G0FY2R3UdBGwyAV22p7zhKnNuggW5IsRdFUN4vGoctgcKS TMQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yO2k+wmEJJ8xH/LdKcVR5jElonjFD3LzbOdCVG89a24=; b=tvVZ+XiEXpmPnk5Xv6+ARucPt2VssILU20tFcZnxgztVo8YnyrJgTTJium7SNiPUvv cpQXA94wI2FKsjWeH+AI2HXEIA13EAh/zj0v1aohnTn14OXv5euGo/ERDdwqNY2kexx+ Nb4UMA/dE9bmCUNkB8IraVHsADkjALmQXPHsVRSJC9Ohhi6a+VkNactrieV0sf6muj/c YPJ23quoq5nRiaEwPUzSNAq+kLiRJtP1FkPYhXjtdRmk2r+ZY+x2aTZlXUJWyhk0yRpg /MzrfI354q3zujLa3YoTsqgyoibehQeitReyZA5FXaUy0p7GyzbHZPO3NqTn7g6cY3Hd a+Vg== X-Gm-Message-State: AOAM531mlBd/ZobnFJoqllNfH9i9Xs0QWK6CuxF0fQIY+20IxmNSoQni wp3TEJHQYQki4vkbpQFKb+80kjJcOZE= X-Received: by 2002:a17:90b:4d09:: with SMTP id mw9mr990860pjb.199.1611080179615; Tue, 19 Jan 2021 10:16:19 -0800 (PST) Received: from [10.230.29.29] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id k128sm8187958pfd.137.2021.01.19.10.16.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Jan 2021 10:16:18 -0800 (PST) Subject: Re: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver To: Andy Shevchenko , Al Cooper Cc: Linux Kernel Mailing List , bcm-kernel-feedback-list , devicetree , Greg Kroah-Hartman , Jiri Slaby , "open list:SERIAL DRIVERS" , USB , Masahiro Yamada , Rob Herring References: <20210115211543.33563-1-alcooperx@gmail.com> <20210115211543.33563-3-alcooperx@gmail.com> From: Florian Fainelli Message-ID: <71d58a3e-2707-69d7-8074-c67235912e06@gmail.com> Date: Tue, 19 Jan 2021 10:16:16 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/19/2021 7:21 AM, Andy Shevchenko wrote: > On Fri, Jan 15, 2021 at 11:19 PM Al Cooper wrote: >> >> Add a UART driver for the new Broadcom 8250 based STB UART. The new >> UART is backward compatible with the standard 8250, but has some >> additional features. The new features include a high accuracy baud >> rate clock system and DMA support. >> >> The driver will use the new optional BAUD MUX clock to select the best >> one of the four master clocks (81MHz, 108MHz, 64MHz and 48MHz) to feed >> the baud rate selection logic for any requested baud rate. This allows >> for more accurate BAUD rates when high speed baud rates are selected. >> >> The driver will use the new UART DMA hardware if the UART DMA registers >> are specified in Device Tree "reg" property. The DMA functionality can >> be disabled on kernel boot with the argument: >> "8250_bcm7271.disable_dma=Y". >> >> The driver also set the UPSTAT_AUTOCTS flag when hardware flow control >> is enabled. This flag is needed for UARTs that don't assert a CTS >> changed interrupt when CTS changes and AFE (Hardware Flow Control) is >> enabled. >> >> The driver also contains a workaround for a bug in the Synopsis 8250 >> core. The problem is that at high baud rates, the RX partial FIFO >> timeout interrupt can occur but there is no RX data (DR not set in >> the LSR register). In this case the driver will not read the Receive >> Buffer Register, which clears the interrupt, and the system will get >> continuous UART interrupts until the next RX character arrives. The >> fix originally suggested by Synopsis was to read the Receive Buffer >> Register and discard the character when the DR bit in the LSR was >> not set, to clear the interrupt. The problem was that occasionally >> a character would arrive just after the DR bit check and a valid >> character would be discarded. The fix that was added will clear >> receive interrupts to stop the interrupt, deassert RTS to insure >> that no new data can arrive, wait for 1.5 character times for the >> sender to react to RTS and then check for data and either do a dummy >> read or a valid read. Sysfs error counters were also added and were >> used to help create test software that would cause the error condition. >> The counters can be found at: >> /sys/devices/platform/rdb/*serial/rx_bad_timeout_late_char >> /sys/devices/platform/rdb/*serial/rx_bad_timeout_no_char > > Brief looking into the code raises several questions: > - is it driver from the last decade? Work on this driver started back in 2018, that was indeed the last decade. > - why it's not using what kernel provides? > - we have a lot of nice helpers: > - DMA Engine API Not sure this makes sense, given that the DMA hardware that was added to this UART block is only used by the UART block and no other pieces of HW in the system, nor will they ever be. Not sure it makes sense to pay the cost of an extra indirection and subsystem unless there are at least two consumers of that DMA hardware to warrant modeling it after a dmaengine driver. I also remember that Al researched before whether 8250_dma.c could work, and came to the conclusion that it would not, but I will let him comment on the specifics. > - BIT() and GENMASK() macros > - tons of different helpers like regmap API (if you wish to dump > registers via debugfs) > > Can you shrink this driver by 20-30% (I truly believe it's possible) > and split DMA driver to drivers/dma (which may already have something > similar there)? See previous response. -- Florian