Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1959299pxb; Thu, 11 Feb 2021 00:01:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8xnleGIg+8S+g6QcrO3wgV5meP+xoHqlLpbigpB4USuEDea1mp+MBhagOjr/iimlGiHZO X-Received: by 2002:a17:906:6b1b:: with SMTP id q27mr6897828ejr.508.1613030482994; Thu, 11 Feb 2021 00:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613030482; cv=none; d=google.com; s=arc-20160816; b=Xfka0MMJdC5cF0PTBwDkVMeIP9iB86W0lpzWOrgxeASLOjEOwxUZAbWLuALX6L3Zce pwEaEQNRtZa6N+IW2Oxt2q3TUpR/V2BDDGV/HOI2TgH9CcUIQGa7Cb1uHihSFjMsmJoc t1ITr1c6VgH2IJ9c4CvfV5IGe28yArou3fNL2HmVgjGPrjkG9gBbDOr2esH0H+5fNua+ w0Q6hn7QzgHil61nDT/+CR+lUNaOhsjivMd7nPuwmORMmiotayIgCT911ldxBDPjmaze WjK+8AIFvdJmygpzAyfzA5QKJuy3ZLQ6+pSDo3Bb93eG/3bIPMdnRS3cmmXMvzRaICAk dZcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=+y2ykRo35Ho1Ay2BjBPfbis5WVr8Yo45047sbXAu03U=; b=d0OYMfhoFQ0yKyesxCwNk5RwHUUW4x/EczWQ8UCp5VkYzuoWPat7sKkiQg+URKlbId NyOLNaD3kgd383qQurstjpMNGL/JMlocU0hCdlKJD/K/nfiITySSwbeBa/ju0iL3v5iH zCUxHs1JrKiVQtlW0b20+9cpOPmYAT0csrE1bqSqNE+4VWTZd7xiiFaj8Hc0f5gIPFqK CNZ/nYvXuHqjNOGdEQHPU/YK1O9CdrR51vmh1A/8t6jxf8ys+cQetT1CDAW1FcyKillQ AqY41m8Zr/WKiN0O04iCcIdNiMt2BUws7yECpujj/mi4HE2XNfxGQ64UP2on1dR688pi QxAA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb10si3084226ejc.75.2021.02.11.00.00.59; Thu, 11 Feb 2021 00:01:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229979AbhBKH5o (ORCPT + 99 others); Thu, 11 Feb 2021 02:57:44 -0500 Received: from mail-ot1-f48.google.com ([209.85.210.48]:41409 "EHLO mail-ot1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbhBKHzQ (ORCPT ); Thu, 11 Feb 2021 02:55:16 -0500 Received: by mail-ot1-f48.google.com with SMTP id s107so4369052otb.8; Wed, 10 Feb 2021 23:55:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+y2ykRo35Ho1Ay2BjBPfbis5WVr8Yo45047sbXAu03U=; b=NoZWoxODDM8XN2MeaY7pdhAM1vX6YtPM9qUWchjPVxU0pLKY6R8qLXy2UftHHocyHN 72KFdKV2EvaPdxGH0cjC3X1+C8bSOV+891yR/DygBawkR3b048Eib3ndzX/QNajjU93G cueYJNYZGnBrMjxnK0HYECTLp/q5Q2bpnUrTWqne+GDx7RlwgJWhiepAQsyKzFvrq2oA 4N3kx1n4FCnSRk6/XVH4AQ81jR8jH44IIX85bW5TXxqahvMaS+7ojZ0FvIYSM1tSUrY3 FHyuTzC/5zrxbbefPFdteASm+MEeqDvpcDBhfIa90zUD7bCnq4m0z9ykDRvSPslChG3R GXAw== X-Gm-Message-State: AOAM530Rc3cIj/DksDewsvbyr2kbnGox8x5J+vFKxwfri4OAvi15wKyZ 2BEhDuEttpCza/+fLXl2C5F5DO8z37j3ITwzKqZ3ZGqC X-Received: by 2002:a9d:77d6:: with SMTP id w22mr4966439otl.145.1613030118370; Wed, 10 Feb 2021 23:55:18 -0800 (PST) MIME-Version: 1.0 References: <17nqrn25-rp5s-4652-o5o1-72p2oprqpq90@onlyvoer.pbz> <30np982n-r2q8-8532-q6os-9p9729ppos45@syhkavp.arg> <61p41n8-r88q-9npq-879o-s4r5856os9s1@onlyvoer.pbz> <82qo9ooo-32q0-2r4r-26q-o8482651qr91@onlyvoer.pbz> <161301451636.1254594.7473642352348913785@swboyd.mtv.corp.google.com> In-Reply-To: <161301451636.1254594.7473642352348913785@swboyd.mtv.corp.google.com> From: Geert Uytterhoeven Date: Thu, 11 Feb 2021 08:55:07 +0100 Message-ID: Subject: Re: [PATCH v4] PM / clk: make PM clock layer compatible with clocks that must sleep To: Stephen Boyd Cc: Nicolas Pitre , "Rafael J. Wysocki" , Naresh Kamboju , "Rafael J. Wysocki" , Greg Kroah-Hartman , Michael Turquette , Russell King , Linux PM , linux-clk , Linux Kernel Mailing List , Mark Brown , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stephen, On Thu, Feb 11, 2021 at 4:35 AM Stephen Boyd wrote: > Quoting Nicolas Pitre (2021-01-25 11:29:18) > > The clock API splits its interface into sleepable ant atomic contexts: > > > > - clk_prepare/clk_unprepare for stuff that might sleep > > > > - clk_enable_clk_disable for anything that may be done in atomic context > > > > The code handling runtime PM for clocks only calls clk_disable() on > > suspend requests, and clk_enable on resume requests. This means that > > runtime PM with clock providers that only have the prepare/unprepare > > methods implemented is basically useless. > > > > Many clock implementations can't accommodate atomic contexts. This is > > often the case when communication with the clock happens through another > > subsystem like I2C or SCMI. > > > > Let's make the clock PM code useful with such clocks by safely invoking > > clk_prepare/clk_unprepare upon resume/suspend requests. Of course, when > > such clocks are registered with the PM layer then pm_runtime_irq_safe() > > can't be used, and neither pm_runtime_suspend() nor pm_runtime_resume() > > may be invoked in atomic context. > > > > For clocks that do implement the enable and disable methods then > > everything just works as before. > > > > A note on sparse: > > According to https://lwn.net/Articles/109066/ there are things > > that sparse can't cope with. In particular, pm_clk_op_lock() and > > pm_clk_op_unlock() may or may not lock/unlock psd->lock depending on > > some runtime condition. To work around that we tell it the lock is > > always untaken for the purpose of static analisys. > > > > Thanks to Naresh Kamboju for reporting issues with the initial patch. > > > > Signed-off-by: Nicolas Pitre > > Tested-by: Naresh Kamboju > > > > --- > > Thanks for doing this. I think it's the main reason why nobody uses the > PM clock code so far. "git grep pm_clk_add" tells you otherwise? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds