Re: [RFC PATCH 5/7] iommu/riscv: Expose global QoS IDs in sysfs
From: Zhanpeng Zhang
Date: Tue Aug 11 2026 - 22:38:55 EST
Hi Drew,
On 8/9/26 1:09 AM, Drew Fustini wrote:
> On Tue, Jul 14, 2026 at 09:06:55PM +0800, Zhanpeng Zhang wrote:
>> The RISC-V IOMMU QoS extension provides iommu_qosid as a per-IOMMU
>> global default tag. It is used for IOMMU-originated DDT, CQ, FQ, PQ, and
>> MSI accesses, and for device-originated requests when DDTP is in BARE
>> mode.
>>
>> Initialize iommu_qosid to RCID 0 and MCID 0 when the hardware advertises
>> QOSID support. Preserve reserved and WPRI bits with read-modify-write,
>> and use register readback to reject values which the WARL fields do not
>> retain.
>>
>> Add a qosid attribute to the RISC-V IOMMU class device. Reading returns
>> the current RCID and MCID values. Writing the documented
>> 'rcid=<rcid> mcid=<mcid>' form updates both fields while preserving the
>> other register bits.
>>
>> Keep this interface separate from resctrl group QoS. The sysfs attribute
>> controls the IOMMU-wide default, while resctrl device assignment programs
>> per-device DC.ta in translated modes.
>>
>> Signed-off-by: Zhanpeng Zhang <zhangzhanpeng.jasper@xxxxxxxxxxxxx>
>> ---
>> .../ABI/testing/sysfs-class-iommu-riscv-iommu | 27 +++
>> MAINTAINERS | 10 ++
>> drivers/iommu/riscv/iommu.c | 159 +++++++++++++++++-
>> drivers/iommu/riscv/iommu.h | 9 +-
>> 4 files changed, 202 insertions(+), 3 deletions(-)
>> create mode 100644 Documentation/ABI/testing/sysfs-class-iommu-riscv-iommu
>>
>> diff --git a/Documentation/ABI/testing/sysfs-class-iommu-riscv-iommu b/Documentation/ABI/testing/sysfs-class-iommu-riscv-iommu
>> new file mode 100644
>> index 000000000000..b0cd68997f17
>> --- /dev/null
>> +++ b/Documentation/ABI/testing/sysfs-class-iommu-riscv-iommu
>> @@ -0,0 +1,27 @@
>> +What: /sys/class/iommu/<iommu>/qosid
>> +Date: June 2026
>> +KernelVersion: 6.18
>> +Contact: Zhanpeng Zhang <zhangzhanpeng.jasper@xxxxxxxxxxxxx>
>> +Description:
>> + The RISC-V IOMMU global default QoS IDs for this IOMMU.
>> + The file is present only when the IOMMU reports the QOSID
>> + capability.
>> +
>> + Reading the file returns the RCID and MCID fields from the
>> + iommu_qosid register:
>> +
>> + rcid=<rcid> mcid=<mcid>
>> +
>> + Writing the file updates the RCID and MCID fields while
>> + preserving reserved/WPRI bits:
>> +
>> + rcid=<rcid> mcid=<mcid>
>
> I think it might fit sysfs better if the rcid and mcid are separate
> files in that directory. Is there a reason you combine them into one
> file?
>
> Thanks,
> Drew
Agreed. There is actually no particular need to update the two fields
together; combining them was mostly a habit on my part... I will split
the interface into qosid/rcid and qosid/mcid in v2.
Thanks,
Zhanpeng