Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-21 Thread Lu Baolu
On 2/22/22 7:48 AM, Jason Gunthorpe wrote: since we should only care about ownership at probe, hotplug, and other places well outside critical fast-paths, I'm not sure we really need to keep track of that anyway - it can always be recalculated by walking the group->devices list, It has to be loc

Re: [PATCH v4 3/8] hisi_ptt: Register PMU device for PTT trace

2022-02-21 Thread Yicong Yang via iommu
On 2022/2/21 21:26, Yicong Yang wrote: > On 2022/2/21 19:44, Jonathan Cameron wrote: >> On Mon, 21 Feb 2022 16:43:02 +0800 >> Yicong Yang wrote: >> >>> Register PMU device of PTT trace, then users can use >>> trace through perf command. The driver makes use of perf >>> AUX trace and support follow

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-21 Thread Jason Gunthorpe via iommu
On Mon, Feb 21, 2022 at 08:43:33PM +, Robin Murphy wrote: > On 2022-02-19 07:32, Christoph Hellwig wrote: > > So we are back to the callback madness instead of the nice and simple > > flag? Sigh. > > TBH, I *think* this part could be a fair bit simpler. It looks like this > whole callback mes

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-21 Thread Robin Murphy
On 2022-02-19 07:32, Christoph Hellwig wrote: So we are back to the callback madness instead of the nice and simple flag? Sigh. TBH, I *think* this part could be a fair bit simpler. It looks like this whole callback mess is effectively just to decrement group->owner_cnt, but since we should

Re: [PATCH v3 8/9] drm/tegra: vic: Implement get_streamid_offset

