Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp245264rdh; Wed, 7 Feb 2024 03:43:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/5zOlibcap1rfYDkpifaz6fyhmQNJsZtwC2xnOB2wlOG368JVS97FuRkuHypac5qG3xr8 X-Received: by 2002:ac8:6717:0:b0:42b:e7e0:b079 with SMTP id e23-20020ac86717000000b0042be7e0b079mr4750319qtp.17.1707306201517; Wed, 07 Feb 2024 03:43:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707306201; cv=pass; d=google.com; s=arc-20160816; b=dqcVJm4x33+19jbliJ+pgkwX15YA1/8c4xzbnduKZd3hKv2WZewJlB9Z2OC5Br9oZu CTAkCF3tpe5F5oJ3OfVgq6Kwb/BpIWlMnTTbfdSiAsy/0wwECNynBB+6SEAp/qQ1Eugz Hx9xFXT/1GNASWUZuvCVpoC9jVBi9AILIW0LL5Iglf0I0dwrjXDMh2Cmcr/89QNpyfwu 1mBWpO0yrkDb8ynVbBL7dsJk4p12RiiEKlr7tA8ejgiXhSaTdNEZAZmzRNXKmNvLHiES k4mUjkPaNCSkIHq/isepefDsWon5hBHmi22EWpxpDSfy+mW5KwH1C+dicnuFNUqNMMh5 ph/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=mDRI0QBrap0H2clNIo68wfgCeGsVyFFKlUnFyl+O8Oc=; fh=x2IFSY2Bb5HDgSKId1bt1CTtnNK2KnDpOUm17LMR6jM=; b=ttuqz32F5S0T20X39aRC3L9SA8mzMsaAeF3tBxe/HHrpyb/gRK+p+7CaOeY+KPIGau 0DexEDDRFebpPo1pzL21t8HU077IwLi9NjnWS1glUkYirwDerHaDqfROa4zcPNZUmLy6 xvtekSTOjWBH6OZcWMVuEc7qQn1g6Dus2t2k09CXhXplx7+zrQVwUJ/aPSO2OY2aQxkj TmJCMZNI6BC/pQ0ViFjg+tyirNsQX9xT+mHSfoj52fdSfmmw7DskGNjTpiEbFB0UgOZ/ KAMgN+BucwoMvCPzaIzG0iBUb3wLrbgdl5oQM+fNKmCkLhq/TVpo3ICWgNk4xFcd2QYx GdHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOzWSE12; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-56409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56409-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=2; AJvYcCV5OOdd2ZnHx7+Z4CSe+Vb+9ursF8r4Uwq5AKC/fHOuuhUH2lyLjs7v22+ZAfSAr4KCmLDRus9ORLTLcvZTNFBoPMKyqdLdiF5M4XfDrQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s26-20020a05622a1a9a00b0042c183180a6si929850qtc.715.2024.02.07.03.43.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 03:43:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOzWSE12; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-56409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56409-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 39DBF1C25DCC for ; Wed, 7 Feb 2024 11:43:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B6BB2420C; Wed, 7 Feb 2024 11:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QOzWSE12" Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com [209.85.222.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 360FA25639 for ; Wed, 7 Feb 2024 11:42:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707306138; cv=none; b=pGM22ubECkZqIRkPLLxvA2s/ntSS2Yn6mIApPpYUi5pQMJDbvb7A3hcSY18dWEb87hztREuA2V9PYFWfclXpKMjtOaS9ZMSW4Z9rOJAwUVsSJS2Br435QQS5kSI5mXTCCy73gVlchK4zV0jMZZyfhMm5hteydMHyIhBUrefnlAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707306138; c=relaxed/simple; bh=yXMP0S/lszIS82Cm3HVooHmFHezs5svv3J4mLhiJ6Bk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=AiY8fZBVZTv1ySBDlSAoaqMlnr1N9jo5OXfkDTwGtblDYt6igUcwSgeO9i/wu3U9rD+l8D9p1fwMflU4lmx7SKhqdjiV9dvKuQo3k4xUfI2IAAWJBJ7qCwrk4nfaxP1H8p7hMaP+R9IB6dl+mzw6f6FRiGoO0Yr0eaYiH0yXqGU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=QOzWSE12; arc=none smtp.client-ip=209.85.222.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ua1-f46.google.com with SMTP id a1e0cc1a2514c-7d5a6b1dd60so225126241.3 for ; Wed, 07 Feb 2024 03:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707306135; x=1707910935; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mDRI0QBrap0H2clNIo68wfgCeGsVyFFKlUnFyl+O8Oc=; b=QOzWSE12voIqeyO/a4pMbo0EmmfnQqAspa+MUnvkSVl+eNCu2cmoD8nK7SmRAOeu5M Wd/3Q3bw6x1Xrv3+Bx/Y/vCNzYzY9WmY3PSEMMT5HfAaqZ8/SzNpVIuQn87AgG30jmao egXjdJ2khLyXeF1uWiZ7uZ/OG+5Z8wsYHSG7h6IJTPQyHFH+gGKmlCLll+L+s+EUTG/u Xw/j0rD8mOY4bedHwxgHChVyHRyyTBrrIKGg5uUyg3ySs1FKHO87H20Lxt/ERqCw/0iR F0Flv+syVxiBX57frV5ItsLgcm92k9FvEY2F9wTAebJBGAapg/Krl1PjpiVeTRjlZWnw KVzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707306135; x=1707910935; h=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=mDRI0QBrap0H2clNIo68wfgCeGsVyFFKlUnFyl+O8Oc=; b=kEYEIJd1f52didWuGLr6J1sjwPJlT6Mtf/Q0CSoYMSlxYb5KPRi99sfYB1Pwy0YtL3 IsC3vPbrpv6k4SXGZXiIsoYILs8HM8cqURHlVDI4zAtxe27gHduuQ37Rti7cznYT9U/9 jIisZkVjtO1cfUXD9LCJwYqYUiQmeZr3dCV4XWlorO4S3v1xgcivrziCjoZzljI9Sk8S vJBZZ80YXKntu8E+b5j8DIBCq+Gif5SuizqTWa/uEZ34ks5DmGkqlNYygATDsoqpxr93 EHrTQtv2u9xJuY4p40ooOyxnJ76z4dwKnTNR8EG410UGzf9tlOZNurRtwBdhlDuGgUi9 cBNA== X-Gm-Message-State: AOJu0YyQbTlpbCykUcGRyI1qPLY5mm1IrjAquMkl5DvRGxMYkKIgg8bk qM4inWbytZvyBN564KNRYj02f09j1kBxDBHN+V/1rUZwpsBT/nlbMTzon9A94aTHlm3TwKPGaS3 5YnN7Mk1hBp5hnoOu94bZ02zhIFaecP4P8wkJuw== X-Received: by 2002:a05:6102:3231:b0:46d:1c65:bc13 with SMTP id x17-20020a056102323100b0046d1c65bc13mr2322228vsf.24.1707306134913; Wed, 07 Feb 2024 03:42:14 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240129211912.3068411-1-peter.griffin@linaro.org> <20240129211912.3068411-2-peter.griffin@linaro.org> <99828589-c0b5-456d-b250-6ad3e6085a91@linaro.org> In-Reply-To: <99828589-c0b5-456d-b250-6ad3e6085a91@linaro.org> From: Peter Griffin Date: Wed, 7 Feb 2024 11:42:03 +0000 Message-ID: Subject: Re: [PATCH v2 1/2] soc: samsung: exynos-pmu: Add regmap support for SoCs that protect PMU regs To: Krzysztof Kozlowski Cc: arnd@arndb.de, linux@roeck-us.net, wim@linux-watchdog.org, alim.akhtar@samsung.com, jaewon02.kim@samsung.com, semen.protsenko@linaro.org, kernel-team@android.com, tudor.ambarus@linaro.org, andre.draszik@linaro.org, saravanak@google.com, willmcvicker@google.com, linux-fsd@tesla.com, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Hi Krzysztof, Thanks for your review feedback. On Mon, 5 Feb 2024 at 13:13, Krzysztof Kozlowski wrote: > > On 01/02/2024 13:51, Peter Griffin wrote: > > Hi Krzysztof, > > > > On Tue, 30 Jan 2024 at 16:01, Krzysztof Kozlowski > > wrote: > >> > >> On 29/01/2024 22:19, Peter Griffin wrote: > >>> Some Exynos based SoCs like Tensor gs101 protect the PMU registers for > >>> security hardening reasons so that they are only accessible in el3 via an > >>> SMC call. > >>> > >>> As most Exynos drivers that need to write PMU registers currently obtain a > >>> regmap via syscon (phys, pinctrl, watchdog). Support for the above usecase > >>> is implemented in this driver using a custom regmap similar to syscon to > >>> handle the SMC call. Platforms that don't secure PMU registers, get a mmio > >>> regmap like before. As regmaps abstract out the underlying register access > >>> changes to the leaf drivers are minimal. > >>> > >>> A new API exynos_get_pmu_regmap_by_phandle() is provided for leaf drivers > >>> that currently use syscon_regmap_lookup_by_phandle(). This also handles > >>> deferred probing. > >>> > >>> Signed-off-by: Peter Griffin > >>> --- > >>> drivers/soc/samsung/exynos-pmu.c | 227 ++++++++++++++++++++++++- > >>> include/linux/soc/samsung/exynos-pmu.h | 10 ++ > >>> 2 files changed, 236 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c > >>> index 250537d7cfd6..7bcc144e53a2 100644 > >>> --- a/drivers/soc/samsung/exynos-pmu.c > >>> +++ b/drivers/soc/samsung/exynos-pmu.c > >>> @@ -5,6 +5,7 @@ > >>> // > >>> // Exynos - CPU PMU(Power Management Unit) support > >>> > >>> +#include > >>> #include > >>> #include > >>> #include > >>> @@ -12,20 +13,159 @@ > >>> #include > >>> #include > >>> #include > >>> +#include > >>> > >>> #include > >>> #include > >>> > >>> #include "exynos-pmu.h" > >>> > >>> +static struct platform_driver exynos_pmu_driver; > >> > >> I don't understand why do you need it. You can have only one > >> pmu_context. The moment you probe second one, previous becomes invalid. > >> > >> I guess you want to parse phandle and check if just in case if it points > >> to the right device, but still the original code is not ready for two > >> PMU devices. I say either this problem should be solved entirely, > >> allowing two devices, or just compare device node from phandle with > >> device node of exynos_pmu_context->dev and return -EINVAL on mismatches. > > > > Apologies I didn't answer your original question. This wasn't about > > having partial support for multiple pmu devices. It is being used by > > driver_find_device_by_of_node() in exynos_get_pmu_regmap_by_phandle() > > to determine that the exynos-pmu device has probed and therefore a > > pmu_context exists and a regmap has been created and can be returned > > to the caller (as opposed to doing a -EPROBE_DEFER). > > > > Is there some better/other API you recommend for this purpose? Just > > checking pmu_context directly seems racy, so I don't think we should > > do that. > > Hm, I don't quite get why you cannot use of_find_device_by_node()? of_find_device_by_node() returns a platform_device, even if the driver hasn't probed. Whereas driver_find_device_by_of_node() iterates devices bound to a driver. If using of_find_device_by_node() API I could check the result of platform_get_drvdata(), and -EPROBE_DEFER if NULL (that pattern seems to be used by a few drivers). But that AFAIK only guarantees you reached the platform_set_drvdata() call in your driver probe() function, not that it has completed. IMHO the drivers using driver_find_device_by_of_node() for probe deferral are doing it more robustly than those using of_find_device_by_node() and checking if platform_get_drvdata() is NULL. Or is there some other way you had in mind of using of_find_device_by_node() I've not thought of to implement this? Thanks, Peter.