From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F7DB3A6B6D; Wed, 20 May 2026 18:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300660; cv=none; b=qqBoKduPBLGI+9tOwUGV2/v/HeX1+OFkDtDeYHSL+K1NB2xCpjeZQNhXKJUAruZ+eQYqKFCnt1FJ9I7R+mLegI2689kJJNTu6s6SAxdfmHENCthUMexH0MLVNAFOswc447F8BQt1U9b+vY1YABZKXnzI227rRUEPOuF42gc+3ZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300660; c=relaxed/simple; bh=nYnF6pGp/PNRU17YnpuSxKiVr+Yv+Fo4J7GQI779hSk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lT9f6ujJNO3O5gnvOFT17rRdMtY+xkaHA6+NtyJiTVTtWE+ZjI4bNKK4lhxCtgorjlUeRNhc4Q68NDGhXIArQS+AErdsmqbOy459sdLR/p+lyEUb/0b2YGErcXV700azStutV/VXvEGgmdmGVPx1dJ5wR2Vl8eNnxw1LPiJ/lPs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sWWHx9Ks; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sWWHx9Ks" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93D791F000E9; Wed, 20 May 2026 18:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779300659; bh=OHQA7b3gOlBAynpfZ7oPDrcsG/Fo4uA6k9IJol7Zwek=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sWWHx9KsCWrkhfGsqrndfbNgz8Hy+c3lRxjK83N87X9mVNHGdYC+eM9G5NAZ+y8pC RhF0eauJcAdGeA546HbBrfmr6bpjt6gLG/Sy2Igi66E3e1mNszayvUc9Iz2Y+2A7Qx DlGiXgyfa5TMQROb+lCutDS5fw7bErUa/2nB+Ir8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vasant Hegde , Suravee Suthikulpanit , Joerg Roedel , Jason Gunthorpe , Sasha Levin Subject: [PATCH 6.12 208/666] iommu/amd: Remove protection_domain.dev_cnt variable Date: Wed, 20 May 2026 18:16:59 +0200 Message-ID: <20260520162115.714804398@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vasant Hegde [ Upstream commit 743a4bae9fa1480e5f6837f6a55be918d6cd0e16 ] protection_domain->dev_list tracks list of attached devices to domain. We can use list_* functions on dev_list to get device count. Hence remove 'dev_cnt' variable. No functional change intended. Signed-off-by: Vasant Hegde Reviewed-by: Suravee Suthikulpanit Reviewed-by: Joerg Roedel Reviewed-by: Jason Gunthorpe Link: https://lore.kernel.org/r/20241030063556.6104-4-vasant.hegde@amd.com Signed-off-by: Joerg Roedel Stable-dep-of: faad224fe0f0 ("iommu/amd: Fix clone_alias() to use the original device's devid") Signed-off-by: Sasha Levin --- drivers/iommu/amd/amd_iommu_types.h | 1 - drivers/iommu/amd/iommu.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h index df2aa1c4fafcf..d5a689a4f4397 100644 --- a/drivers/iommu/amd/amd_iommu_types.h +++ b/drivers/iommu/amd/amd_iommu_types.h @@ -580,7 +580,6 @@ struct protection_domain { u16 id; /* the domain id written to the device table */ enum protection_domain_mode pd_mode; /* Track page table type */ bool dirty_tracking; /* dirty tracking is enabled in the domain */ - unsigned dev_cnt; /* devices assigned to this domain */ unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */ struct mmu_notifier mn; /* mmu notifier for the SVA domain */ diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index d0e53a03eff02..cf03fe0e8b083 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2068,7 +2068,6 @@ static int do_attach(struct iommu_dev_data *dev_data, /* Do reference counting */ domain->dev_iommu[iommu->index] += 1; - domain->dev_cnt += 1; /* Setup GCR3 table */ if (pdom_is_sva_capable(domain)) { @@ -2101,7 +2100,6 @@ static void do_detach(struct iommu_dev_data *dev_data) /* decrease reference counters - needs to happen after the flushes */ domain->dev_iommu[iommu->index] -= 1; - domain->dev_cnt -= 1; } /* @@ -2274,16 +2272,13 @@ static void cleanup_domain(struct protection_domain *domain) lockdep_assert_held(&domain->lock); - if (!domain->dev_cnt) - return; - while (!list_empty(&domain->dev_list)) { entry = list_first_entry(&domain->dev_list, struct iommu_dev_data, list); BUG_ON(!entry->domain); do_detach(entry); } - WARN_ON(domain->dev_cnt != 0); + WARN_ON(!list_empty(&domain->dev_list)); } void protection_domain_free(struct protection_domain *domain) -- 2.53.0