Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5551570rwd; Mon, 5 Jun 2023 05:30:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zB06Wt60u2KXNJA9FjgssM4Xnsb9eJ5RoRBgx5/s8odqRmZQI3UGV60wi/3r5t48N4zlY X-Received: by 2002:a05:6a00:148b:b0:64f:aea5:7b49 with SMTP id v11-20020a056a00148b00b0064faea57b49mr15054913pfu.17.1685968217902; Mon, 05 Jun 2023 05:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685968217; cv=none; d=google.com; s=arc-20160816; b=iAJDYNmIUvEnnI48E3Ln/NRR192mRvmwqNs0Smzdk5d171fHS7R6jcu5lJ70pTWH7E W1VkgVnqxHvRR2WfFAWzbU5KdvrAZ2JfOlJi26c6/uI6OQHSKEvtShN8XqklyEZabFYm Qr6cp4Kg+1NZzM/HUwUXdcUE22thiSWSU3Y69/ievv+HKTLkbp8VMz1/5rdz2Ftt02WG Gul++z0TJ0N8xQiCTx991+Yiqn8XO7UR0FfdmIWPFaY2Q9oNgbYWrhNDNgr3i5+wa+ff EgLBKbHPBmNkquX2O2lMcLQU8C8M2fGwHbr222qwDLx1ICGEPrUneEnouy6FrFS1Vju5 +UsA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=wn7yobGIB2xPqyYn6rYO7VrD19g9B4rrMjHusD1goP4=; b=XtBSQvIOdqYIP8eLzqDGLltJNz7c43d/byjALZPohrXsTVNui/UsyWrImVj/eVdRZF e9stnd6/KGyZil56ipY1wqH7wlDtXEpMvABUDAchR9YNzTLwpM66cz2hGZU2eKPm0cBf N5VJRfInLlH4LX9ZJpXKB3hqnrvTeC3sXujsV1NIW3F1mZCVVN0JmIDwcUGTTv1N2Nii UmU5KqOy7RnusjRV1pjY5Jyd3eTbM9KDuDGGniYSybR2D9SThHH9ozxRjulvWJ7nb+kn McvROJKVEKdgBesW7hg7N5rsQ97tMnNZx3+7/AW8TQB0+HrNQBA0wl0J2zSCpKrPioWM /O3g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a656a8e000000b005303a7ca051si5365868pgu.284.2023.06.05.05.30.05; Mon, 05 Jun 2023 05:30:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233171AbjFEMYz (ORCPT + 99 others); Mon, 5 Jun 2023 08:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233438AbjFEMYv (ORCPT ); Mon, 5 Jun 2023 08:24:51 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED0AEBD; Mon, 5 Jun 2023 05:24:49 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 31DB880FE; Mon, 5 Jun 2023 12:24:49 +0000 (UTC) Date: Mon, 5 Jun 2023 15:24:47 +0300 From: Tony Lindgren To: Chen-Yu Tsai Cc: John Ogness , Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko , Dhruva Gole , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-omap@vger.kernel.org, Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, =?utf-8?B?TsOtY29sYXMgRi4gUi4gQS4=?= Prado , AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org Subject: Re: [PATCH v12 1/1] serial: core: Start managing serial controllers to enable runtime PM Message-ID: <20230605122447.GY14287@atomide.com> References: <20230525113034.46880-1-tony@atomide.com> <20230602083335.GA181647@google.com> <87a5xii33r.fsf@jogness.linutronix.de> <20230603054139.GR14287@atomide.com> <20230603063533.GS14287@atomide.com> <20230605061511.GW14287@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 * Chen-Yu Tsai [230605 11:34]: > On Mon, Jun 5, 2023 at 2:15 PM Tony Lindgren wrote: > > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c > > --- a/drivers/tty/serial/8250/8250_mtk.c > > +++ b/drivers/tty/serial/8250/8250_mtk.c > > @@ -425,11 +439,10 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, > > static int __maybe_unused mtk8250_runtime_suspend(struct device *dev) > > { > > struct mtk8250_data *data = dev_get_drvdata(dev); > > - struct uart_8250_port *up = serial8250_get_port(data->line); > > > > /* wait until UART in idle status */ > > while > > - (serial_in(up, MTK_UART_DEBUG0)); > > + (mtk8250_read(data, MTK_UART_DEBUG0)); > > I believe it still gets stuck here sometimes. Hmm so maybe you need to mtk8250_write(data, 0, MTK_UART_RATE_FIX) in probe before pm_runtime_resume_and_get() that enables the baud clock? That's something I changed, so maybe it messes up things. Looking at the 8250_mtk git log, it's runtime PM functions seem to only currently manage the baud clock so register access should be doable without runtime PM resume? > With your earlier patch, it could get through registering the port, and > the console would show > > 11002000.serial: ttyS0 at MMIO 0x11002000 (irq = 240, base_baud = > 1625000) is a ST16650V2 > > for the console UART. OK > Angelo mentioned that we should be using SLEEP_REQ/SLEEP_ACK registers > in the MTK UART hardware. > > I tried reworking it into your patch here, but it causes issues with the > UART-based Bluetooth on one of my devices. After the UART runtime suspends > and resumes, something is off and causes the transfers during Bluetooth > init to become corrupt. > > I'll try some more stuff, but the existing code seems timing dependent. > If I add too many printk statements to the runtime suspend/resume > callbacks, things seem to work. One time I even ended up with broken > UARTs but otherwise booted up the system. Well another thing that now changes is that we now runtime suspend the port at the end of the probe. What the 8250_mtk probe was doing earlier it was leaving the port baud clock enabled, but runtime PM disabled until mtk8250_do_pm() I guess. Regards, Tony