From patchwork Tue Aug 22 10:57:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13360487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B2A6EE49A3 for ; Tue, 22 Aug 2023 10:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=VEea6tfOZoUJMt46+DUkXWz1pVdxNDZbCni49SjNTmE=; b=m+N8+OLnWX0+MVinDcMmgEqcuS vt9ToGnr/ZA1DlubtLefCwZsAmhZqZjvt+1okxAHhTBMS1kJtDffdDa9QmDGaIhmoqFvkhYnsZzIl PFdU7DG/X/0V1ONV91wqx5kyRbRNuBfjySJoLJ/1ap0tUXo3ZrBiSGP/H6ltO75LiOPAz8Xj9zBbw mYKjIObg458mE8hPesQs5OnM75zltgomhgPQZrEsClkqXULMbUxX3AtMecKkk1B9Wndv9elKNP4bL jZF8iOJsnbQfHUOo5UALMgoMNXaxR1cCxdoXJ00HvPAb920HlrIlTAVtdZ11iaO8sGN4fioljrqv+ bLKhxTBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYP62-00FmkP-1g; Tue, 22 Aug 2023 10:58:50 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYP5f-00FmWk-0v for linux-arm-kernel@lists.infradead.org; Tue, 22 Aug 2023 10:58:28 +0000 Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-26d49dd574aso5231399a91.1 for ; Tue, 22 Aug 2023 03:58:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692701906; x=1693306706; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=gv8qs8tb5+ht3xEXCO2MlfdAXc51HHEhUztVM4QYf7k=; b=XxR0LNcd6ZMLLCXEsgVSgiM0m2dvGOpGJ0H2y2I3Ztbzt8plf5Zs/4VNYjeQOFpry+ PH2HqrjjVyT6YxZ0ZowGRVgJRmlhAZziZAfr8pHS5GaUhXmpfF+xIN8sFcmU+VoQt6jf vg3KT/vuCq2HJIN/0b20FjE97XCf5ZOP7uVIA8O/OCVtNAP0HVbSntANTxWg/EcMcSxH R2UP3T6vuQvik0z9gG1HI/Zbn+2pPHPvZv+kPu+c7PlQhUh/60zo8gc/U/LQaRzF5NLz gJKIgjHkQfwHgvdR7MHN1Gw86BsVoxJ55knBkY5sEEGZdpPjIn/teqw7obJvPgVEFyXC Op7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692701906; x=1693306706; 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=gv8qs8tb5+ht3xEXCO2MlfdAXc51HHEhUztVM4QYf7k=; b=Kme5BWRTELdIlTPhaSSm82WX1viPH/ue3sT3jVmpaz42lhBYmAqK7H8vUpmzcXFUJU UE2AnQS26WEQAiHYDXhWJH5rY9yJk3rz0CWJHNQYZdxFlYSUrpncBYCjPzvQjLiTuIEk cVis+rQjULAngVabjA+XbDdCRC/4noZXe+TFtbYN4BQCJo5LHOOKW4tV7b2OZCLipQHj awskhwl48pZu6bf+Tr8N2TqgyFYwpOcCKzYcIuwl/K0EqSIAm1YcssRR6ANixb6JAP8f dBy5+7jEqoK+oBOYTBBajVKBXo98J+omNT3VPFy7Bce5ZlAVmnTyKZHorUC+AnynB3oO 2Mww== X-Gm-Message-State: AOJu0YyNaLdkgjQRLzAGV1dSehk895beLmyMFdvxk0sBhoffNPWOV7SW 45pHlHCP0Jnk+oZeKknpePU73sCWPSP6 X-Google-Smtp-Source: AGHT+IHY7P3AGtuprqqUV/dDekDb2kOfyGnlyTzMrT8+CEylyDp3RWzdk6ztQiyu+b0tkcWobWMgKFfrKVgj X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:44ad:3968:8aaa:c4fe]) (user=mshavit job=sendgmr) by 2002:a17:90a:a58f:b0:268:38e3:34f0 with SMTP id b15-20020a17090aa58f00b0026838e334f0mr1756657pjq.2.1692701906060; Tue, 22 Aug 2023 03:58:26 -0700 (PDT) Date: Tue, 22 Aug 2023 18:57:05 +0800 In-Reply-To: <20230822105738.1607365-1-mshavit@google.com> Mime-Version: 1.0 References: <20230822105738.1607365-1-mshavit@google.com> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog Message-ID: <20230822185632.RFC.v2.9.I5d374dbc818b209e911ef5fbf43de6df0d7ac40b@changeid> Subject: [RFC PATCH v2 9/9] iommu/arm-smmu-v3: allow multi-SMMU domain installs. From: Michael Shavit To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: nicolinc@nvidia.com, tina.zhang@intel.com, jean-philippe@linaro.org, will@kernel.org, robin.murphy@arm.com, jgg@nvidia.com, Michael Shavit , Dawei Li , Jason Gunthorpe , Joerg Roedel , "Kirill A. Shutemov" , Lu Baolu , Mark Brown X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230822_035827_322186_B471A03C X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Remove the arm_smmu_domain->smmu handle now that a domain may be attached to devices with different upstream SMMUs. Signed-off-by: Michael Shavit --- (no changes since v1) drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 +++------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 9f8b701771fc3..55c0b8aecfb0a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2564,13 +2564,9 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) mutex_lock(&smmu_domain->init_mutex); - if (!smmu_domain->smmu) { - smmu_domain->smmu = smmu; - ret = arm_smmu_domain_finalise(domain, smmu); - if (ret) - smmu_domain->smmu = NULL; - } else if (smmu_domain->smmu != smmu || - !arm_smmu_verify_domain_compatible(smmu, smmu_domain)) + if (!smmu_domain->pgtbl_ops) + ret = arm_smmu_domain_finalise(&smmu_domain->domain, smmu); + else if (!arm_smmu_verify_domain_compatible(smmu, smmu_domain)) ret = -EINVAL; mutex_unlock(&smmu_domain->init_mutex); diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index 1661d3252bac5..fcf3845f4659c 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -716,8 +716,7 @@ enum arm_smmu_domain_stage { }; struct arm_smmu_domain { - struct arm_smmu_device *smmu; - struct mutex init_mutex; /* Protects smmu pointer */ + struct mutex init_mutex; /* Protects pgtbl_ops pointer */ struct io_pgtable_ops *pgtbl_ops; atomic_t nr_ats_masters;