From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795448988; b=M17r7zRmdHA1X7FtcVwPD68kn1NFbUZtToeKQC7UaMx7V2uXK1u4Z5BUgbpBEbz6HGTi vNJU4qtbeXCS9djP2TC4jCw/yXhm3jJLNHRmLqPf3db7w2XZnQ/3XtQVKsmwTNC4FgO73 S36KHrrRa7/1gNXAruxSuD2ebvstozX2vBgB9k5CxR+olUwt8ogK16dpRn+DxXgE3nzBP KMgFOg0SDuIA3gqGb0u3I8Dz359kwHAa1x8IoofSSWEu9dVHsGABs1txloIMicYFsvE17 /DcBBUI6Q6JZukDX6cN8ugLC+5zYClV0uoczhR6YPh0h25QPrb1flTgPHXHaI74ti4Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795448988; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=ampCWU9YaRxYyU/2VqzGl7j5fZT5bJdrecIR7kU5Uc4=; b=uswjC0ghfYNDujRzXbNPWAkQmNKFZYOFYcMy4MiBFNa3iC1Kk5hNNGkpBEC2MUEfbqj9 nI2o5XkVRnFDBNRe96Cyr/0IeK40jxcMhPljX58nd8P6IrpKP2Zg91s03WYdYdNFGICPA EDbA+Sm0jkGkTDku1kWlWXlIR45J0heKxnxc9EJXjkeoStu4PrRRs5xXU079WA3Y5Zl1X dIrvU5hzjDRtlqUD311cJH/lW+PTS/ET86YNUpi4kNDa0yzlUqVTtoqwPO55zYPqZ3IpO kzzLuVMjSaUcyuAzlXnJzDu9PAcTBLjrQt1xkwfwAPY7F8QfxfW6Z45Eb10uUqE6Yfw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--praan.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SpWPTY4F; arc=none smtp.remote-ip=209.85.215.199 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AE52606A31E for ; Mon, 23 Nov 2026 15:49:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0AE52606A31E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--praan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SpWPTY4F Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cd5ca3840c5so3628098a12.2 for ; Mon, 23 Nov 2026 07:49:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795448987; x=1796053787; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ampCWU9YaRxYyU/2VqzGl7j5fZT5bJdrecIR7kU5Uc4=; b=SpWPTY4F85dNRzaA70ukgpGaruaayL5uwoejzjZXWeXrnVdALfaRO9aeIHNqKdfqcx UlZg3TElsIYRS+zI8Zsn1EHYrbHlgCqvWTrrScw5fOC6CCLpgPTtQI1IIG6IwmJCuptO vl7LsV5z5YCefT7j4obKQu7iD4hfW1MxwRD5ir3drwQTnMnyKE47c3nNuAo0aI/3n3ye 8B5Xee+dry5LT748usG9YjeBrYdEVOKVApf11uKwxNMZ/xY80b6XPUL6ulA39k7Ht2vL 53oltTwnRiR2qoeri0py6WEat7ZQosCwfVcql7+EqnAAOvYgQY9tPKbG7MGGZBS+QfLI DQWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795448987; x=1796053787; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ampCWU9YaRxYyU/2VqzGl7j5fZT5bJdrecIR7kU5Uc4=; b=oy2djIq1CxQr4WZJ0uX+r5BBQrJd2b/H8+4XO7gaqQ8aURhDVpp1zFDZDv+6pwvSVK fj2mD/ib633+qQjJI2aN1PJDopMg6E6AllSBtePSNKFVbQrhLsOyYKZcfDXV78+SDvW9 /eHfPHYKsZIOdKyQHjbTZLfbaEgfRv4ihgmYcdhNPOCQstU3Wp+ZdPOEPJos3Ox3aCmE 9jhBHFIIpb1cWFGnAVvJXbfflo4g644TwkMJeLCXCvr3M7zgyOzzMO0b0bJFP2kMBDAe jN5wVTwfjxt7v32tAuO+RfR6aZ89U4vPePSDUxVOhfmEp1tYkJTseSPLJp6ahBfV+5+J 36Gw== X-Forwarded-Encrypted: i=1; AL+hErHYFY6JIBaHWtEsHl7eIyhqxemkk4y+PUKhfwuNT/8fOYAbDOcNkeBj0jqcIzoih8sD1E7M24iGg+QSkS8=@vger.kernel.org X-Gm-Message-State: APuU4Z+scMmrtsqv8GiLS0rkSGSGFUWCLJtRI0+bFwCFydhrzFTUKDlx Vc8zOJD/DugjLp386a/a+28IV9uwhfYmewafMLvF2+F+S5IMoswt/xQAUa1/8w+/3mINE/KD95/ dFw== X-Received: from pfbfd26.prod.google.com ([2002:a05:6a00:2e9a:b0:8a0:70d8:a2ef]) (user=praan job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:218b:b0:3f8:f0b1:e7c0 with SMTP id adf61e73a8af0-4014da5fc3emr11235211637.59.1795448987022; Mon, 23 Nov 2026 07:49:47 -0800 (PST) Date: Mon, 23 Nov 2026 15:49:45 +0000 In-Reply-To: <20261118101913.3135869-3-amitamishra@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261118101913.3135869-3-amitamishra@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261123154945.3083888-1-praan@google.com> Subject: Re: [PATCH 2/2] perf/smmuv3: Add runtime PM support From: Pranjal Shrivastava To: amitamishra@google.com Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, krzk+dt@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mark.rutland@arm.com, robh@kernel.org, robin.murphy@arm.com, will@kernel.org, iommu@lists.linux.dev, smostafa@google.com Content-Type: text/plain; charset="UTF-8" On Wed, Nov 18, 2026 at 10:19:13AM +0000, Amita Mishra wrote: Hi Amita, +iommu@lists.linux.dev Please CC the iommu list as well. > On SoCs where an SMMUv3 PMCG resides in a switchable power domain, > probing the PMCG attaches and powers on the domain, but without runtime > PM support the domain remains permanently powered on even when no perf > events are active. I'm interested to know which PMCGs are these? Upstream arm-smmu-v3 doesn't have runtime PM yet, thus, a PMCG that shares its SMMU's power domain gains nothing from this today: the SMMU keeps the domain on anyway With my arm-smmu-v3 runtime PM series [1], the SMMU lets go of the domain once it has no active clients, and then a PMCG without runtime PM would be the one keeping it on, the two series seem to fit together. For TBU PMCGs in a subsystem's domain this matters either way. I'm wondering if you have PMCGs in power-domains that are neither tied to the SMMU power-domain and nor it's clients' power-domain? (That'd be a bit odd but possible). [...] > + /* The same condition smmu_pmu_probe() enables runtime PM on. */ > + if (dev->pm_domain) { > + int ret = pm_runtime_resume_and_get(dev); > + > + if (ret < 0) > + return ret; > + event->destroy = smmu_pmu_event_destroy; > } This keeps the domain powered for as long as the event exists, even while it is disabled or not scheduled. I'd be surprised if the production devices that use runtime PM keep a PMCG event open requiring this? For a PMCG in the SMMU's domain, with [1] that means a perf event keeps the domain on while the SMMU itself is suspended (SMMUEN=0, GBPA=Abort). The SMMU only suspends once all its clients are idle, so apart from cycles there's nothing meaningful to count. For a TBU PMCG, it keeps the subsystem's domain powered, which changes what's being measured: the TBU's TLBs and config caches survive what would otherwise be power-offs, so tlb_miss and config_cache_miss can under-report compared to the unmonitored system. Which makes me question whether the PMCG needs runtime PM at all. It's a profiling tool, and I'd be surprised if production devices that use runtime PM keep PMCG events open. Without events nothing needs the PMCG powered, so all this buys is not pinning the domain while the driver is probed but unused.. Do you probe the PMCGs on production devices? If they're only used for profiling and not in-field, not loading the driver there (or leaving the node disabled) avoids the problem without runtime PM in the driver. If we do need it, a couple of issues with the implementation below: [...] > @@ -975,15 +1040,45 @@ static void smmu_pmu_remove(struct platform_device *pdev) > > perf_pmu_unregister(&smmu_pmu->pmu); > cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node); > + if (pdev->dev.pm_domain) > + pm_runtime_disable(&pdev->dev); > } Events hold a module reference and bind/unbind is suppressed, so this only runs with no events, i.e. normally with the PMCG runtime-suspended. devres then frees the IRQ: free_irq() -> msi_domain_deactivate() -> smmu_pmu_write_msi_msg() writes to the unpowered PMCG, since the PM domain is only detached after devres in device_unbind_cleanup(). Wired interrupts are fine, and the CPU hotplug path Sashiko mentioned shouldn't rewrite the message with a GICv3 ITS parent, so in practice this is MSIs plus module unload. With the MSI message cached by the core (see below), smmu_pmu_write_msi_msg() could simply skip the MMIO while the PMCG is suspended and leave it to resume. Note it would have to check pm_runtime_status_suspended(), since runtime PM is already disabled by the time devres runs. Alternatively, keep the PMCG resumed across the devres teardown. [...] > +static int smmu_pmu_runtime_resume(struct device *dev) > +{ > + struct smmu_pmu *smmu_pmu = dev_get_drvdata(dev); > + > + smmu_pmu_reset(smmu_pmu); > + return 0; > +} Sashiko flagged this too: after a power-off the IRQ configuration is gone, and smmu_pmu_reset() doesn't put it back. With MSIs, overflow interrupts stop arriving and counters wrap unnoticed. With a wired interrupt on an MSI-capable PMCG, IRQ_CFG0 comes back UNKNOWN, so an overflow can send an MSI write to a garbage address, which is exactly why probe clears it. This is the same problem I had to solve for the SMMU in [1]: patches 7-8 make the genirq/msi core cache the message in irq_chip_write_msi_msg() and add msi_device_domain_restore_msi_msgs(), and arm_smmu_resume_msis() in patch 9 clears the IRQ_CFG0 registers and then calls it (a no-op for wired IRQs). The PMCG resume needs the same: writeq_relaxed(0, smmu_pmu->reg_base + SMMU_PMCG_IRQ_CFG0); msi_device_domain_restore_msi_msgs(dev, MSI_DEFAULT_DOMAIN); Minor: an autosuspend delay would avoid powering the domain on and off for every event open/close. Thanks, Praan [1] https://lore.kernel.org/all/20260929034510.2023173-1-praan@google.com/