From nobody Tue Nov 26 11:58:25 2024 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=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1708535914; cv=none; d=zohomail.com; s=zohoarc; b=XhiWCojg/KagZrRyDfUOA0ZX+B04x3XeGZMhnE3a8oIPo8IBQhbDhr7zvt5Z6t6Tbb81hPnLP9UNRHfbPW0akvl73PJLf6/NSpzfQSlvApStvZybLlH2zwoQ2Y4xRb0MBhb6nKJfeXvlnWh6upPM7IBO4QP+VyylIJPZV+GugGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708535914; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7LpRySPaP0CHOH79hBVtR1tsWRZD/BKE7TKJiIenQ5A=; b=LnfyL2lvg+ZR2ufSZa/NC/Uj0WtH9qGHbMipf5FkmKB8FjZ/5P1VCgGiW4tyQ/ft4B4fXLtEST0gjXd/e00XGhjdTNZ2EeMCmxLU+coOdV/PhS0t6VdqheYuozJXD8oToxQVD07NefLzV8uZEJ3xXT4wiDncrbJoR4l3ddt7684= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708535914897769.7031129518709; Wed, 21 Feb 2024 09:18:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcqDz-0000VN-KX; Wed, 21 Feb 2024 12:17:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3IjDWZQwKChE4rszyv9Avwr4x55x2v.t537v3B-uvCv2454x4B.58x@flex--nabihestefan.bounces.google.com>) id 1rcqDy-0000V8-4C for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:17:38 -0500 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3IjDWZQwKChE4rszyv9Avwr4x55x2v.t537v3B-uvCv2454x4B.58x@flex--nabihestefan.bounces.google.com>) id 1rcqDj-0007iu-Ck for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:17:37 -0500 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dc64e0fc7c8so9572231276.2 for ; Wed, 21 Feb 2024 09:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708535842; x=1709140642; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=7LpRySPaP0CHOH79hBVtR1tsWRZD/BKE7TKJiIenQ5A=; b=EaR/Jenplj9N9FDsmbKtqww0IcMUblXUHo0vdW47/hqHAeP9tFzGj/szxoashm3Xdg 3f4LED0Wt/eiKrd06x1A+jGYhAGoYyu3dUsX2zOxS1/h9HTOx+lzO8UFzt8dfaDiTobr QJpFZy+ihpz+JbH6kNMvuiK9bQESySra52Une+lm2g6w05XWw3pIdzfyBZTvuGRed4Ej LDQoR6Eb7kMAd3hglvFOnytpYExIyaF7XemnuDUy/p9WIz09oKPWw976F61DEU6vhOn/ 8URjgM/RvK1wcSw3rX0T/du/nOWGa8Foa0HHgizPAx0GdBZ/j3FK3TfszqI6DDIsft2i 0esg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708535842; x=1709140642; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7LpRySPaP0CHOH79hBVtR1tsWRZD/BKE7TKJiIenQ5A=; b=fY5d4MpCNcsFmZsel4yKbIdLWUM7WaZDFmaUkzWGXc5RaI7JbDP+xoZjI4pxMYx624 VAyrWqEibkxw3wC1HbelZ7TJO7C0Tufd8mLyitJBi8YuK/FfaRaFQTfhzAV1W6bFCNNN 4ra3O0lQGTuhMmVDbl9ckcs+5pDi1ai7NhQqZszTdUkuKbIxc2OIwl9B0z1WMr1bDZ1G H1SRSFuLBAEzJxCcqjm3l4AoMGmnO7Hr6+S1BsJrW3o3hIhZPsIlr+igqNkad8XfhUGz OyTm/H0cvsNaoie43zB+fpxNgb1iSu5Os9w0U6zg4xes4/iN/cnAP1aKj4NqaVpUD5EI XhmQ== X-Forwarded-Encrypted: i=1; AJvYcCU8W1JbEcisBqD+07pXpiOvZ4otowPZNydzDS7B54h7fumcxcI0Ya+WxqqjWaiYTK3DXNsjaCVRtC3J5ZLzk1xqmt6z6Tg= X-Gm-Message-State: AOJu0YxqXueC8j2aBw6N8GfITCYRQAtF75szyv9meP/YzYkQ48wd2+ru 9jKUV6vcL+aKJzwvZxlne8MGhSNCa49zYQtl+AyRNJPXRIGi4H3Olb7rZyOSm16f2hmQTsdKtjZ 8cEF6u9m3AtV/4o2JJYq4wCuWQw== X-Google-Smtp-Source: AGHT+IFq05j1ZDpzfKSBRyL0w7k2B6acgaENYw7bFsnKtGNTF3koo0OHtMD+T3OvgaYx4KwOs4IFD5Xe88DNY4IjC4E= X-Received: from nabihestefan.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2737]) (user=nabihestefan job=sendgmr) by 2002:a05:6902:1001:b0:dcc:79ab:e522 with SMTP id w1-20020a056902100100b00dcc79abe522mr778978ybt.11.1708535842359; Wed, 21 Feb 2024 09:17:22 -0800 (PST) Date: Wed, 21 Feb 2024 17:17:16 +0000 In-Reply-To: <20240221171716.1260192-1-nabihestefan@google.com> Mime-Version: 1.0 References: <20240221171716.1260192-1-nabihestefan@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221171716.1260192-3-nabihestefan@google.com> Subject: [PATCH 2/2] hw/arm/smmu-common: Create virtual function for implementation defined StreamID From: Nabih Estefan To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-block@nongnu.org, its@irrelevant.dk, kbusch@kernel.org, eric.auger@redhat.com, roqueh@google.com, nabihestefan@google.com 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=2607:f8b0:4864:20::b49; envelope-from=3IjDWZQwKChE4rszyv9Avwr4x55x2v.t537v3B-uvCv2454x4B.58x@flex--nabihestefan.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1708535916541100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Roque Arcudia Hernandez According to the SMMU specification the StreamID construction and size is IMPLEMENTATION DEFINED, the size being between 0 and 32 bits. This patch creates virtual functions get_sid and get_iommu_mr to allow diff= erent implementations of how the StreamID is constructed via inheritance. The def= ault implementation of these functions will match the current ones where the BDF= is used directly as StreamID. Signed-off-by: Roque Arcudia Hernandez Signed-off-by: Nabih Estefan --- hw/arm/smmu-common.c | 12 ++++++++++++ include/hw/arm/smmu-common.h | 16 +++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 4caedb4998..14b3240a88 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -621,6 +621,11 @@ static const PCIIOMMUOps smmu_ops =3D { }; =20 IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid) +{ + return ARM_SMMU_GET_CLASS(s)->get_iommu_mr(s, sid); +} + +static IOMMUMemoryRegion *smmu_base_iommu_mr(SMMUState *s, uint32_t sid) { uint8_t bus_n, devfn; SMMUPciBus *smmu_bus; @@ -659,6 +664,11 @@ void smmu_inv_notifiers_all(SMMUState *s) } } =20 +static uint32_t smmu_base_get_sid(SMMUDevice *sdev) +{ + return PCI_BUILD_BDF(pci_bus_num(sdev->bus), sdev->devfn); +} + static void smmu_base_realize(DeviceState *dev, Error **errp) { SMMUState *s =3D ARM_SMMU(dev); @@ -709,6 +719,8 @@ static void smmu_base_class_init(ObjectClass *klass, vo= id *data) device_class_set_parent_realize(dc, smmu_base_realize, &sbc->parent_realize); rc->phases.hold =3D smmu_base_reset_hold; + sbc->get_sid =3D smmu_base_get_sid; + sbc->get_iommu_mr =3D smmu_base_iommu_mr; } =20 static const TypeInfo smmu_base_info =3D { diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 5ec2e6c1a4..d53121fe37 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -131,6 +131,9 @@ typedef struct SMMUIOTLBKey { uint8_t level; } SMMUIOTLBKey; =20 +#define TYPE_ARM_SMMU "arm-smmu" +OBJECT_DECLARE_TYPE(SMMUState, SMMUBaseClass, ARM_SMMU) + struct SMMUState { /* */ SysBusDevice dev; @@ -147,6 +150,9 @@ struct SMMUState { PCIBus *primary_bus; }; =20 +typedef uint32_t GetSidFunc(SMMUDevice *obj); +typedef IOMMUMemoryRegion *GetIommuMr(SMMUState *s, uint32_t sid); + struct SMMUBaseClass { /* */ SysBusDeviceClass parent_class; @@ -154,19 +160,19 @@ struct SMMUBaseClass { /*< public >*/ =20 DeviceRealize parent_realize; + GetSidFunc *get_sid; + GetIommuMr *get_iommu_mr; =20 }; =20 -#define TYPE_ARM_SMMU "arm-smmu" -OBJECT_DECLARE_TYPE(SMMUState, SMMUBaseClass, ARM_SMMU) - /* Return the SMMUPciBus handle associated to a PCI bus number */ SMMUPciBus *smmu_find_smmu_pcibus(SMMUState *s, uint8_t bus_num); =20 /* Return the stream ID of an SMMU device */ -static inline uint16_t smmu_get_sid(SMMUDevice *sdev) +static inline uint32_t smmu_get_sid(SMMUDevice *sdev) { - return PCI_BUILD_BDF(pci_bus_num(sdev->bus), sdev->devfn); + SMMUState *s =3D sdev->smmu; + return ARM_SMMU_GET_CLASS(s)->get_sid(sdev); } =20 /** --=20 2.44.0.rc0.258.g7320e95886-goog