From patchwork Tue Apr 20 08:27:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 424553 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp206390jao; Tue, 20 Apr 2021 02:28:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHy/Xt7PRVKsEmuSbmw9l1DzKti6x645rq2AvL1XxBM2TzAv1KofcPCUjtFICXc8xI4GLU X-Received: by 2002:a17:907:77d9:: with SMTP id kz25mr26761194ejc.153.1618910891363; Tue, 20 Apr 2021 02:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618910891; cv=none; d=google.com; s=arc-20160816; b=o61L5avFLNSPhpCrJduR1KF1X/j14FpK21ONX+JwjfofkMGiiBZnkUZHGW3902xjoq DEgkUNn/AkrjZsMfrQs2BBNdyRLqrLE83nMmUwnLhsEMZ4qkaltEEOQOPwhzlkgAijPy grenn6fthiQPX9OQ3QL+2UrZVrzrpZV4XsCuNu4eyXiD/Jl0QSikwHvxMW8e0mTIHVgW qEgEKmRez3gez94mKSOrOL+ybn9o3c+bmHOFbZHpoi3kE20BQ9+VwINVWGTTIT1WcK7/ PJbP+VHPVQAGgb6dST+5S71HExnvFUQcFjn7odJSr/88pCtWXPdger0bSAgjvZq8CELP hAMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=STMzQ/fHTlpjKlR9OYxsRX04y/rQA5Ejx6CCjX6naN8=; b=Rqohh/Z/Y55Ew4MCn4A84+yii2RwwF338qAgrLg4sKaVvY+ZDYETqwH4eQciExXg0X bmFkarifxLqpIwxRtVL/ChRonWOH+0yxClVRg1hoptFSbOI4ZbuMcYqVyVDhwkjt+Mut l8woO6oVb4rd1LWuFoEFEhe/S+nndyFeeggrjhL+90525gdA9cxJMtYjkYIHBjNeVrkN 0czB14Spqrm6R/Ky37Nu+ajN+5k4SDKwxQF5QlMuCW+F0dOO/h4xXvnGfc+0ZtnbNJAf 5fkunamrOnO2mKX+OVA9VmZ9t//tS3Jyu6bf+OR6cLWAn/17hSqfwtugTVR4ukz6yu5P qH6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si5177143edq.3.2021.04.20.02.28.11; Tue, 20 Apr 2021 02:28:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbhDTJ2j (ORCPT + 4 others); Tue, 20 Apr 2021 05:28:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:16483 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbhDTJ2j (ORCPT ); Tue, 20 Apr 2021 05:28:39 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FPdZw5MNSzrfkt; Tue, 20 Apr 2021 17:25:44 +0800 (CST) Received: from A2006125610.china.huawei.com (10.47.83.26) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Tue, 20 Apr 2021 17:27:59 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , , , Subject: [PATCH v3 00/10] ACPI/IORT: Support for IORT RMR node Date: Tue, 20 Apr 2021 10:27:41 +0200 Message-ID: <20210420082751.1829-1-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.47.83.26] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Hi, RFC v2 --> v3 -Dropped RFC tag as the ACPICA header changes are now ready to be part of 5.13[0]. But this series still has a dependency on that patch. -Added IORT E.b related changes(node flags, _DSM function 5 checks for PCIe). -Changed RMR to stream id mapping from M:N to M:1 as per the spec and discussion here[1]. -Last two patches add support for SMMUv2(Thanks to Jon Nettleton!) Sanity tested on a HiSilicon D06. Further testing and feedback is greatly appreciated. The whole series can be found here, https://github.com/hisilicon/kernel-dev/tree/private-v5.12-rc8-rmr-v3 Thanks, Shameer [0] https://lore.kernel.org/linux-acpi/20210406213028.718796-22-erik.kaneda@intel.com/ [1] https://op-lists.linaro.org/pipermail/linaro-open-discussions/2021-April/000150.html RFC v1 --> v2:  - Added a generic interface for IOMMU drivers to retrieve all the    RMR info associated with a given IOMMU.  - SMMUv3 driver gets the RMR list during probe() and installs    bypass STEs for all the SIDs in the RMR list. This is to keep   the ongoing traffic alive(if any) during SMMUv3 reset. This is based on the suggestions received for v1 to take care of the EFI framebuffer use case. Only sanity tested for now.  - During the probe/attach device, SMMUv3 driver reserves any    RMR region associated with the device such that there is a unity    mapping for them in SMMU. ---     >From RFC v1: ------------- The series adds support to IORT RMR nodes specified in IORT Revision E -ARM DEN 0049E[0]. RMR nodes are used to describe memory ranges that are used by endpoints and require a unity mapping in SMMU. We have faced issues with 3408iMR RAID controller cards which fail to boot when SMMU is enabled. This is because these controllers make use of host memory for various caching related purposes and when SMMU is enabled the iMR firmware fails to access these memory regions as there is no mapping for them. IORT RMR provides a way for UEFI to describe and report these memory regions so that the kernel can make a unity mapping for these in SMMU. Tests: With a UEFI, that reports the RMR for the dev, .... [16F0h 5872 1] Type : 06 [16F1h 5873 2] Length : 007C [16F3h 5875 1] Revision : 00 [1038h 0056 2] Reserved : 00000000 [1038h 0056 2] Identifier : 00000000 [16F8h 5880 4] Mapping Count : 00000001 [16FCh 5884 4] Mapping Offset : 00000040 [1700h 5888 4] Number of RMR Descriptors : 00000002 [1704h 5892 4] RMR Descriptor Offset : 00000018 [1708h 5896 8] Base Address of RMR : 0000E6400000 [1710h 5904 8] Length of RMR : 000000100000 [1718h 5912 4] Reserved : 00000000 [171Ch 5916 8] Base Address of RMR : 0000000027B00000 [1724h 5924 8] Length of RMR : 0000000000C00000 [172Ch 5932 4] Reserved : 00000000 [1730h 5936 4] Input base : 00000000 [1734h 5940 4] ID Count : 00000001 [1738h 5944 4] Output Base : 00000003 [173Ch 5948 4] Output Reference : 00000064 [1740h 5952 4] Flags (decoded below) : 00000001 Single Mapping : 1 ... Without the series the RAID controller initialization fails as below, ... [ 12.631117] megaraid_sas 0000:03:00.0: FW supports sync cache : Yes [ 12.637360] megaraid_sas 0000:03:00.0: megasas_disable_intr_fusion is called outbound_intr_mask:0x40000009 [ 18.776377] megaraid_sas 0000:03:00.0: Init cmd return status FAILED for SCSI host 0 [ 23.019383] megaraid_sas 0000:03:00.0: Waiting for FW to come to ready state [ 106.684281] megaraid_sas 0000:03:00.0: FW in FAULT state, Fault code:0x10000 subcode:0x0 func:megasas_transition_to_ready [ 106.695186] megaraid_sas 0000:03:00.0: System Register set: [ 106.889787] megaraid_sas 0000:03:00.0: Failed to transition controller to ready for scsi0. [ 106.910475] megaraid_sas 0000:03:00.0: Failed from megasas_init_fw 6407 estuary:/$ With the series, now the kernel has direct mapping for the dev as below, estuary:/$ cat /sys/kernel/iommu_groups/0/reserved_regions 0x0000000008000000 0x00000000080fffff msi 0x0000000027b00000 0x00000000286fffff direct 0x00000000e6400000 0x00000000e64fffff direct estuary:/$ .... [ 12.254318] megaraid_sas 0000:03:00.0: megasas_disable_intr_fusion is called outbound_intr_mask:0x40000009 [ 12.739089] megaraid_sas 0000:03:00.0: FW provided supportMaxExtLDs: 0 max_lds: 32 [ 12.746628] megaraid_sas 0000:03:00.0: controller type : iMR(0MB) [ 12.752694] megaraid_sas 0000:03:00.0: Online Controller Reset(OCR) : Enabled [ 12.759798] megaraid_sas 0000:03:00.0: Secure JBOD support : Yes [ 12.765778] megaraid_sas 0000:03:00.0: NVMe passthru support : Yes [ 12.771931] megaraid_sas 0000:03:00.0: FW provided TM TaskAbort/Reset timeou: 6 secs/60 secs [ 12.780503] megaraid_sas 0000:03:00.0: JBOD sequence map support : Yes [ 12.787000] megaraid_sas 0000:03:00.0: PCI Lane Margining support : No [ 12.819179] megaraid_sas 0000:03:00.0: NVME page size : (4096) [ 12.825672] megaraid_sas 0000:03:00.0: megasas_enable_intr_fusion is called outbound_intr_mask:0x40000000 [ 12.835199] megaraid_sas 0000:03:00.0: INIT adapter done [ 12.873932] megaraid_sas 0000:03:00.0: pci id : (0x1000)/(0x0017)/(0x19e5)/(0xd213) [ 12.881644] megaraid_sas 0000:03:00.0: unevenspan support : no [ 12.887451] megaraid_sas 0000:03:00.0: firmware crash dump : no [ 12.893344] megaraid_sas 0000:03:00.0: JBOD sequence map : enabled RAID controller init is now success and can detect the drives attached as well. Jon Nettleton (2): iommu/arm-smmu: Get associated RMR info and install bypass SMR iommu/arm-smmu: Reserve any RMR regions associated with a dev Shameer Kolothum (8): ACPI/IORT: Add support for RMR node parsing iommu/dma: Introduce generic helper to retrieve RMR info ACPI/IORT: Add a helper to retrieve RMR memory regions iommu/dma: Add a helper function to reserve RMRs for IOMMU drivers iommu/arm-smmu-v3: Introduce strtab init helper iommu/arm-smmu-v3: Add bypass flag to arm_smmu_write_strtab_ent() iommu/arm-smmu-v3: Get associated RMR info and install bypass STE iommu/arm-smmu-v3: Reserve any RMR regions associated with a dev drivers/acpi/arm64/iort.c | 144 +++++++++++++++++++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 98 +++++++++++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 + drivers/iommu/arm/arm-smmu/arm-smmu.c | 75 ++++++++++ drivers/iommu/arm/arm-smmu/arm-smmu.h | 2 + drivers/iommu/dma-iommu.c | 71 ++++++++++ include/linux/acpi_iort.h | 7 + include/linux/dma-iommu.h | 15 ++ include/linux/iommu.h | 19 +++ 9 files changed, 417 insertions(+), 16 deletions(-) -- 2.17.1