Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2429280rdb; Wed, 4 Oct 2023 00:14:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4T/KmnS213XFTlaBs6PxOgNB2+WKKoiQP30hGt0jXAYfSSU31xoDBl4Ves0bqI8zz6Fro X-Received: by 2002:a05:6a20:a110:b0:15f:16f5:8595 with SMTP id q16-20020a056a20a11000b0015f16f58595mr1668289pzk.52.1696403687669; Wed, 04 Oct 2023 00:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696403687; cv=none; d=google.com; s=arc-20160816; b=egl7hGz0ddXkbrVnH1WC2KGzSLe+HPPwacSRMqmhxSJa/qkSiAE61wSxWunSoZbnUX lcU+x4tiYMll32ZZgnL3OqXH/3oP2hywaOXv/8n38q8es4MBLne2aRf2XsJ5c5c04TQE 2JlrXs7jouGuzZ00aVVmxf94uKUqCx8Lm048JkhMfpavZOVyhq1hqW25t9jT51toJJro X+gSPVaXGS7IyYCJomffc6/TbUnzUKpFYSSdKs8Y4oTY8+XjzLTI1UAAMC1bllLL5rJi LFlP+VzZAZge50iGCi5pQ/qZwlwJx+/YhlhZ+yr9Yl5t+bWu/XMw9o/EAK2bedyXuR98 cNQA== 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:dkim-signature; bh=5FV1qZ2cj2fIAfsE86kX9rw0KGNfRtaaaTnPt4mY+EY=; fh=bQqN4VYJbnCrQjf2QiFNhI3AMs+PkZ86XIaN2k0jgVQ=; b=GZbWvELs0SooW6ZiMhQ/Mu5I7+WL8Gfx4AdMFLEeLi79yCr6N9EP7GIdeYuorPX99U 8WdB1itRw9vX8CNFmwP0772ennz+rGzPFhYIActswf3Ka9xobY5P/YazmR3AIwQ80Mgq VVeTCAwgDxckfiLRYzdAofDnxqZoqtzFLAqwfJw9I9XiKMVT1B3LjtRPdRD3VUNko1x0 030Ui/cnZz8HhpEK3AGtJl7SKD2Dpx8K6B6aI5RNlMqKOKCbw6seU+s+d0s/9h5+Ud0P Em8U5lo9qCv680eXMw4hiH69yBmDEz6gkOEcgqOSNNK4qP/eH7iDBBqjIPPOx5glv7t4 KObg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bmzeidEz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id kh6-20020a170903064600b001c342073f76si2925901plb.323.2023.10.04.00.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 00:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bmzeidEz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 929E8832D71C; Wed, 4 Oct 2023 00:14:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241376AbjJDHOq (ORCPT + 99 others); Wed, 4 Oct 2023 03:14:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbjJDHOp (ORCPT ); Wed, 4 Oct 2023 03:14:45 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 284F2AC; Wed, 4 Oct 2023 00:14:42 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B85A1C433C8; Wed, 4 Oct 2023 07:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696403681; bh=m/p7K2IFOIG74E7oqwH/WUHUmY/+kpgIUGYxIeReDzg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bmzeidEz6oct6O0sOTET90kRCSuaFqJwEDgllPvzjDUGhuboeanV/feQg0Q/iWJCv bypM0eZECkZcEGFL9wENMgyrMUkfXE/sVAKGlxcnClDsmHiFTIeHpVmMwPGZdZfeaG CuefXGfLSNmuT0lAiuE4k9e+P/Lq2sYWD1Wc0KZDqqZzhHP82E8PstP2Fl4x4dfnWi ipYhYTaI32aAUNDuyeFdbj6JbzQeUsuIv8v85iDbcfyEv8rvgUfRfLMFdsapGiHuGF 8bviCT1Kn0qJ7xRcY2myuK8CTPxxkjmCloZwl8HGkZwAuexigzk4mPeTlDT6wmoNBD s5Uwoua4DFeoA== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qnw5t-0000QG-22; Wed, 04 Oct 2023 09:14:53 +0200 Date: Wed, 4 Oct 2023 09:14:53 +0200 From: Johan Hovold To: Tony Lindgren Cc: Maximilian Luz , Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko , Dhruva Gole , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , John Ogness , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-omap@vger.kernel.org, Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH v12 1/1] serial: core: Start managing serial controllers to enable runtime PM Message-ID: References: <20230525113034.46880-1-tony@atomide.com> <62d3678a-a23d-4619-95de-145026629ba8@gmail.com> <20231003121455.GB34982@atomide.com> <20231003122137.GC34982@atomide.com> <20231004061708.GD34982@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231004061708.GD34982@atomide.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 00:14:46 -0700 (PDT) On Wed, Oct 04, 2023 at 09:17:08AM +0300, Tony Lindgren wrote: > * Maximilian Luz [231003 22:09]: > > Unfortunately that doesn't quite line up with what I can see on v6.5.5. The > > serdev controller seems to be a child of dw-apb-uart.4, a platform device. The > > serial-base and serdev devices are siblings. According to sysfs: > > > > /sys/bus/platform/devices/dw-apb-uart.4 > > ├── driver -> ../../../../bus/platform/drivers/dw-apb-uart > > ├── subsystem -> ../../../../bus/platform > > │ > > ├── dw-apb-uart.4:0 > > │ ├── driver -> ../../../../../bus/serial-base/drivers/ctrl > > │ ├── subsystem -> ../../../../../bus/serial-base > > │ │ > > │ └── dw-apb-uart.4:0.0 > > │ ├── driver -> ../../../../../../bus/serial-base/drivers/port > > │ └── subsystem -> ../../../../../../bus/serial-base > > │ > > └── serial0 > > ├── subsystem -> ../../../../../bus/serial > > │ > > └── serial0-0 > > ├── driver -> ../../../../../../bus/serial/drivers/surface_serial_hub > > └── subsystem -> ../../../../../../bus/serial > > The hierachy above is correct. Looks like I pasted the wrong device above, > I meant dw-apb-uart.4, sorry about the extra confusion added. Eventually > the serdev device could be a child of dw-apb-uart.4:0.0 at some point as > it's specific to a serial port instance, but for now that should not be > needed. > > If serial0-0 is runtime PM active, then dw-apb-uart.4 is runtime PM active > also unless ingore_children is set. > > > Runtime suspend on serial0-0 is disabled/not set up at all. So I assume that if > > it were a descendent of dw-apb-uart.4:0.0, things should have worked > > out-of-the-box. > > Hmm yes so maybe the issue is not with surface_serial_hub, but with serial > port device being nable to resume after __device_suspend_late() has > disabled runtime PM like you've been saying. > > If the issue is with the serial port not being able to runtime resume, then > the patch below should help. Care to give it a try? > 8< ------------------ > diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_port.c > --- a/drivers/tty/serial/serial_port.c > +++ b/drivers/tty/serial/serial_port.c > @@ -46,8 +46,27 @@ static int serial_port_runtime_resume(struct device *dev) > return 0; > } > > -static DEFINE_RUNTIME_DEV_PM_OPS(serial_port_pm, > - NULL, serial_port_runtime_resume, NULL); > +/* > + * Allow serdev devices to talk to hardware during system suspend. > + * Assumes the serial port hardware controller device driver calls > + * pm_runtime_force_suspend() and pm_runtime_force_resume() for > + * system suspend as needed. > + */ > +static int serial_port_prepare(struct device *dev) > +{ > + return pm_runtime_resume_and_get(dev); > +} > + > +static void serial_port_complete(struct device *dev) > +{ > + pm_runtime_put_sync(dev); > +} > + > +static const struct dev_pm_ops __maybe_unused serial_port_pm = { > + SET_RUNTIME_PM_OPS(NULL, serial_port_runtime_resume, NULL) > + .prepare = serial_port_prepare, > + .complete = serial_port_complete, > +}; > > static int serial_port_probe(struct device *dev) > { Just a drive-by comment: The above looks like a too big of a hammer and the wrong place to fix this. The serdev runtime PM implementation is supposed to just work for serdev drivers that do not want to use it, and otherwise those drivers manage the runtime PM state of the serdev (serial) controller directly (e.g. see c3bf40ce2c20 ("serdev: add controller runtime PM support")). Without having time to look at this regression (or the rework) in detail, it seems like the serial core rework has broken the serdev runtime PM implementation if the serial controller is now suspended without the serdev driver having asked for it. The pm_runtime_get_sync() in serdev_device_open() is supposed to prevent that from happening by default and if that now longer works, then that needs to be fixed. Johan