Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6070939rwn; Mon, 12 Sep 2022 20:42:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ebAWNz+t8nSEmnlheQwC+plXr/KCy1wI9AgGn86i2h8eVwFK/zycFkSSgLPkiA2YY8Af7 X-Received: by 2002:a17:907:2ced:b0:773:6f77:f10f with SMTP id hz13-20020a1709072ced00b007736f77f10fmr17449390ejc.34.1663040556240; Mon, 12 Sep 2022 20:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663040556; cv=none; d=google.com; s=arc-20160816; b=GvmEmR6ZHRBq01qWVhvX05UWe6RVEgmsEgoU8U6cZxIhfLKNBgA0n7P6Jsecy7myS+ lOUwB3qIaLAmuSl3hKjaQOFq2206OGMlowwjJ1O2n0vh1hA25unhtwNmm3TwE8N0m08I CGIAki7g8H3FNKdy0WIhIgda7egonXQzXFP0nP9xkaE6/UZ2tJZXVI1I6WvLYoEL4SgS r1J5TcPpwKrLuZvYR5bxl+1R8+BfTN8DXoCUAQ25R1QTGF78eeCzsgonyttqJfhzcwRX 8/Z3Wguhec/ADel3xAT4VjsogjcZfJwOnXJ3+zZ2+lKJMqQzVhH1U0n15R11sX+ufYX/ 9F1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XGUSVb9lRhIh/HfatIul3qp9Jgraqbj052ofBRnNU+I=; b=fibJ5N1nLYIxkwhLJ8lhT6asGS2ExH4Xtr3dMmvSSXFlTqWMl7JGhnvCRmwMTmXX8w xKnA/Zw9jP6sCMtqnQm7c3zwa9i6YlvwSYjoH1JvFJl5op9xju5R80hsS45Me5s7jsiD H4XtKHw1tDEKbk6qBw+PQOl265CC7KpVDEg8GJpLfG56nlDenIn/WefebLeC8r53YLv0 vp/VEGnowZzG/2T+68GeyU6dySx+QB2DXpI7jb4MdYuz4T/pBmvmIUsKSQ1L/f7N/NTe 5phODvLJYUqUUV3v2oZRLCUjJqAmZ7zEj7vTo94gVIcbLV2Dd/y5Kv5Qa4CSbvfm8YpH S0eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="UfXYse/j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs37-20020a1709072d2500b0073beb58e98dsi10664785ejc.276.2022.09.12.20.42.11; Mon, 12 Sep 2022 20:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="UfXYse/j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230142AbiIMC6Q (ORCPT + 99 others); Mon, 12 Sep 2022 22:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230133AbiIMC6F (ORCPT ); Mon, 12 Sep 2022 22:58:05 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB1D352FF6; Mon, 12 Sep 2022 19:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663037883; x=1694573883; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Sp5gG4+b6ZZJ27Y2zvVjoqOFmRPQHUPIEcDl++tfFLY=; b=UfXYse/jCGmOGor0qaEKRlyZBlOgtWv/wPPO/vyFB/OEWw2a+f3qJTBS Skxr4l9zo4FO37ROH6fyp2TGXDaIjgelm9qz/hr3f9SGz5k+GxdjfJNWp L62bbIDB82ERbiLMheWu7shOOZoZ/Fur5s8dlOkH+j1XCAofplBq7YDER eDGdalp59CiarAsqFTV63dXjWEqisMm4UivrUMaNEDRz8S0dkKhwPair3 pZBIWZqNUvFPG+m5uTxKd870D1r5ADYb+sX7MULayB4VHjPdiY2n6miM+ A7UTqzQAlxVxdBwSd/tCPlQcnefOLTi77mRQ1iTk/8LuF4kZo1RxEowC0 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="359747665" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="359747665" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 19:57:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="646736842" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by orsmga008.jf.intel.com with ESMTP; 12 Sep 2022 19:57:54 -0700 Date: Tue, 13 Sep 2022 10:48:20 +0800 From: Xu Yilun To: matthew.gerlach@linux.intel.com Cc: hao.wu@intel.com, russell.h.weight@intel.com, basheer.ahmed.muddebihal@intel.com, trix@redhat.com, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, tianfei.zhang@intel.com, corbet@lwn.net, gregkh@linuxfoundation.org, linux-serial@vger.kernel.org, jirislaby@kernel.org, geert+renesas@glider.be, andriy.shevchenko@linux.intel.com, niklas.soderlund+renesas@ragnatech.se, phil.edworthy@renesas.com, macro@orcam.me.uk, johan@kernel.org, lukas@wunner.de Subject: Re: [PATCH v1 5/5] tty: serial: 8250: add DFL bus driver for Altera 16550. Message-ID: References: <20220906190426.3139760-1-matthew.gerlach@linux.intel.com> <20220906190426.3139760-6-matthew.gerlach@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-09-12 at 08:29:47 -0700, matthew.gerlach@linux.intel.com wrote: > > > On Sun, 11 Sep 2022, Xu Yilun wrote: > > > On 2022-09-06 at 12:04:26 -0700, matthew.gerlach@linux.intel.com wrote: > > > From: Matthew Gerlach > > > > > > Add a Device Feature List (DFL) bus driver for the Altera > > > 16550 implementation of UART. > > > > > > Signed-off-by: Matthew Gerlach > > > --- > > > drivers/tty/serial/8250/8250_dfl.c | 188 +++++++++++++++++++++++++++++ > > > drivers/tty/serial/8250/Kconfig | 9 ++ > > > drivers/tty/serial/8250/Makefile | 1 + > > > include/linux/dfl.h | 7 ++ > > > 4 files changed, 205 insertions(+) > > > create mode 100644 drivers/tty/serial/8250/8250_dfl.c > > > > > > diff --git a/drivers/tty/serial/8250/8250_dfl.c b/drivers/tty/serial/8250/8250_dfl.c > > > new file mode 100644 > > > index 000000000000..dcf6638a298c > > > --- /dev/null > > > +++ b/drivers/tty/serial/8250/8250_dfl.c > > > @@ -0,0 +1,188 @@ > > > +// SPDX-License-Identifier: GPL-2.0 > > > +/* > > > + * Driver for FPGA UART > > > + * > > > + * Copyright (C) 2022 Intel Corporation, Inc. > > > + * > > > + * Authors: > > > + * Ananda Ravuri > > > + * Matthew Gerlach > > > + */ > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > + > > > +struct dfl_uart { > > > + void __iomem *csr_base; > > > + u64 csr_addr; > > > + unsigned int csr_size; > > > + struct device *dev; > > > + u64 uart_clk; > > > + u64 fifo_len; > > > + unsigned int fifo_size; > > > + unsigned int reg_shift; > > > + unsigned int line; > > > +}; > > > + > > > +int feature_uart_walk(struct dfl_uart *dfluart, resource_size_t max) > > > +{ > > > + void __iomem *param_base; > > > + int off; > > > + u64 v; > > > + > > > + v = readq(dfluart->csr_base + DFHv1_CSR_ADDR); > > > + dfluart->csr_addr = FIELD_GET(DFHv1_CSR_ADDR_MASK, v); > > > + > > > + v = readq(dfluart->csr_base + DFHv1_CSR_SIZE_GRP); > > > + dfluart->csr_size = FIELD_GET(DFHv1_CSR_SIZE_GRP_SIZE, v); > > > > These are generic for DFHv1, so maybe we parse them in DFL generic code. > > I will look into moving this to the DFL generic code. > > > > > > + > > > + if (dfluart->csr_addr == 0 || dfluart->csr_size == 0) { > > > + dev_err(dfluart->dev, "FIXME bad dfh address and size\n"); > > > + return -EINVAL; > > > + } > > > + > > > + if (!FIELD_GET(DFHv1_CSR_SIZE_GRP_HAS_PARAMS, v)) { > > > + dev_err(dfluart->dev, "missing required parameters\n"); > > > + return -EINVAL; > > > + } > > > + > > > + param_base = dfluart->csr_base + DFHv1_PARAM_HDR; > > > > The same concern. > > > > > + > > > + off = dfl_find_param(param_base, max, DFHv1_PARAM_ID_CLK_FRQ); > > > + if (off < 0) { > > > + dev_err(dfluart->dev, "missing CLK_FRQ param\n"); > > > + return -EINVAL; > > > + } > > > + > > > + dfluart->uart_clk = readq(param_base + off + DFHv1_PARAM_DATA); > > > + dev_dbg(dfluart->dev, "UART_CLK_ID %llu Hz\n", dfluart->uart_clk); > > > > I see the DFHv1_PARAM_ID_CLK_FRQ defined in generic dfl.h, is this > > param definition global to all features, or specific to uart? > > Certainly uart drivers need to know the input clock frequency in order to > properly calculate baud rate dividers, but drivers for other features/IP > blocks may need to know the input clock frequency as well. On the other > hand not all drivers need to know the input clock frequency to the > feature/IP block. > > > > > Do we have clear definition of generic parameters vs feature specific > > parameters? > > I don't think there is a clear definition of generic versus feature > specific, but a clock frequency and interrupt information it fairly generic. > > > > > The concern here is to avoid duplicated parameter parsing for each driver. > > I understand the concern about avoiding duplicated parameter parsing. Yeah. Another concern is, reviewers from other domains have to look into every detail of the DFH param layout to know what happened, which I think is not that friendly. Thanks, Yilun