Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1748391rbb; Mon, 26 Feb 2024 22:49:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXfdRbZCGJKjHnPSv+dwXxfzizFfH1t8AYY46OUHzkLpq/J/Br98jBazZtphISM18oiHsrvaX7tXE+HlGaMNJKJrqPUxg1cU9YezHMLUg== X-Google-Smtp-Source: AGHT+IGjKB97S039YUPEc7vXP9TPwWSGaN+u9STMgeoXSN71kMAciTtLkqLpgaS9ndLIPeOl0zK0 X-Received: by 2002:a9d:6a05:0:b0:6e4:545b:3bb with SMTP id g5-20020a9d6a05000000b006e4545b03bbmr10308703otn.17.1709016590901; Mon, 26 Feb 2024 22:49:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709016590; cv=pass; d=google.com; s=arc-20160816; b=mkW1S4vopFTnnl4/tw8uFpXNVy7AGX7PjeO5O2E9J9493Ju/frA15qFu0wOuy+XByF aNxPaKQcOxXO1+mahSwlXA3uWT+Z4UQmCz/RfTraoE6yB/1DmszDb8X6NHdyGv9m1D/x o/Gn3JCuyXCNBOJRC7+gWh6PozeHxVhGAf2uC4iNBFkeH/zet2EMY83j/c6VfqSMWIRm BJVYEIPNFTAnXt/c93Nerc/UwAPpz5erxEmRzn/TtqMwnHnZvwCpLzLwIETJAMo00v7/ K2hFQe6j3mP5FMYZ9+uhdBUQDVo/dQ3GZzE3fUsW1XJh8FzmtcjFYem6AMxVT+iRzsJS qSzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=6FBYjN6sLTi7L4W/93/wTWpFgwkV8FUHLIcwh/+Iuvc=; fh=MGTJ/PcDtolugrHu7coRXN6pZpMhXRJ7ByrWc12tNTg=; b=ToX8eEkB83c49fcdFB6BCEGYS7m15Y8QDZTz81jWRjGfBeRxO3l5XNLgwcDBZJ/0Eu 1FiUQYQkCiQ5h8cjRq1i/1utETFIPjDxZ5IiaPSG7zLuIUaUVjXC5QYhWwa9ITLOFc/+ cWBw7j9VwPv4eYrenclTblfp8tTOqjzzwnDCAwNCwvpl4ho84se7LM4klwzBSLaXOE84 2YtsTChzbI/FRxURZdQJ5ysBj5gHcgSckCCGAJ+QPlvmX4PxXserBdphiVkbj4DRkDNH nYfBF6jQipEJC9yIdoNiMKhOOuCCu+7srWsaU89avYn4oD9gtLHIAFAnO0GP5vnqo5IR tSwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dd26fzy1; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-82760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82760-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q19-20020a637513000000b005ce0474353csi5016160pgc.238.2024.02.26.22.49.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 22:49:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dd26fzy1; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-82760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82760-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2B29BB249E9 for ; Tue, 27 Feb 2024 06:48:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D77295339B; Tue, 27 Feb 2024 06:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Dd26fzy1" Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F93353388 for ; Tue, 27 Feb 2024 06:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709016514; cv=none; b=b+c5yb42NQG+BBD0CwPDB1dtTqXeDpVQglHExYzP91vULywLJ7C1XAzcZmaFwbfUww5RRyo8h0DpvQ3NcLwWDIFUsRm2GIuCqRzEwEOJp+Y419iNejWo2oRsrb8Imxs3Y4FPGTJN8DNmjpBecSJ0FA+uhaAWYVSjVZ08ZYEvj4w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709016514; c=relaxed/simple; bh=gAZmDrTV3gdyDJKZeIBaeyHPyu+CA7GYjfEYzBnrUmk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=uyqFNvzKboJiHYCbdCQxgDs96Pfbm08e77XSN2dMAB5+bzC6AuDpKUhwTNnis8gZ/NhvEVBBXmwiv45KlHuS3/rrW/aViQ36LR1udgpm2QYJQ4izfNKjpMXDHPcHkXdR4+EBbXRN2gzMszn7ojkW9f0s8ki+jYGaWlQnx3YsK7k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Dd26fzy1; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3c19e18470aso1539688b6e.1 for ; Mon, 26 Feb 2024 22:48:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709016511; x=1709621311; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6FBYjN6sLTi7L4W/93/wTWpFgwkV8FUHLIcwh/+Iuvc=; b=Dd26fzy1QUAT4wMOv5svkbmLPrnltN8NjAXGlcQAo2RZJeb31arZ7dzhq/xTvn32vz IXLfo/o+T0WgVWP4NsW/WFx59vcnr6fxrkCm2MvtQBmPvCh/vtXSOJ6CGj385xrIQueN ut+rnpgT+PeouIfYrxfyMdXQC2rcsIyJtqwqdpbhuAQQV7KIYt0WDO4v7l1xQY43UDmT S80RQvfsf4s6EQOTY9aQ51Mi2Z18JUF0+PiMHCRArnIp2NaUSCnZID8x7oE56tTP0/Pg wnkTLVOJsZxCVU3NaY7bDW5qSnVdzpZSkyt9I/NeR2lDUnfTJ+P9UPChEB1Qw+HVC1l9 WlLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709016511; x=1709621311; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6FBYjN6sLTi7L4W/93/wTWpFgwkV8FUHLIcwh/+Iuvc=; b=HxZgnHMZEee+p2e3s7Ar0SXy38pB9XB2Che4qFORJ8uI9OHL4VIzp73oLsfiwkjXKm eZs+H1zPcXUjNuO0TMJCaAwUtWP7UHBCToW5ObhNGG+8mQrDobVihq3i3I1w7/OVRIrP 6YvgHolO82Nvv5JeD7WeSIouK1GJYD8Pr4fWJmqRmR4OOmmFovAsBmBpx3qOEpDh+1Xl uHck31vBWEphM5TsUeo/00rh/4xX5uJ6h0YgcC0pcCnq4Ro4vfNY3XSYA56pBh9x/GQ7 WTxEWujYCVlA7x4wNrOj1+QkOkvkhynCEFyIR02/Nv1NLCqbklXP1Z/V6aAVOCsSeK1t XGxQ== X-Forwarded-Encrypted: i=1; AJvYcCXoPbxujtri6aszLpFgvptwiyHv35wSLiEfghZzI/vbhhnCsnDtdM+nyTUOX5940wrXkXdqa0jDL8ACV0iXvpiYb9sli2c8ik3ICKGs X-Gm-Message-State: AOJu0YzXx6EceF0V8WW4XC/N2V419oNRTZv3VquUs51ZZZOx5MzXprzA kLYOYnwsVNaaVIUM2z4X3/l6HcD/Y4tCD+zaVsQN947n9Zgz+Fl6/DRDgiVjzHY= X-Received: by 2002:a05:6808:1a1e:b0:3c1:adf7:c169 with SMTP id bk30-20020a0568081a1e00b003c1adf7c169mr1037171oib.4.1709016511725; Mon, 26 Feb 2024 22:48:31 -0800 (PST) Received: from localhost.localdomain ([114.103.193.174]) by smtp.gmail.com with ESMTPSA id k2-20020aa788c2000000b006e13a88d52esm5107113pff.61.2024.02.26.22.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 22:48:31 -0800 (PST) From: Zhangfei Gao To: Joerg Roedel , Will Deacon , jean-philippe , Jason Gunthorpe , baolu.lu@linux.intel.com, "Zhang, Tina" , kevin.tian@intel.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Zhangfei Gao Subject: [PATCH rc] iommu/sva: Fix SVA handle sharing in multi device case Date: Tue, 27 Feb 2024 06:48:21 +0000 Message-Id: <20240227064821.128-1-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit iommu_sva_bind_device will directly goto out in multi-device case when found existing domain, ignoring list_add handle, which causes the handle to fail to be shared. Fixes: 65d4418c5002 ("iommu/sva: Restore SVA handle sharing") Signed-off-by: Zhangfei Gao Reviewed-by: Jason Gunthorpe --- Based on rc6 drivers/iommu/iommu-sva.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c index 7f91c8d0064b..65814cbc8402 100644 --- a/drivers/iommu/iommu-sva.c +++ b/drivers/iommu/iommu-sva.c @@ -117,11 +117,11 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm if (ret) goto out_free_domain; domain->users = 1; - refcount_set(&handle->users, 1); list_add(&domain->next, &mm->iommu_mm->sva_domains); - list_add(&handle->handle_item, &mm->iommu_mm->sva_handles); out: + refcount_set(&handle->users, 1); + list_add(&handle->handle_item, &mm->iommu_mm->sva_handles); mutex_unlock(&iommu_sva_lock); handle->dev = dev; handle->domain = domain; -- 2.34.1