2022-02-21 Thread Dmitry Osipenko
21.02.2022 14:44, Mikko Perttunen пишет: > On 2/19/22 20:54, Dmitry Osipenko wrote: >> 19.02.2022 21:49, Dmitry Osipenko пишет: >>> 18.02.2022 14:39, Mikko Perttunen пишет: +static int vic_get_streamid_offset(struct tegra_drm_client *client) +{ +    struct vic *vic = to_vic(client);

Re: [PATCH v3 9/9] drm/tegra: Support context isolation

2022-02-21 Thread Dmitry Osipenko
21.02.2022 15:06, Mikko Perttunen пишет: > On 2/19/22 20:35, Dmitry Osipenko wrote: >> 18.02.2022 14:39, Mikko Perttunen пишет: >>> +    if (context->memory_context && >>> context->client->ops->get_streamid_offset) { >> ^^^ >>> +    int offset = >>> context->client->ops->get_stream

Re: [PATCH v3 8/9] drm/tegra: vic: Implement get_streamid_offset

2022-02-21 Thread Mikko Perttunen
On 2/21/22 19:27, Robin Murphy wrote: On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: Implement the get_streamid_offset required for supporting context isolation. Since old firmware cannot support context isolation without hacks that we don't want to implement, check the firmware binary to

Re: [PATCH v3 8/9] drm/tegra: vic: Implement get_streamid_offset

2022-02-21 Thread Robin Murphy
On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: Implement the get_streamid_offset required for supporting context isolation. Since old firmware cannot support context isolation without hacks that we don't want to implement, check the firmware binary to see if context isolation should be ena

Re: [PATCH v3 1/9] dt-bindings: host1x: Add memory-contexts property

2022-02-21 Thread Mikko Perttunen
On 2/21/22 18:58, Robin Murphy wrote: On 2022-02-21 15:28, Mikko Perttunen wrote: On 2/21/22 17:23, Robin Murphy wrote: On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: Add schema information for the memory-contexts property used to specify context stream IDs. This uses the standard iommu

Re: [PATCH v3 1/9] dt-bindings: host1x: Add memory-contexts property

2022-02-21 Thread Robin Murphy
On 2022-02-21 15:28, Mikko Perttunen wrote: On 2/21/22 17:23, Robin Murphy wrote: On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: Add schema information for the memory-contexts property used to specify context stream IDs. This uses the standard iommu-map property inside a child node. Co

[PATCH v8 11/11] iommu/arm-smmu: Reserve any RMR regions associated with a dev

2022-02-21 Thread Shameer Kolothum via iommu
Get ACPI IORT RMR regions associated with a dev reserved so that there is a unity mapping for them in SMMU. Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-s

[PATCH v8 10/11] iommu/arm-smmu-v3: Reserve any RMR regions associated with a dev

2022-02-21 Thread Shameer Kolothum via iommu
Get ACPI IORT RMR regions associated with a dev reserved so that there is a unity mapping for them in SMMU. Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu

[PATCH v8 09/11] iommu/arm-smmu: Get associated RMR info and install bypass SMR

2022-02-21 Thread Shameer Kolothum via iommu
From: Jon Nettleton Check if there is any RMR info associated with the devices behind the SMMU and if any, install bypass SMRs for them. This is to keep any ongoing traffic associated with these devices alive when we enable/reset SMMU during probe(). Signed-off-by: Jon Nettleton Signed-off-by:

[PATCH v8 08/11] iommu/arm-smmu-v3: Get associated RMR info and install bypass STE

2022-02-21 Thread Shameer Kolothum via iommu
Check if there is any RMR info associated with the devices behind the SMMUv3 and if any, install bypass STEs for them. This is to keep any ongoing traffic associated with these devices alive when we enable/reset SMMUv3 during probe(). Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smm

[PATCH v8 07/11] iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force bypass

2022-02-21 Thread Shameer Kolothum via iommu
By default, disable_bypass flag is set and any dev without an iommu domain installs STE with CFG_ABORT during arm_smmu_init_bypass_stes(). Introduce a "force" flag and move the STE update logic to arm_smmu_init_bypass_stes() so that we can force it to install CFG_BYPASS STE for specific SIDs. This

[PATCH v8 06/11] iommu/arm-smmu-v3: Introduce strtab init helper

2022-02-21 Thread Shameer Kolothum via iommu
Introduce a helper to check the sid range and to init the l2 strtab entries(bypass). This will be useful when we have to initialize the l2 strtab with bypass for RMR SIDs. Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 28 +++-- 1 file changed,

[PATCH v8 05/11] ACPI/IORT: Add a helper to retrieve RMR memory regions

2022-02-21 Thread Shameer Kolothum via iommu
Add helper functions (iort_iommu_get/put_rmrs()) that retrieves/releases RMR memory descriptors associated with a given IOMMU. This will be used by IOMMU drivers to set up necessary mappings. Invoke it from the generic iommu helper functions. Signed-off-by: Shameer Kolothum --- drivers/acpi/arm

[PATCH v8 04/11] iommu/dma: Introduce generic helper to retrieve RMR info

2022-02-21 Thread Shameer Kolothum via iommu
Reserved Memory Regions(RMR) associated with an IOMMU can be described through ACPI IORT tables in systems with devices that require a unity mapping or bypass for those regions. Introduce a generic interface so that IOMMU drivers can retrieve and set up necessary mappings. Signed-off-by: Shameer

[PATCH v8 03/11] ACPI/IORT: Add helper functions to parse RMR nodes

2022-02-21 Thread Shameer Kolothum via iommu
The helper functions here parse through the IORT RMR nodes and populate a reserved region list corresponding to a given iommu and device(optional). These also go through the ID mappings of the RMR node and retrieves all the SIDs associated with a RMR descriptor. Signed-off-by: Shameer Kolothum -

[PATCH v8 02/11] iommu: Introduce a union to struct iommu_resv_region

2022-02-21 Thread Shameer Kolothum via iommu
A union is introduced to struct iommu_resv_region to hold any firmware specific data. This is in preparation to add support for IORT RMR reserve regions and the union now holds the RMR specific information. Signed-off-by: Shameer Kolothum --- include/linux/iommu.h | 9 + 1 file changed,

[PATCH v8 01/11] ACPI/IORT: Add temporary RMR node flag definitions

2022-02-21 Thread Shameer Kolothum via iommu
IORT rev E.d introduces more details into the RMR node Flags field. Add temporary definitions to describe and access these Flags field until ACPICA header is updated to support E.d. This patch can be reverted once the include/acpi/actbl2.h has all the relevant definitions. Signed-off-by: Shameer

[PATCH v8 00/11] ACPI/IORT: Support for IORT RMR node

2022-02-21 Thread Shameer Kolothum via iommu
Hi, Since we now have an updated verion[0] of IORT spec(E.d) which addresses the memory attributes issues discussed here [1], this series now make use of it. The pull request for ACPICA E.d related changes are already raised and can be found here, https://github.com/acpica/acpica/pull/752 v7 -->

Re: [PATCH v3 1/9] dt-bindings: host1x: Add memory-contexts property

2022-02-21 Thread Mikko Perttunen
On 2/21/22 17:23, Robin Murphy wrote: On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: Add schema information for the memory-contexts property used to specify context stream IDs. This uses the standard iommu-map property inside a child node. Couldn't you simply make "iommu-map" an allowed

Re: [PATCH v3 1/9] dt-bindings: host1x: Add memory-contexts property

2022-02-21 Thread Robin Murphy
On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: Add schema information for the memory-contexts property used to specify context stream IDs. This uses the standard iommu-map property inside a child node. Couldn't you simply make "iommu-map" an allowed property on the host1x node itself? F

Re: [PATCH V2 1/2] Swiotlb: Add swiotlb_alloc_from_low_pages switch

2022-02-21 Thread Tianyu Lan
On 2/15/2022 11:32 PM, Tianyu Lan wrote: On 2/14/2022 9:58 PM, Christoph Hellwig wrote: On Mon, Feb 14, 2022 at 07:28:40PM +0800, Tianyu Lan wrote: On 2/14/2022 4:19 PM, Christoph Hellwig wrote: Adding a function to set the flag doesn't really change much.  As Robin pointed out last time you s

Re: [PATCH v4 3/8] hisi_ptt: Register PMU device for PTT trace

2022-02-21 Thread Yicong Yang via iommu
On 2022/2/21 19:44, Jonathan Cameron wrote: > On Mon, 21 Feb 2022 16:43:02 +0800 > Yicong Yang wrote: > >> Register PMU device of PTT trace, then users can use >> trace through perf command. The driver makes use of perf >> AUX trace and support following events to configure the >> trace: >> >> -

Re: [PATCH v4 2/8] hwtracing: Add trace function support for HiSilicon PCIe Tune and Trace device

2022-02-21 Thread Jonathan Cameron via iommu
On Mon, 21 Feb 2022 21:13:45 +0800 Yicong Yang wrote: > Hi Jonathan, > > On 2022/2/21 19:18, Jonathan Cameron wrote: > > On Mon, 21 Feb 2022 16:43:01 +0800 > > Yicong Yang wrote: > > > >> HiSilicon PCIe tune and trace device(PTT) is a PCIe Root Complex > >> integrated Endpoint(RCiEP) device,

Re: [PATCH v4 2/8] hwtracing: Add trace function support for HiSilicon PCIe Tune and Trace device

2022-02-21 Thread Yicong Yang via iommu
Hi Jonathan, On 2022/2/21 19:18, Jonathan Cameron wrote: > On Mon, 21 Feb 2022 16:43:01 +0800 > Yicong Yang wrote: > >> HiSilicon PCIe tune and trace device(PTT) is a PCIe Root Complex >> integrated Endpoint(RCiEP) device, providing the capability >> to dynamically monitor and tune the PCIe traf

Re: [PATCH v3 9/9] drm/tegra: Support context isolation

2022-02-21 Thread Mikko Perttunen
On 2/19/22 20:35, Dmitry Osipenko wrote: 18.02.2022 14:39, Mikko Perttunen пишет: + if (context->memory_context && context->client->ops->get_streamid_offset) { ^^^ + int offset = context->client->ops->get_streamid_offset(context->client); + + if

Re: [PATCH v4 7/8] docs: Add HiSilicon PTT device driver documentation

2022-02-21 Thread Jonathan Cameron via iommu
On Mon, 21 Feb 2022 16:43:06 +0800 Yicong Yang wrote: > Document the introduction and usage of HiSilicon PTT device driver. > > Signed-off-by: Yicong Yang Reviewed-by: Jonathan Cameron > --- > Documentation/trace/hisi-ptt.rst | 303 +++ > 1 file changed, 303 inse

Re: [PATCH v4 4/8] hisi_ptt: Add support for dynamically updating the filter list

2022-02-21 Thread Jonathan Cameron via iommu
On Mon, 21 Feb 2022 16:43:03 +0800 Yicong Yang wrote: > The PCIe devices supported by the PTT trace can be removed/rescanned > by hotplug or through sysfs. Add support for dynamically updating > the available filter list by registering a PCI bus notifier block. > Then user can always get latest

Re: [PATCH v3 8/9] drm/tegra: vic: Implement get_streamid_offset

2022-02-21 Thread Mikko Perttunen
On 2/19/22 20:54, Dmitry Osipenko wrote: 19.02.2022 21:49, Dmitry Osipenko пишет: 18.02.2022 14:39, Mikko Perttunen пишет: +static int vic_get_streamid_offset(struct tegra_drm_client *client) +{ + struct vic *vic = to_vic(client); + int err; + + err = vic_load_firmware(vic);

Re: [PATCH v4 3/8] hisi_ptt: Register PMU device for PTT trace

2022-02-21 Thread Jonathan Cameron via iommu
On Mon, 21 Feb 2022 16:43:02 +0800 Yicong Yang wrote: > Register PMU device of PTT trace, then users can use > trace through perf command. The driver makes use of perf > AUX trace and support following events to configure the > trace: > > - filter: select Root port or Endpoint to trace > - type:

Re: [PATCH v3 3/9] gpu: host1x: Add context device management code

2022-02-21 Thread Mikko Perttunen
On 2/19/22 19:52, Dmitry Osipenko wrote: 18.02.2022 14:39, Mikko Perttunen пишет: + for (index = 0; index < cdl->len; index++) { + struct iommu_fwspec *fwspec; + + ctx = &cdl->devs[index]; + + ctx->host = host1x; + + device_initialize

Re: [PATCH v3 3/9] gpu: host1x: Add context device management code

2022-02-21 Thread Mikko Perttunen
On 2/19/22 19:48, Dmitry Osipenko wrote: 18.02.2022 14:39, Mikko Perttunen пишет: ... +/* + * Due to an issue with T194 NVENC, only 38 bits can be used. + * Anyway, 256GiB of IOVA ought to be enough for anyone. + */ +static dma_addr_t context_device_dma_mask = DMA_BIT_MASK(38); s/dma_addr_t/u6

Re: [PATCH v4 2/8] hwtracing: Add trace function support for HiSilicon PCIe Tune and Trace device

2022-02-21 Thread Jonathan Cameron via iommu
On Mon, 21 Feb 2022 16:43:01 +0800 Yicong Yang wrote: > HiSilicon PCIe tune and trace device(PTT) is a PCIe Root Complex > integrated Endpoint(RCiEP) device, providing the capability > to dynamically monitor and tune the PCIe traffic, and trace > the TLP headers. > > Add the driver for the devic

[PATCH 5/5] iommu/amd: Improve amd_iommu_v2_exit()

2022-02-21 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit During module exit, the current logic loops through all possible 16-bit device ID space to search for existing devices and clean up device state structures. This can be simplified by looping through the device state list. Also, refactor various clean up logic into fre

[PATCH 4/5] iommu/amd: Remove unused struct fault.devid

2022-02-21 Thread Vasant Hegde via iommu
This variable has not been used since it was introduced. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu_v2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iommu/amd/iommu_v2.c b/drivers/iommu/amd/

[PATCH 1/5] iommu/amd: Improve error handling for amd_iommu_init_pci

2022-02-21 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Add error messages to prevent silent failure. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd

[PATCH 0/5] iommu/amd: Cleanup and fixes

2022-02-21 Thread Vasant Hegde via iommu
This series contains various cleanup and trivial fixes. Suravee Suthikulpanit (2): iommu/amd: Improve error handling for amd_iommu_init_pci iommu/amd: Improve amd_iommu_v2_exit() Vasant Hegde (3): iommu/amd: Call memunmap in error path iommu/amd: Clean up function declarations iommu/amd

[PATCH 3/5] iommu/amd: Clean up function declarations

2022-02-21 Thread Vasant Hegde via iommu
Remove unused declarations and add static keyword as needed. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu.h | 4 drivers/iommu/amd/init.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-)

[PATCH 2/5] iommu/amd: Call memunmap in error path

2022-02-21 Thread Vasant Hegde via iommu
From: Vasant Hegde Unmap old_devtb in error path. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c ind

[PATCH v4 3/8] hisi_ptt: Register PMU device for PTT trace

2022-02-21 Thread Yicong Yang via iommu
Register PMU device of PTT trace, then users can use trace through perf command. The driver makes use of perf AUX trace and support following events to configure the trace: - filter: select Root port or Endpoint to trace - type: select the type of traced TLP headers - direction: select the directi

[PATCH v4 2/8] hwtracing: Add trace function support for HiSilicon PCIe Tune and Trace device

2022-02-21 Thread Yicong Yang via iommu
HiSilicon PCIe tune and trace device(PTT) is a PCIe Root Complex integrated Endpoint(RCiEP) device, providing the capability to dynamically monitor and tune the PCIe traffic, and trace the TLP headers. Add the driver for the device to enable the trace function. This patch adds basic function of tr

[PATCH v4 0/8] Add support for HiSilicon PCIe Tune and Trace device

2022-02-21 Thread Yicong Yang via iommu
HiSilicon PCIe tune and trace device (PTT) is a PCIe Root Complex integrated Endpoint (RCiEP) device, providing the capability to dynamically monitor and tune the PCIe traffic (tune), and trace the TLP headers (trace). PTT tune is designed for monitoring and adjusting PCIe link parameters. We prov

[PATCH v4 4/8] hisi_ptt: Add support for dynamically updating the filter list

2022-02-21 Thread Yicong Yang via iommu
The PCIe devices supported by the PTT trace can be removed/rescanned by hotplug or through sysfs. Add support for dynamically updating the available filter list by registering a PCI bus notifier block. Then user can always get latest information about available tracing filters and driver can block

[PATCH v4 7/8] docs: Add HiSilicon PTT device driver documentation

2022-02-21 Thread Yicong Yang via iommu
Document the introduction and usage of HiSilicon PTT device driver. Signed-off-by: Yicong Yang --- Documentation/trace/hisi-ptt.rst | 303 +++ 1 file changed, 303 insertions(+) create mode 100644 Documentation/trace/hisi-ptt.rst diff --git a/Documentation/trace/hisi

[PATCH v4 6/8] perf tool: Add support for HiSilicon PCIe Tune and Trace device driver

2022-02-21 Thread Yicong Yang via iommu
From: Qi Liu 'perf record' and 'perf report --dump-raw-trace' supported in this patch. Example usage: Output will contain raw PTT data and its textual representation, such as: 0 0 0x5810 [0x30]: PERF_RECORD_AUXTRACE size: 0x40 offset: 0 ref: 0xa5d50c725 idx: 0 tid: -1 cpu: 0 . . ... HI

[PATCH v4 5/8] hisi_ptt: Add tune function support for HiSilicon PCIe Tune and Trace device

2022-02-21 Thread Yicong Yang via iommu
Add tune function for the HiSilicon Tune and Trace device. The interface of tune is exposed through sysfs attributes of PTT PMU device. Reviewed-by: Jonathan Cameron Signed-off-by: Yicong Yang --- drivers/hwtracing/ptt/hisi_ptt.c | 154 +++ drivers/hwtracing/ptt/hisi

[PATCH v4 8/8] MAINTAINERS: Add maintainer for HiSilicon PTT driver

2022-02-21 Thread Yicong Yang via iommu
Add maintainer for driver and documentation of HiSilicon PTT device. Signed-off-by: Yicong Yang --- MAINTAINERS | 7 +++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ea3e6c914384..237c618a74d5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8689,6 +8689,13 @@

[PATCH v4 1/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity

2022-02-21 Thread Yicong Yang via iommu
The DMA of HiSilicon PTT device can only work with identical mapping. So add a quirk for the device to force the domain passthrough. Signed-off-by: Yicong Yang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 16 1 file changed, 16 insertions(+) diff --git a/drivers/iommu/arm/