From patchwork Wed Jun 21 06:37:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13286744 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 2964BEB64D8 for ; Wed, 21 Jun 2023 06:45:02 +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=FUDd86Bbj/aoLrC28fhzeglulWpVPOmujdqZLoA4HpU=; b=lSWYexjWIwt8fxnR+tgu2hcYhH I/ZLvM9u/ZDNRxaNwgqXINTCh/tgKfVrGqamh/SGKrRhf6a19ERO0yy9Mpu3ok1cXC/O7Ylp7nz84 ncdKlG30OH/UihjJldnFingsWlqNYJnsZYw13EXY9Ngo5DnRv652E4neK/mV+qPRjJxoNQm8Zwb9K uQempthnyT/SywiIo61JsWg3dBV850ZWFWXm8mfFDNo4MDoyjKH2nrYhc7ZS8g8VskgF4wxh3C0qO Bbbyd2zZMLrSqrAhs7ZSC8rQWICG0P1ZnpAm89GawWBD/l1+XircgFvLfSVltnGR6FH4BEfPCuxXg CViwbBUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBra7-00DSdL-0d; Wed, 21 Jun 2023 06:44:43 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBra3-00DSZg-0E for linux-arm-kernel@lists.infradead.org; Wed, 21 Jun 2023 06:44:42 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bd5f9d084c9so6156073276.3 for ; Tue, 20 Jun 2023 23:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687329877; x=1689921877; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=tvomj7iW2UACU6/yECNbFWEXmb4EH1aV19zctsWiNw0=; b=bFIfZORz4qlyvHdesSBGaoACwrXyukUmDFr+sNMMwiGcbhJJOqX5vCINTCGVK/kqb1 M2pwDMPHBCg5EsNV8co3V/w8l6vhX4vTin9L9Y5GtkOrDe1gld2dyDd8Gs1HqLfNwdN1 G1FtBdPsy2NHnG2IC3hIdVsnPTWng2eGQ+qtojfzCdm1ORIt9R40o+eakI5Ec4ojnwqT F2VattLO/4nUSbZD2O/jFgdRuiN0pvkwRjTfp2vimZsBjB7peBN0fhLflu4T05WVZiO1 hJkx9W1oX0Pcb7kL4Ccd0fi2GEjiJaL7AxA3aaF5kFJsUz+3Ce+yO5GZBwoTHZZ/M+Ot GroQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687329877; x=1689921877; 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=tvomj7iW2UACU6/yECNbFWEXmb4EH1aV19zctsWiNw0=; b=byTxjomUfcGndbgtZtF1cxnBIuRzSioTUw10lvaStam3CJv6J77LxzK08QIUPiDeeg ROLKuJ5G5c8Lvn8GDJ2HV/CN8c1BLCFSEVbCCneyMTVpzIjfmbiL93gnRq3YMy29mFCs RI8FzWDo3JDNIGOSZqZpplu3ymNG2EfowztH/jcL1raSTCmAYxegl1KxKCeq+gv/RSRB VFhCD8UgkRwyHeSMJAzdP22SE9GfZyN/mtyNZsLYoJgDgjQDTOjtYMqQbs2i+GgFVVIb yw3f+6hVezHgkRE7YQ9WxI7GcIFM1QMD3a9ajsj6FnSXb/QlcOD5JVMuCKrZ79WoKdPZ tusg== X-Gm-Message-State: AC+VfDxHrVztQhi9yj3oitosgEekD565Zji8b2sLIIgmNEVNmm6JukHo hqm9vzTE/c1oZjLC0rwbjJMjeXut749r X-Google-Smtp-Source: ACHHUZ4Hv0OtvqUjdHD4vH+y719Y6q1CiVIktPp2laFj3DNmpEvjIkRNUnFgjTd048rLwQnXunTIxIImH8Cz X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:384f:f7da:c61d:5a3e]) (user=mshavit job=sendgmr) by 2002:a25:d658:0:b0:bbb:8c13:ce26 with SMTP id n85-20020a25d658000000b00bbb8c13ce26mr5885974ybg.11.1687329877614; Tue, 20 Jun 2023 23:44:37 -0700 (PDT) Date: Wed, 21 Jun 2023 14:37:22 +0800 In-Reply-To: <20230621063825.268890-1-mshavit@google.com> Mime-Version: 1.0 References: <20230621063825.268890-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230621063825.268890-11-mshavit@google.com> Subject: [PATCH v4 10/13] iommu/arm-smmu-v3-sva: Remove bond refcount From: Michael Shavit To: Will Deacon , Robin Murphy , Joerg Roedel Cc: Michael Shavit , jean-philippe@linaro.org, nicolinc@nvidia.com, jgg@nvidia.com, baolu.lu@linux.intel.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230620_234439_200254_DFC102AA X-CRM114-Status: GOOD ( 13.35 ) 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 The iommu-sva framework checks if a bond between a device and mm already exists and handles refcounting at the iommu_domain level. __arm_smmu_sva_bind is therefore only called once for a device/mm pair. Signed-off-by: Michael Shavit --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index d07c08b53c5cf..20301d0a2c0b0 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -29,7 +29,6 @@ struct arm_smmu_bond { struct mm_struct *mm; struct arm_smmu_mmu_notifier *smmu_mn; struct list_head list; - refcount_t refs; }; #define sva_to_bond(handle) \ @@ -377,21 +376,12 @@ __arm_smmu_sva_bind(struct device *dev, struct mm_struct *mm) if (!master || !master->sva_enabled) return ERR_PTR(-ENODEV); - /* If bind() was already called for this {dev, mm} pair, reuse it. */ - list_for_each_entry(bond, &master->bonds, list) { - if (bond->mm == mm) { - refcount_inc(&bond->refs); - return &bond->sva; - } - } - bond = kzalloc(sizeof(*bond), GFP_KERNEL); if (!bond) return ERR_PTR(-ENOMEM); bond->mm = mm; bond->sva.dev = dev; - refcount_set(&bond->refs, 1); bond->smmu_mn = arm_smmu_mmu_notifier_get(smmu_domain, mm); if (IS_ERR(bond->smmu_mn)) { @@ -570,7 +560,7 @@ void arm_smmu_sva_remove_dev_pasid(struct iommu_domain *domain, } } - if (!WARN_ON(!bond) && refcount_dec_and_test(&bond->refs)) { + if (!WARN_ON(!bond)) { list_del(&bond->list); arm_smmu_mmu_notifier_put(bond->smmu_mn); kfree(bond);