Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4378747pxt; Wed, 11 Aug 2021 04:50:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd4F3L8aPnMqI3GxtvreY2nrZ2wdB3I5/GN4fxxu9QtY4XPSK/fKPjKL7XdwMBxAnSWWuh X-Received: by 2002:a02:1942:: with SMTP id b63mr31552546jab.111.1628682639872; Wed, 11 Aug 2021 04:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628682639; cv=none; d=google.com; s=arc-20160816; b=hMIPxSimlXOCOvgQI6HKRuMnXK+8wuDL0QHSZ440Kq7wLqNKLGq3jq9PDGOlMYRNgs bzv3PB2lA8erX3BNWBj7Ro+yF8skFDHpXmJ/Yn23kXxlQi6XBBD73YxGIMIe8mqLVANB LZ7u2kHiEFskPSoOyR9XGzcPExvTOropnTiteQErIXXTbmTz21NMFW8khQhkdQBIhs+B 1oOiBNFEun6H2KSjBuWir1UhVhd5dztr4D5HRUbhmLA+9+BLWh2XIpALJSXVxG+q1UIQ 3BAc0lDos9e0K6NrSpMf5smDFHzmI0risf7SRS4VpFkv9FWP+ARwbvx78hXSeyERq6SD 9xvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=74c2jeSJleFwyv+dhHCIuK6GObV3pmCwwVjH8CAIqc4=; b=v4yOQlHw6mV9tzqUz/YeM9pUbd+G6j2YIMbgnte0n0lCq5VN1Gde8Tv/zHsjfzvTB1 D/drQLyVKgPy8kSfu18f3Pv9/gRcZqHZHHwzc05s1ZYlquNez3p6PkQyTGl33QcfClmh +K2lYNk8EMtCcDzT5ixbvrY8Z9+G+QvG7fuP9kwlQXtgoKt8U7draO3Z4CteO12aKL2g c6vXFdFujDuKNMUXPpVeT4bKot7vwyO1t+fpolAkK3wBRa255DAk43d+3txhMDkhHJaZ oIpoNZ2zDIiuNSaqoRqcyJckrkcGpRJxsS1MwOjX6TRY4mDeL0eLaNyLDseeb0PapQHO mgrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uaLhK8xH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si1073853ilg.94.2021.08.11.04.50.27; Wed, 11 Aug 2021 04:50:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uaLhK8xH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237571AbhHKLt6 (ORCPT + 99 others); Wed, 11 Aug 2021 07:49:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:45454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237589AbhHKLtx (ORCPT ); Wed, 11 Aug 2021 07:49:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5943760C3E; Wed, 11 Aug 2021 11:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628682569; bh=NpZoarZNXOYI6N/IP04rCszscxBifRJPQcNMIhZUxq0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uaLhK8xHUrlzAp7BPCC4GmxUZJLbKJoXtourSyBET2zV2VUqX91dyMNiJGuzrjUp4 XbutvdMjUbsmcntFVd06sJMl0PVF+LD4tr5LSqCQsd+Dk0A8Xj49al2S2eEHbS40yD 899aro87UICWXSwLi/EDCD22ulACt7tni089e+n0= Date: Wed, 11 Aug 2021 13:49:27 +0200 From: Greg KH To: Barry Song Cc: rafael@kernel.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, will@kernel.org, linuxarm@huawei.com, Zhou Wang Subject: Re: [PATCH] platform-msi: Add ABI to show msi_irqs of platform devices Message-ID: References: <20210811105020.12980-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210811105020.12980-1-song.bao.hua@hisilicon.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 11, 2021 at 10:50:20PM +1200, Barry Song wrote: > Just like pci devices have msi_irqs which can be used by userspace irq affinity > tools or applications to bind irqs, platform devices also widely support msi > irqs. For platform devices, for example ARM SMMU, userspaces also care about > its msi irqs as applications can know the mapping between devices and irqs > and then make smarter decision on handling irq affinity. For example, for > SVA mode, it is better to pin io page fault to the numa node applications > are running on. Otherwise, io page fault will get a remote page from the > node iopf happens. > With this patch, a system with multiple arm SMMUs in multiple different numa > node can get the mapping between devices and irqs now: > root@ubuntu:/sys/devices/platform# ls -l arm-smmu-v3.*/msi_irqs/* > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.0.auto/msi_irqs/25 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.0.auto/msi_irqs/26 > -r--r--r-- 1 root root 4096 Aug 11 10:28 arm-smmu-v3.1.auto/msi_irqs/27 > -r--r--r-- 1 root root 4096 Aug 11 10:28 arm-smmu-v3.1.auto/msi_irqs/28 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.2.auto/msi_irqs/29 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.2.auto/msi_irqs/30 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.3.auto/msi_irqs/31 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.3.auto/msi_irqs/32 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.4.auto/msi_irqs/33 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.4.auto/msi_irqs/34 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.5.auto/msi_irqs/35 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.5.auto/msi_irqs/36 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.6.auto/msi_irqs/37 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.6.auto/msi_irqs/38 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.7.auto/msi_irqs/39 > -r--r--r-- 1 root root 4096 Aug 11 10:29 arm-smmu-v3.7.auto/msi_irqs/40 > > Applications can use the mapping and the numa node information to pin > irqs by leveraging the numa information which has also been exported: > root@ubuntu:/sys/devices/platform# cat arm-smmu-v3.0.auto/numa_node > 0 > root@ubuntu:/sys/devices/platform# cat arm-smmu-v3.4.auto/numa_node > 2 > > Cc: Zhou Wang > Signed-off-by: Barry Song > --- > Documentation/ABI/testing/sysfs-bus-platform | 14 +++ > drivers/base/platform-msi.c | 122 +++++++++++++++++++++++++++ > 2 files changed, 136 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-bus-platform b/Documentation/ABI/testing/sysfs-bus-platform > index 194ca70..4498f89 100644 > --- a/Documentation/ABI/testing/sysfs-bus-platform > +++ b/Documentation/ABI/testing/sysfs-bus-platform > @@ -28,3 +28,17 @@ Description: > value comes from an ACPI _PXM method or a similar firmware > source. Initial users for this file would be devices like > arm smmu which are populated by arm64 acpi_iort. > + > +What: /sys/bus/platform/devices/.../msi_irqs/ > +Date: August 2021 > +Contact: Barry Song > +Description: > + The /sys/devices/.../msi_irqs directory contains a variable set > + of files, with each file being named after a corresponding msi > + irq vector allocated to that device. > + > +What: /sys/bus/platform/devices/.../msi_irqs/ > +Date: August 2021 > +Contact: Barry Song > +Description: > + This attribute will show "msi" if is a valid msi irq > diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c > index 0b72b13..6a72ebc 100644 > --- a/drivers/base/platform-msi.c > +++ b/drivers/base/platform-msi.c > @@ -23,6 +23,7 @@ > struct platform_msi_priv_data { > struct device *dev; > void *host_data; > + const struct attribute_group **msi_irq_groups; > msi_alloc_info_t arg; > irq_write_msi_msg_t write_msg; > int devid; > @@ -245,6 +246,120 @@ static void platform_msi_free_priv_data(struct platform_msi_priv_data *data) > kfree(data); > } > > +static ssize_t platform_msi_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct msi_desc *entry; > + unsigned long irq; > + int retval; > + > + retval = kstrtoul(attr->attr.name, 10, &irq); > + if (retval) > + return retval; > + > + entry = irq_get_msi_desc(irq); > + if (entry) > + return sprintf(buf, "msi\n"); sysfs_emit()? But why isn't this all handled by the MSI core code? Why would each bus need to have this logic in it? thanks, greg k-h