From patchwork Sun Nov 26 16:04:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamshi Gajjela X-Patchwork-Id: 169886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp2552821vqx; Sun, 26 Nov 2023 08:04:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaxLMyRCkFX8tdyDZN5IFbIr+WYgIk8S69we+7X8RBSogm2vozf/eRb2GAf3uV4QcnwWYs X-Received: by 2002:a05:6830:1018:b0:6d8:69c:e814 with SMTP id a24-20020a056830101800b006d8069ce814mr9898662otp.19.1701014686549; Sun, 26 Nov 2023 08:04:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701014686; cv=none; d=google.com; s=arc-20160816; b=fdQHVW89Af3X+L0gQUEqu/QKGeH1xvY83t+6XSl0gr859FqL4kDyDmr7c2K6sFf1i0 U/36rSXG4mwLI3iIGVLrY+fk7svbtcxgkFG6Fm6dPkjfeFG15khlS39NOUBmoUMJNWsT gD7ES/3nK1/zqyM6zb/Zn9hrebvwbIr07sHWi/Wy5AoytRYkOx3dA3iSyp+R6Z7mCccu MVz1tG9PLp0nx0RjeSIyIx+oUjwvMPx3hir5eEykFlDNIs0dl6fXHKg3MUmcQDBl65/h NrdxZIK4snu18Ccap5gsxiUhMhBC/O8ycexzi1012a7H2Wu44WSaOgcqZBsHYzn9bUNh TviA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=jAcVnKA6iADA9vLnhJjfNDjx1x+ezMFBfqAWXzVOUug=; fh=qWAsb2aA8VxByy8KpZXa/ZtLPC0GsHYLARU0woA8UyQ=; b=awM+laK8MG0TMTy5+lySC4ZfIB2AVKJfAYJHnEL/9D64YnPNU2GTKN4vMQDsKJKPy8 PIPSYtqnh2kNlrG258+8eBu5Wahy3k+fqvoN4dCkGOzsCudqU8xM+ob2gQD8zPcFOl6O /3C4c8g4e2CDXRuBSMdMLNdrzhGuaFjOaf/uyltDqcSdI+XAVxo0Kkeisvsq6xBl456/ LMbUD1p/GDkCZQcPElTu6P6NzQrtCXTjXRDxK1wiH612QQb1geLy4wTAc0cW4g3bkjhw E9VA6OP3O/JTgdbsWahK1nRJ2b6wZmSC0tsp3L2mnsy/qSRJ/Pa0iiMsgjmRUZvJ9DCc LSZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qxpCeGJL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id i13-20020a9d624d000000b006ce37c0aa86si2806609otk.298.2023.11.26.08.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 08:04:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qxpCeGJL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 04603807121A; Sun, 26 Nov 2023 08:04:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbjKZQEW (ORCPT + 99 others); Sun, 26 Nov 2023 11:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjKZQEV (ORCPT ); Sun, 26 Nov 2023 11:04:21 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9471CFB for ; Sun, 26 Nov 2023 08:04:27 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5cd6a86a898so37062127b3.3 for ; Sun, 26 Nov 2023 08:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701014667; x=1701619467; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=jAcVnKA6iADA9vLnhJjfNDjx1x+ezMFBfqAWXzVOUug=; b=qxpCeGJLfF1BCtxowMWAsfvRVIv/6qZrnIrK/Xl5809mDWHNzkIX7uE999sOckKP79 DN2Purd3BvPqXnrl6nFdfvZ6cWbSFnbAzz6T1SLRYaOqrv/LSKAdNO2Z7SqVe5aN8KEO TWLG6Wo0k4O7deHKhrgrhWmdq65QJwd0Kqotz6lDgxZXs4dwrDRierRwYIQNEGQGInuq YGYjpssDOzVLRN7U1LYM0ZRfIZiYLQbu8jAtqoc2qFzaG7+oOTdSYNIseyyqLUlxvZfr TjvQOSxdZ1hxh9pznfRok2ZZ65iTbpznhZ4QTcKvo0Pjjbja3Ivzolj9OI87B0yP4coL GU/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701014667; x=1701619467; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jAcVnKA6iADA9vLnhJjfNDjx1x+ezMFBfqAWXzVOUug=; b=gO1IV91rzMwwcLzNkc8lw49IorDDZZk5MYvGTbdHcqMTPJ+3IToPmU8QLTfmd7rv7y BTOjSuX/dW4ajbRDKoG3Wl6F89JbvnXCJvk65DoQ+l1D3hpFsoscp5AwqXz0UdviLQbN ZGOLzjyfgZUEfeRUHr1XH4pEAI1AuQ6JkjIWXVMVTGkIQFQ5ymJ4AWxluhh3zdgxSq3i leWJZUXyCyihQeWscUkGYU/YribbKDQKVI9VOBAQZI5iTANz/H2OTv9gYcqeeVoiO5U/ K5TW6TahVN5Z8lYLitbub55VVKHWW1Oc2lmJT6SRfoRRY6o1s37twLKKDoJhGj3/jqK4 0XKQ== X-Gm-Message-State: AOJu0YxazooANWB8jxiRc7K9qP7ful+PwnMKUwCOoHUHp+if2arInxyU X8aYRwqJIY5JlP6FDBsRjZ1ZdipKddodk8bOoXd7 X-Received: from vamshig51.c.googlers.com ([fda3:e722:ac3:cc00:3:22c1:c0a8:70c]) (user=vamshigajjela job=sendgmr) by 2002:a81:9b10:0:b0:5ca:5fcd:7063 with SMTP id s16-20020a819b10000000b005ca5fcd7063mr318515ywg.3.1701014666758; Sun, 26 Nov 2023 08:04:26 -0800 (PST) Date: Sun, 26 Nov 2023 21:34:20 +0530 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Message-ID: <20231126160420.2442330-1-vamshigajjela@google.com> Subject: [PATCH] serial: 8250_dw: Decouple DLF register check from UCV From: Vamshi Gajjela To: Jiri Slaby , ilpo.jarvinen@linux.intel.com, Andy Shevchenko Cc: Greg Kroah-Hartman , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, Subhash Jadavani , Vamshi Gajjela X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Sun, 26 Nov 2023 08:04:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783643175668996049 X-GMAIL-MSGID: 1783643175668996049 Designware UART has an optional feature to enable Fractional Baud Rate Divisor (DLF) through the FRACTIONAL_BAUD_DIVISOR_EN configuration parameter, and it is not dependent on ADDITIONAL_FEATURES. dw8250_setup_port() checks DLF to determine dlf_size only when UART Component Version (UCV) is non-zero. As mentioned above DLF and UCV are independent features. Move the logic corresponding to DLF size calculation ahead of the UCV check to prevent early return. Otherwise, dlf_size will be zero and driver will not be able to use the controller's fractional baud rate divisor (DLF) feature. Signed-off-by: Vamshi Gajjela --- drivers/tty/serial/8250/8250_dwlib.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c index 84843e204a5e..136ad093c5b6 100644 --- a/drivers/tty/serial/8250/8250_dwlib.c +++ b/drivers/tty/serial/8250/8250_dwlib.c @@ -259,17 +259,6 @@ void dw8250_setup_port(struct uart_port *p) } up->capabilities |= UART_CAP_NOTEMT; - /* - * If the Component Version Register returns zero, we know that - * ADDITIONAL_FEATURES are not enabled. No need to go any further. - */ - reg = dw8250_readl_ext(p, DW_UART_UCV); - if (!reg) - return; - - dev_dbg(p->dev, "Designware UART version %c.%c%c\n", - (reg >> 24) & 0xff, (reg >> 16) & 0xff, (reg >> 8) & 0xff); - /* Preserve value written by firmware or bootloader */ old_dlf = dw8250_readl_ext(p, DW_UART_DLF); dw8250_writel_ext(p, DW_UART_DLF, ~0U); @@ -282,6 +271,17 @@ void dw8250_setup_port(struct uart_port *p) p->set_divisor = dw8250_set_divisor; } + /* + * If the Component Version Register returns zero, we know that + * ADDITIONAL_FEATURES are not enabled. No need to go any further. + */ + reg = dw8250_readl_ext(p, DW_UART_UCV); + if (!reg) + return; + + dev_dbg(p->dev, "Designware UART version %c.%c%c\n", + (reg >> 24) & 0xff, (reg >> 16) & 0xff, (reg >> 8) & 0xff); + reg = dw8250_readl_ext(p, DW_UART_CPR); if (!reg) { reg = data->pdata->cpr_val;