From nobody Tue Feb 10 23:58:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=163.com ARC-Seal: i=1; a=rsa-sha256; t=1629896848; cv=none; d=zohomail.com; s=zohoarc; b=NAGDem5e/E4lwqhZdPYjDs4RPpdk93lHJTFmRjtf/HM/LLLVQb8QfbSdxsnGny5Phxrne/CdB87uZuw47MG3RD5dHJAt53ZmMQPp8tJtH7TqXTVlvmjuocs3JaX5oZZBjliiX5bD/FunJBZjIjx26oTirgDuGq9C0bW77xpkp54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629896848; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Hv+OoWC7Sexfnl1JdO2e84SRRthOhXXfF007eFefhFk=; b=PKcq1MkW6J8DzBA8CiucQbOO4ovu5Rq8FhqzqR2Q9vCM4OZUwk+Cv+FY1m9lzeGkBxZREaV79uOaTa2ukWYJ5OEYTzHCmjHdG7NL6T2e+rZmJRbNnbGGLA2fpIB2I3jrdnbB+U2KFRh5FPJTZAvZcfLnwzg3pcmeuPHNqaecQvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629896848938141.3011361354537; Wed, 25 Aug 2021 06:07:28 -0700 (PDT) Received: from localhost ([::1]:53776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIscp-0000z1-UB for importer@patchew.org; Wed, 25 Aug 2021 09:07:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIoDL-0003vr-62; Wed, 25 Aug 2021 04:24:51 -0400 Received: from m12-13.163.com ([220.181.12.13]:48194) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIoDH-00042H-VD; Wed, 25 Aug 2021 04:24:50 -0400 Received: from localhost.localdomain (unknown [180.169.130.89]) by smtp9 (Coremail) with SMTP id DcCowABnCwWL+iVhtO7SAQ--.38418S5; Wed, 25 Aug 2021 16:08:50 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=Hv+OoWC7Sexfnl1JdO 2e84SRRthOhXXfF007eFefhFk=; b=A8Md/xx02R6uhlSxwCOfKREhgKIKn4B46p bNBLZO8Csi4sXuHMivLJyzfAfDzMRnMs97Fd4SzkjT8LFzOvmEFIZu2PRXQMR48o ZxK/JHCusoCBvpyTMhr2waH7w1N2GJxdwR8dONhtnVpIVRyGN4vJ6Fnxd15hKNhG XhYDgTja4= From: chunming To: eric.auger@redhat.com, peter.maydell@linaro.org Subject: [PATCH v5 2/4] hw/arm/smmuv3: Update implementation of CFGI commands based on device SID Date: Wed, 25 Aug 2021 16:08:40 +0800 Message-Id: <1629878922-173270-3-git-send-email-chunming_li1234@163.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629878922-173270-1-git-send-email-chunming_li1234@163.com> References: <1629878922-173270-1-git-send-email-chunming_li1234@163.com> X-CM-TRANSID: DcCowABnCwWL+iVhtO7SAQ--.38418S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxXF17GFW7ur47AFykKw45KFg_yoW5Cr1kpa nrGr90gw4rCF1SyrnxKrW2krnIq34qgF10qryUWa9akw1UAryrXFWDK3Wrt34DJrW0yF47 ua4rWFs8XF17Z3DanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bTrcfUUUUU= X-Originating-IP: [180.169.130.89] X-CM-SenderInfo: xfkx0zplqjszjlrsjki6rwjhhfrp/xtbBrRL5dl75bWkJFwAAsN Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=220.181.12.13; envelope-from=chunming_li1234@163.com; helo=m12-13.163.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 25 Aug 2021 09:00:24 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: renwei.liu@verisilicon.com, qemu-arm@nongnu.org, jianxian.wen@verisilicon.com, qemu-devel@nongnu.org, chunming Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @163.com) X-ZM-MESSAGEID: 1629896849341100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: chunming Replace "smmuv3_flush_config" with "g_hash_table_foreach_remove". "smmu_iommu_mr" function can't get MR according to SID for non PCI/PCIe dev= ices. Signed-off-by: chunming --- hw/arm/smmuv3.c | 35 ++++++++++------------------------- include/hw/arm/smmu-common.h | 5 ++++- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 11d7fe8423..9f3f13fb8e 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -613,14 +613,6 @@ static SMMUTransCfg *smmuv3_get_config(SMMUDevice *sde= v, SMMUEventInfo *event) return cfg; } =20 -static void smmuv3_flush_config(SMMUDevice *sdev) -{ - SMMUv3State *s =3D sdev->smmu; - SMMUState *bc =3D &s->smmu_state; - - trace_smmuv3_config_cache_inv(smmu_get_sid(sdev)); - g_hash_table_remove(bc->configs, sdev); -} =20 static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, IOMMUAccessFlags flag, int iommu_idx) @@ -964,22 +956,18 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) case SMMU_CMD_CFGI_STE: { uint32_t sid =3D CMD_SID(&cmd); - IOMMUMemoryRegion *mr =3D smmu_iommu_mr(bs, sid); - SMMUDevice *sdev; + SMMUSIDRange sid_range; =20 if (CMD_SSEC(&cmd)) { cmd_error =3D SMMU_CERROR_ILL; break; } =20 - if (!mr) { - break; - } - + sid_range.start =3D sid; + sid_range.end =3D sid; trace_smmuv3_cmdq_cfgi_ste(sid); - sdev =3D container_of(mr, SMMUDevice, iommu); - smmuv3_flush_config(sdev); - + g_hash_table_foreach_remove(bs->configs, smmuv3_invalidate_ste, + &sid_range); break; } case SMMU_CMD_CFGI_STE_RANGE: /* same as SMMU_CMD_CFGI_ALL */ @@ -1006,21 +994,18 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) case SMMU_CMD_CFGI_CD_ALL: { uint32_t sid =3D CMD_SID(&cmd); - IOMMUMemoryRegion *mr =3D smmu_iommu_mr(bs, sid); - SMMUDevice *sdev; + SMMUSIDRange sid_range; =20 if (CMD_SSEC(&cmd)) { cmd_error =3D SMMU_CERROR_ILL; break; } =20 - if (!mr) { - break; - } - + sid_range.start =3D sid; + sid_range.end =3D sid; trace_smmuv3_cmdq_cfgi_cd(sid); - sdev =3D container_of(mr, SMMUDevice, iommu); - smmuv3_flush_config(sdev); + g_hash_table_foreach_remove(bs->configs, smmuv3_invalidate_ste, + &sid_range); break; } case SMMU_CMD_TLBI_NH_ASID: diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 95cd12a4b5..d016455d80 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -159,7 +159,10 @@ int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMU= AccessFlags perm, */ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova); =20 -/* Return the iommu mr associated to @sid, or NULL if none */ +/** + * Return the iommu mr associated to @sid, or NULL if none + * Only for PCI device, check smmu_find_peri_sdev for non PCI/PCIe device + */ IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid); =20 #define SMMU_IOTLB_MAX_SIZE 256 --=20 2.30.2