Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2230780rdb; Wed, 21 Feb 2024 00:43:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXV8DzRpAy0LundPf63nYMYbwy6nL2AhuaOHNnAHpVuUGoDpLOyD3bizd0fzVlCRSxvmXnuNYEQ5v5k7ki1s9gaoAExzyF/+dYL69L8ug== X-Google-Smtp-Source: AGHT+IF5K/2z4MmfrzTRbSsxXAbhbW+hrLrCNCUw6mWcxkpnIHFIUD87IsZJkniK4la9+kXx1RWM X-Received: by 2002:a05:6a00:93a5:b0:6e4:69ea:1f6d with SMTP id ka37-20020a056a0093a500b006e469ea1f6dmr9133643pfb.5.1708504993581; Wed, 21 Feb 2024 00:43:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708504993; cv=pass; d=google.com; s=arc-20160816; b=IP+7AlC4MfDIYp4YFlb7RVn0eF48gIBY8FA45dsUaOOP1rMECEc4iMVyaKiH8NdAR/ Z8F44d+ExIGB427xxV1nG/J5A3sEHb4l1KER9brHjTR0hAr+8EAuRGEPZK9BJCaZg85j Dk6uRB02J7N6TZvE1mWJgAlp4m8vCdULyxvBVHr+/uxFY/Wy3Gs7TtdFivam8RwERoWr ej0fkMkO6zNo4REnAIl7PXqG4RbXxfJo2uq+Bzr4c9sEbfFBzGE1PWDzQu7Z0FU2cxxm YH/UIT44jp2X4NIuVgP6inH93Ac/R+7yup+/P+uUOWMiMEFUgSLOnBGJbhIzldJ72HwM v2iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=5JFbebWnaOELZUkqxAEj6ANGpA9qZ0u3+xyV8xOnxaw=; fh=fyh6AlxGbMEOdXAXYh4g9wpci2RFta1LDpvrptcfNPk=; b=GAFm30xNTdQ01AKJcxUcEYUEyNMmExSNBkgokRM28A+wlTDhX42Re/xKJ8ClUUt5Et GVgP+cQofkkaQ34tb57tGKH3N4Yc1nDqFqWJWchO2KNbs5HvXwHDsuAxRBqetKQ35zlf T0+ugKqce7zUXiZYA3ehSrjPGG8e3gJ2zxzfYgMAvVE//mFmk0yDwyxSXLIU3F2o3Jek 5d6HoAZ+Bn1MaxKrFoeQ1dg1q8Mx6kL0C+0eA/4v6oe1w0OigJrj9ZrF0pdTf3Oyr/WQ Ogt2P/nYmFuO33H+K31XU04k056LyDP4G2qfygTOz9mpDlx0GL4EQjJ1SrnjYkVJivfZ WHbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PILavZoz; 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-74315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74315-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 cj22-20020a056a00299600b006e48313db5asi1992751pfb.83.2024.02.21.00.43.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:43:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74315-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=PILavZoz; 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-74315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74315-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 E9683B226D6 for ; Wed, 21 Feb 2024 08:39:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C82953C680; Wed, 21 Feb 2024 08:39:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PILavZoz" Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 14FAA3C493 for ; Wed, 21 Feb 2024 08:39:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708504790; cv=none; b=CPBv4C4eub0iemf6NGwy36nRndjX9Q97dInNwqKfjgVdZJQ8BPzSu/pnz938G6z25Om/UH0ezcgy+x/mEoLlWWnB2qdM8h1BuhPL2LbfdnHXVfuTF8ul+c+HFDGP58N3YBowmhj6zqMrKdxu7KkL8ZNLMajCiOJu7Lv92VuTi0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708504790; c=relaxed/simple; bh=GUsh6EFsJ7PPrJAD0y3jO+1W1vxjRmmaExeG14jW4aA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=D7hR7SVOSeGcgkFIEj9SC5/uD1CM3G/Rb7qpFKIw/6Tg6Hm+dqzPGwBzuL6gbs5gcFBJl6mCV0T9FVRimT0f6N/nB0x6tKHoJglIp90IutQZGIDXkUayEeHz0wag1RSv8jKWm34MzX6CiaOkWmV/u72PfJq9Rtqx7a7cGNijnog= 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=PILavZoz; arc=none smtp.client-ip=209.85.208.179 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-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d204e102a9so81441101fa.0 for ; Wed, 21 Feb 2024 00:39:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708504786; x=1709109586; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5JFbebWnaOELZUkqxAEj6ANGpA9qZ0u3+xyV8xOnxaw=; b=PILavZoz3pyY1OOjMzzYVHTQ1ob1fo+MyEqtB0EJ7swj/UzLkMDYaTiP+n61v0rC7K oSYNLs8w+GbtrtMxe66p/VSuavlQNRrMexNwOQnGInQuZX0/2GEXzUtA3/seJFpLYiNk RBPgOmArfT90TRsnnxzToYhdAIiCF0fDDgaC8hLzjaKZ+446BObLtI0l0sVM50KY1AZg Qrj7IPRGYMaIm7dGNwp1jmH9SDC0pZiNsMkosVyaqzlTMgh0wNOSGgOL6b8/ZbmtZ0PM 7qPqj1GUnCzDlXuVOkRyPYKNyZ+osA9pxo1HVT5PwLDMEOxX5xGvOTnR/yajYXclzPsN A2Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708504786; x=1709109586; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5JFbebWnaOELZUkqxAEj6ANGpA9qZ0u3+xyV8xOnxaw=; b=VvlGoZUPRrU9whVHFVYIg3SWYF3s0dvyRo1/8kTI8X1+UMXlRMmEAVoj9sajEabzoo CbJ69N+I0SqBQXzJhhZwlPUZEFBRML4BxDQMrT/4p6O6ZhuHKvMYXNjzJ7XV7k8PQL3+ HR/XJob6MI4d0l/aJEvV7rytTesfc51zI8TSD9LAjIyvSLcT+q+PV5x7fedhd8UQkHJM k0/NGcgEIKpRQiH/IbWpc9MUO1y+Hu6x9T0GkIMM3TFz2qSkpqN4vg9hHM6IaDXNddpr q2YMUusW9eXzzEhGH8dzKX9SzC+Mhv883qiJzNTbU6k91sMZ2NrWmAIDBULUFxiMVpPu dPXg== X-Forwarded-Encrypted: i=1; AJvYcCUxq4mFRZNha0J6hCr56RfA/gdfi1SRHGv9ZL+zlj5mStUkgf97qChbP8IquMlusRBIGZWqWnJVxNvmEXRJRAAEBQFpHd/bCnG1fUBZ X-Gm-Message-State: AOJu0YxPL52wdaSs8AM4HcABIH9YAhfq1ViYpM/NO8056ZrdCahkc6Q5 bfPVkvhrPtUEV3Z+WABoFqvU+111F6+h5abDcEhOr4u2IRZI6J4w3x58Jb78GlGU5lb4fl2IPKq CKxgfU8+6Xv0VI/o7itYoiNoPIhPpMMk7l8Wbkw== X-Received: by 2002:a2e:be21:0:b0:2d2:289f:16f7 with SMTP id z33-20020a2ebe21000000b002d2289f16f7mr8827955ljq.49.1708504786146; Wed, 21 Feb 2024 00:39:46 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240221061832.430-1-zhangfei.gao@linaro.org> In-Reply-To: From: Zhangfei Gao Date: Wed, 21 Feb 2024 16:39:34 +0800 Message-ID: Subject: Re: [PATCH] iommu: Fix iommu_sva_bind_device to the same domain To: "Zhang, Tina" Cc: Joerg Roedel , Will Deacon , jean-philippe , Jason Gunthorpe , "baolu.lu@linux.intel.com" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" On Wed, 21 Feb 2024 at 15:59, Zhang, Tina wrote: > > Hi, > > > -----Original Message----- > > From: Zhangfei Gao > > Sent: Wednesday, February 21, 2024 2:19 PM > > To: Joerg Roedel ; Will Deacon ; jean- > > philippe ; Jason Gunthorpe ; > > baolu.lu@linux.intel.com; Zhang, Tina > > Cc: iommu@lists.linux.dev; linux-kernel@vger.kernel.org; Zhangfei Gao > > > > Subject: [PATCH] iommu: Fix iommu_sva_bind_device to the same domain > > > > The accelerator dev can provide multi-queue and bind to the same domain in > > multi-thread for better performance, and domain refcount takes care of it. > > > > 'commit 092edaddb660 ("iommu: Support mm PASID 1:n with sva domains")' > > removes the possibility, so fix it > > > > Fixs: '092edaddb660 ("iommu: Support mm PASID 1:n with sva domains")' > > Signed-off-by: Zhangfei Gao > > --- > > 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 > > c3fc9201d0be..a95c8f3a5407 100644 > > --- a/drivers/iommu/iommu-sva.c > > +++ b/drivers/iommu/iommu-sva.c > > @@ -91,7 +91,7 @@ struct iommu_sva *iommu_sva_bind_device(struct > > device *dev, struct mm_struct *mm > > /* Search for an existing domain. */ > > list_for_each_entry(domain, &mm->iommu_mm->sva_domains, next) > > { > > ret = iommu_attach_device_pasid(domain, dev, iommu_mm- > > >pasid); > > - if (!ret) { > > + if (!ret || ret == -EBUSY) { > If rebinding is allowed, how could IOMMU core know if this invocation is intended (like the multi-thread case mentioned in the commit message) or is mistakenly invoked? I think it is the purpose of refcount, it should be no difference whether same device or not. Even different dev, IOMMU core can not make sure it is intended or mistakenly invoked. Add the limitation does not make sense. Thanks