From patchwork Thu Aug 17 18:16:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13356871 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 84587C3DA58 for ; Thu, 17 Aug 2023 18:22:35 +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=Zha9+yymFcRyNRg2U1PByNCmN0wJzNkP6zeuaxjLUYw=; b=XrxmF9Mz6nMd/Iy4WRkZDjchPV 9gzXewxnJ58tsO6nz/5nizcq5e0g7HwgeHMse0ZTwTb5EJ7R+Jx9mcy6Z6a0UL4u6sK/O5pEY2/48 KYoTXt65tikKaeLiW7YMJ4C+F8B+VE15u/tBf+A+JWdUeEQKLcLnbFc7+70SGFin7BOLAvoMvJjbt h0NN9CNlHcXMU22StR8HpFaKZ+SkhXBAzULHxla/Z/F7aC5bI2deBkcIbJ+StwM85qWDLiw/0+0id UbRjbnmI2/omNJ4YxUylYT35NDezArtgQOdOeAA4KdPkQC8Ivbv2CRIZekhO2LvNUU6bNJhyw+0Jb i1Y+Jj2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWhdJ-006xhf-2R; Thu, 17 Aug 2023 18:22:09 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWhcz-006xX2-37 for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2023 18:21:53 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-583c49018c6so1534267b3.0 for ; Thu, 17 Aug 2023 11:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692296505; x=1692901305; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=oBooMpaGlkQ+FKKABWmvIlNH9aUPRTcSS6CTCMQ9kRM=; b=IU2UOZ1QAkZfOcMGg5vcsJJHh9ZQj9hhxtEDAYymf3rWNhFaqWW+6INaMkoyKxt/oE Kaqvuj+X/pxgIK2TiTFUz0WzsHSgyKWS2ZHyj2Hj43tq7Hr69oibRlmjOv8YImpM7OIV 9u3bHZgKiIQbgOPeaKpTQ+kaemWaVvBB3iWU+3PEWGmyQY6v+wO7PHV/kAo4zw+G1ugz mhFC+iuG27Yd3uMkvWXhaPZhcM8v7uoVO4GDfIWF9C6ZmyyycifTgv9BjPqaUlTr8GVS r6LVXt1zs+RHdu5RadGCtpslOLsMzFZd/mXaGR/d8Zfs3hVW2VKBl03OxCrI41Dupwpr gSAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692296505; x=1692901305; 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=oBooMpaGlkQ+FKKABWmvIlNH9aUPRTcSS6CTCMQ9kRM=; b=IYiW+IYYI7NJ8qdo/Hzb41aTJL6RDJijiqs1u89ZJr6MkrfoPcvBkzx9Y4cqA2kph0 tDBlbfWaH6TB1lswASurPS/YZr+cX5P3a/wYo8u2QVC1Rskvt0MJNDNJksSuZJ6jYYXS hxPhBYumHxXgdfCDUNhGkhurUM6hP0Kky9efFHptWKX8cfYWiEGroYtrNnWL0wUYEhJu MfJvrsqScvM+SYHBmAqi9FDqQdjqzArRGnuCYuQrOG9GZde4R31TkO90DRACW3ntWe00 QebYBrodikO7dbtiRcCAMa16LD8yNteTgkNRTcKNbefIDEz5dtK3NxOc0A8NOceYE6IO jypg== X-Gm-Message-State: AOJu0YxIU1FQwymawBAvTp3x3XynpiZ1MVKkmX7CqNeUyh+9jCg2UHF1 ZzCJOAQ8TiRo4wooUzc3etq80P1uvcTa X-Google-Smtp-Source: AGHT+IEqqWWy632gyVQWnMmINQsSMRfInztWWbMpGG+vOabJBtHCJeGHnGFeZG2cljxVwoXwgg50KcnBmYwN X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:4a77:fd20:7069:bdf9]) (user=mshavit job=sendgmr) by 2002:a25:494:0:b0:d12:d6e4:a08d with SMTP id 142-20020a250494000000b00d12d6e4a08dmr4183ybe.7.1692296505437; Thu, 17 Aug 2023 11:21:45 -0700 (PDT) Date: Fri, 18 Aug 2023 02:16:30 +0800 In-Reply-To: <20230817182055.1770180-1-mshavit@google.com> Mime-Version: 1.0 References: <20230817182055.1770180-1-mshavit@google.com> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog Message-ID: <20230818021629.RFC.v1.8.I5d374dbc818b209e911ef5fbf43de6df0d7ac40b@changeid> Subject: [RFC PATCH v1 8/8] 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: will@kernel.org, jgg@nvidia.com, nicolinc@nvidia.com, tina.zhang@intel.com, jean-philippe@linaro.org, robin.murphy@arm.com, Michael Shavit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230817_112150_025569_954E008B X-CRM114-Status: GOOD ( 12.93 ) 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 --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 9 ++------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +-- 2 files changed, 3 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 c9f89f4f47721..08594612a81a8 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2587,13 +2587,8 @@ 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) - ret = -EINVAL; + if (!smmu_domain->pgtbl_ops) + ret = arm_smmu_domain_finalise(&smmu_domain->domain, smmu); mutex_unlock(&smmu_domain->init_mutex); if (ret) 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 143b287be2f8b..342fa6ef837ab 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -726,8 +726,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; struct io_pgtable_cfg pgtbl_cfg;