From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 9881F404BCF for ; Tue, 14 Jul 2026 08:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784018206; cv=none; b=B0B9lIJ0Tbp9YgeWhks6MAunQX41yp/jYRxll63I0K9595YTv8IA3eCBOnJ3lUS3J+g8+NvWIufAVzv/Jia/YzwEDuV6/zQjLCDnQ581TufvAPGSGF828GYrqbDMp0MvOPtD+xIYD+W3hfLANQLGmPC3UV6ZFHaVdfG4tNoYRfE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784018206; c=relaxed/simple; bh=NQOBvsBZy+DfNF/ir0u60/1P4/x/thiv2MfnshEydEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZWs0eLCMEjIF21aJAro8/0xaz1hXumfKKu6t1eoXeyGtru1cgmgewPVh81HYj+sfFe3LWkYjvyGGJSVr5htMTEDoUh8ac+DexdBO70GcqxyfCCMJGn8bQZqIE7De0PnAvtxBdshNhAJJxMs7/t0w3KKt99SXbvEL8ARxptTAXHc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=JO9bniXT; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="JO9bniXT" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-c9c26a5fb98so490313a12.0 for ; Tue, 14 Jul 2026 01:36:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1784018191; x=1784622991; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Wk16cXvhCfpgFzGrnK8+fTVVUodSt/9s9ecoWwXHbTE=; b=JO9bniXT42olQJBdED1FaHLj4PcFDwIiPUvfzXRo532an6/cwWY1gQyc/hr8l4Dr+N 64O7Fq5JZhJGNDQJQC0UyZqn1jILfyLB2T/4CMVFOVei5px54ppuq5FKXtRltFPuMBfu R/7kWElHZcbOh0l6qC6U7HZoqtChrXBFd/iQrdh0OIwZQ6IpjyFyK86I3tkQrQYTZAH7 oDGUg+lUFF9gAhh9bzSHR4dJfNvud1Id2qxMWBSLWEdjWQczy6BBGzplr0fRssrxf5LD 5tvxgra33aIggXLoJbeMxuYZCt+lF7IwFG62K3tWrf14U7qHkKfaEU1hBWx1hwOKYLaT dT4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784018191; x=1784622991; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Wk16cXvhCfpgFzGrnK8+fTVVUodSt/9s9ecoWwXHbTE=; b=MmyDeeFQJuHk8hVssJ6xM+i0q3RBtzfPHbDHpcBzZbi0R+S5FEG821sT53X8kCPb2/ PL5UQu8HPMUK6uRIduDhIcy0Jjeew0/yQ0inHyrpiObV3SxJIn4sElrEA1cEbKF70Jps gUl1uvqRu1WyQ82AWOLekanhlVeXw/RDvn15Zuz/mQ8pnvu8vXSHf/3haDUFeuil7M8v dZmtqdi5jeQTFVMWoWDcDvgReP2GPyqaTz4ut4cB+/CaxL9WKWRhspxHaqALDtXPygnS KTmuOwGqlGZYSNpp06mahD4vylYOTry5FUq+/aBrXorExPro+d6/nuQxTKpHMuKacYxo b0yw== X-Forwarded-Encrypted: i=1; AHgh+RqGsc0BXLuwtATw3gadg15u31f7gJOWXc2tzxqbUoAueXIvjKIKUeRRtE3bhvvA02yXSB7tWog1lFvIlu8=@vger.kernel.org X-Gm-Message-State: AOJu0YxwbOgLGlZb47w7vWtfLxgYnyyTFQJFhVqN52m+CmsgpKDJtGRf 5N44a2HKPg4LBeeimq1Ci8Rem+C63jruS8nec5OlROphsLwjlmtFD7ep5pf/CnZ91HQ= X-Gm-Gg: AfdE7ckKQDC1CQ6wUaf84ToUUzR6+IeNdJ0rTUjhQCTrHv5bEioamLay8iT/DkITUKo gZqAm4pwL/C/L6RYH08GwcZye9wn3/ftcTwP5yabHCLBHUOrQWWvuH4IbjV2XsktMutlZEEsKfB pwk4wKokNheHHXyPFro9sPGVxLCWYwtOfmo+2uiJfRf93gA80Eo6N0L9+TW2itwY2fjCa81a02r s/hIs2g4hiLgF+wfAPLNcEie/0zU1MN/y+7FMLUlNsiK/F/oJuBH3SzIp/QKVdBxmqSKLSbpSUZ qaFXPWOOvvI94dzh22D/8t3qrsxMpPH7qa2hnB7xITbnsBeDoey+QcUMtFiHIA2r4hOxVKBUt3Y NpzWltDhHUkaL6cdFgLqEntD1cm4aaI9UT1rk/RD69b2kiKViXv8gvUhEKvqyogBQ5+Jajkgj8a w5ELfabCZnzJHh+OD15MFsn0nF X-Received: by 2002:a05:6a21:511:b0:3b3:3852:6663 with SMTP id adf61e73a8af0-3c0f0ae8f4amr19643932637.24.1784018191116; Tue, 14 Jul 2026 01:36:31 -0700 (PDT) Received: from sw04.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311950eb930sm55932938eec.8.2026.07.14.01.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 01:36:30 -0700 (PDT) From: Zong Li To: tjeznach@rivosinc.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, mark.rutland@arm.com, andrew.jones@oss.qualcomm.com, guoren@kernel.org, david.laight.linux@gmail.com, zhangzhanpeng.jasper@bytedance.com, iommu@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Zong Li , Samuel Holland Subject: [PATCH v4 2/2] iommu/riscv: create a auxiliary device for HPM Date: Tue, 14 Jul 2026 01:36:22 -0700 Message-ID: <20260714083625.1083606-3-zong.li@sifive.com> X-Mailer: git-send-email @GIT_VERSION@ In-Reply-To: <20260714083625.1083606-1-zong.li@sifive.com> References: <20260714083625.1083606-1-zong.li@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Create an auxiliary device for HPM when the IOMMU supports a hardware performance monitor. Use the physical address of the device directory table as the unique ID for auxiliary device in each IOMMU instance Reviewed-by: Guo Ren Suggested-by: Samuel Holland Signed-off-by: Zong Li --- drivers/iommu/riscv/Kconfig | 1 + drivers/iommu/riscv/iommu.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/iommu/riscv/Kconfig b/drivers/iommu/riscv/Kconfig index b86e5ab94183..8025bf0fb67f 100644 --- a/drivers/iommu/riscv/Kconfig +++ b/drivers/iommu/riscv/Kconfig @@ -10,6 +10,7 @@ config RISCV_IOMMU select GENERIC_PT select IOMMU_PT select IOMMU_PT_RISCV64 + select AUXILIARY_BUS help Support for implementations of the RISC-V IOMMU architecture that complements the RISC-V MMU capabilities, providing similar address diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c index cec3ddd7ab10..186c22c3ea6c 100644 --- a/drivers/iommu/riscv/iommu.c +++ b/drivers/iommu/riscv/iommu.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -565,6 +566,21 @@ static irqreturn_t riscv_iommu_fltq_process(int irq, void *data) return IRQ_HANDLED; } +/* + * IOMMU Hardware performance monitor + */ +static int riscv_iommu_hpm_enable(struct riscv_iommu_device *iommu) +{ + struct auxiliary_device *auxdev; + + auxdev = __devm_auxiliary_device_create(iommu->dev, KBUILD_MODNAME, + "pmu", iommu, iommu->ddt_phys); + if (!auxdev) + return -ENODEV; + + return 0; +} + /* Lookup and initialize device context info structure. */ static struct riscv_iommu_dc *riscv_iommu_get_dc(struct riscv_iommu_device *iommu, unsigned int devid) @@ -1613,6 +1629,9 @@ int riscv_iommu_init(struct riscv_iommu_device *iommu) goto err_remove_sysfs; } + if (iommu->caps & RISCV_IOMMU_CAPABILITIES_HPM) + riscv_iommu_hpm_enable(iommu); + return 0; err_remove_sysfs: -- 2.43.7