Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3359879rdb; Thu, 16 Nov 2023 07:34:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHq0512RDxzT7mWf7wHTabPNFiPLw068yTUD2nQBOKC57AIMWgDyvCq5rAvs1jo+dRi1sw X-Received: by 2002:a54:4689:0:b0:3b6:cbd1:beda with SMTP id k9-20020a544689000000b003b6cbd1bedamr16588722oic.39.1700148884204; Thu, 16 Nov 2023 07:34:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700148884; cv=none; d=google.com; s=arc-20160816; b=WafChDGQSF3mujvQaY0CeglLA6NjihVa73m36aUbeU3Oc8RQV6IL41qzz3LAI2MDPY ddMwLvRrUsae0U9EWbGCCZXkZ3Rae51GnyXs+pgWvm83/xomVDAFLFbfoo9MbVRH+M8l 832HyWTBmvmU+0SS/MnxkYa69K8enYHoGMFDxz9QVUHR0RXFVxjHEcGNS330TH8kkW+N ZWxgGi1cOHlO2fHIzhWciBysDU9Eq7RG1mR1WMjoRjigjh4R/Nl6oj9UloBpheNQnVeG TeyFmy+i4tFicJ1WQfYwvYIRcaLK6QA0oS3pTQILx4erTAko8QBEukkbmbjsSDuqWC+z HJ0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PVNPAkisoMvkTyEW/8SK0tYA7Rxlmav3LfVvFoFHM20=; fh=yPmiMEENpodNn06ZkL7zXqP0Q6NPi7l7foa2SzckG4c=; b=du0syl4PG+LS2uKFr7rOFNEqh3CU+FgG0j7D/O9L5gQyLmnKXv/7m0tjrovKAL6CHu CkpfPahmvA9SmSghvpxctB3cvdbejeglJbX33czjOB0fwz8gH3qQ8fjc+5f54bRwOj5w A1k8P6PzlWzQJpDfuqIBPYLAIf4OyUdT3GuGvh/fMQnm5R+JuANImk9WAEdvaMwpCBfx cHFK2eSRLshJrbwT4r9Y088geLEsXV1CmzeRrYpT+0HHS0oE92xBoN9lvIRWF0DwkR6Y /86x6NNcVvImADlQJ3ersaDntGG7FUNbzXiZz26ycHHtTczWuBw9CSZUf6tWhfAfz/iE Zxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TWBX3+dF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w34-20020a631622000000b005bdd9ef451bsi11964621pgl.874.2023.11.16.07.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 07:34:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TWBX3+dF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 9B37A80926BB; Thu, 16 Nov 2023 07:34:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230019AbjKPPef (ORCPT + 99 others); Thu, 16 Nov 2023 10:34:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbjKPPee (ORCPT ); Thu, 16 Nov 2023 10:34:34 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 851A4195 for ; Thu, 16 Nov 2023 07:34:30 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5446c9f3a77so1497221a12.0 for ; Thu, 16 Nov 2023 07:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700148869; x=1700753669; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PVNPAkisoMvkTyEW/8SK0tYA7Rxlmav3LfVvFoFHM20=; b=TWBX3+dFKB6YDGnBNNRGVJsl1S5ajnnZVcPODjnz5+0EnYsMt0l12mH9Pr+eRfXaS0 HJOSnoNEtSNYX5hMHEd6Hkg/3DuV0C8srrxjzV/FTQgS5Dz/y2RubeGZukn0i1cBTFws Gt1j26x+Jy21AAXtTqPE19RbWB9zCwjO9kwV45o69i09K2cIWi6/v2/DZw5Iz8CctgRK 1jkYg5QkuLlBQwplsYv4TMV7eXGY/i1Dmk11zB3bOUAcp/P4m7gpw5OLbHzmgXw6EbQN pb6P8b8pa3XWwdaApSx5oqk0UUmXGaVPLiu9+2NKkpZmo8VuR6kG8I9aJaRgzfASmL4q zmPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700148869; x=1700753669; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PVNPAkisoMvkTyEW/8SK0tYA7Rxlmav3LfVvFoFHM20=; b=LtvKY8YznVo5jODFLXaq2qqU3aFq4p+qcTLsK0wiw/3HKFW38wsSjjeW4q6N8StqIO bC934ZMsaWZj7VHS4sJMlMCUABCI+XJ9NlaPN6B9kBZi6sMRwFKZKmkLDCctOurJI23V iu3/3jyvrSRy4FrswfnUG80NCO2TU3Ot157NREohLoRPaJ6NUPobemiwC2vb64PA5F3A 8l3V0CMR4+1YLba08qwHFGhQJAyf2HoMDMBz52+tKXiQ15UgQ/xwly8omICYKOH+5G6A pcZC/MjXFlsTl4NbfqF6kUbCBFUxA2tToFf0B12MH/bd2TcnG0Yb0bctdAssfOiPwi1x Gi5g== X-Gm-Message-State: AOJu0YyTOoLUXeq/0yHyzqwWzwVhvTEKDq9THiE2/iVsBiGJANcHXnsQ /j35FMGtAPadNsK1xS2gchT/KbqDFAa8Qcbe1mzNqA== X-Received: by 2002:a17:906:2348:b0:9d0:51d4:4d87 with SMTP id m8-20020a170906234800b009d051d44d87mr12024787eja.62.1700148868828; Thu, 16 Nov 2023 07:34:28 -0800 (PST) MIME-Version: 1.0 References: <20231110102054.1393570-1-joychakr@google.com> In-Reply-To: From: Joy Chakraborty Date: Thu, 16 Nov 2023 21:04:15 +0530 Message-ID: Subject: Re: [RFC PATCH] PM: runtime: Apply pinctrl settings if defined To: andy.shevchenko@gmail.com Cc: Linus Walleij , Greg Kroah-Hartman , "Rafael J. Wysocki" , Pavel Machek , Len Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, manugautam@google.com, aniketmaurya@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 07:34:41 -0800 (PST) On Wed, Nov 15, 2023 at 7:21=E2=80=AFAM wrote: > > Tue, Nov 14, 2023 at 02:01:48PM +0100, Linus Walleij kirjoitti: > > On Fri, Nov 10, 2023 at 11:21=E2=80=AFAM Joy Chakraborty wrote: > > > > > Apply pinctrl state from runtime framework device state transtion. > > > > > > Pinctrl states if defined in DT are bookmarked in device structures > > > but they need to be explicitly applied from device driver callbacks > > > which is boiler plate code and also not present in many drivers. > > > > > > If there is a specific order of setting pinctrl state with other driv= er > > > actions then the device driver can choose to do it from its pm callba= cks, > > > in such a case this call will be a no-op from the pinctrl core framew= ork > > > since the desired pinctrl state would already be set. > > > > > > We could also add a Kconfig knob to enable/disable this, but I do not > > > see a need to. > > Besides questionable code style (inline functions in the C file)... Sure, I can change that. > > > It has a certain beauty to it does it not! > > > > The reason it wasn't done like this from the start was, if I recall cor= rectly, > > that in some cases a device needs to do the pin control state switching > > in a special sequence with other operations, that can not be reordered, > > i.e.: > > > > 1. The pin control state change is not context-free. > > > > 2. The order of events, i.e. context, does not necessarily match the > > order that Linux subsystems happen to do things. > > > > When looking through the kernel tree I don't see that people use > > the sleep state and idle state much, so we could very well go > > with this, and then expect people that need special-casing to name > > their states differently. > > > > What do people thing about that? > > ...I think the patch is incomplete(?) due to misterious ways of PM runtim= e > calls. For example, in some cases we force runtime PM during system suspe= nd > which may have an undesired effect of the switching pin control states > (hence glitches or some real issues with the hardware, up to hanging the > system). Some pins may be critical to work with and shuffling their state= s > in an unappropriate time can lead to a disaster. > > So, I would consider this change okay if and only if it will have a detai= led > research for all existing users to prove there will be no changes in the = whole > set of possible scenarious (of system sleep / resume, runtime, runtime wi= th a > custom ->prepare callback and so on). > I tried to place the calls to set the pinctrl states after driver/user callback based on my understanding of runtime code so that existing users do get a chance to set the state with any special sequence that needs to be performed post which doing another call to set the state would be ignored in the pinctrl framework. But this only would be possible with the assumption that even in any special sequences executed by users they set nothing but "default" state in runtime_resume, "idle" state in runtime_idle and "'sleep" state in their runtime suspend callbacks. And like Andy mentions about "->prepare callback", if there are drivers that are setting pinctrl state "default", "sleep" or "idle" from any callback but ... int (*runtime_suspend)(struct device *dev); int (*runtime_resume)(struct device *dev); int (*runtime_idle)(struct device *dev); ... it could indeed be a problem. I'll dig into users of pinctrl_select_sleep/default/idle and see if there are such cases or if it could be done in some other way. Thanks Joy > -- > With Best Regards, > Andy Shevchenko > >