Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2537685imi; Mon, 25 Jul 2022 00:54:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s7/qfzsDozftTwipWnY2tY6nP5z4CkjYr1uJApQK+ErqUzcglHKd2ZsF0hT4PcXWNrr04e X-Received: by 2002:a17:907:69b0:b0:72f:6380:4452 with SMTP id ra48-20020a17090769b000b0072f63804452mr9193466ejc.88.1658735667827; Mon, 25 Jul 2022 00:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658735667; cv=none; d=google.com; s=arc-20160816; b=mvd7PdGJxw+ePZit/Sp/ZSxxqJpmr6Iy4iiVYRoIWJjjKUfX29nor/D2SGxm+43l+U zt9etTwzUrMKanORcMuDk1t1A2z/nzyS0WO37Pq26V1EzdeQz65LEFaVb7baksp6QyiG xqc2pOSMLbHelnj9ziEm0N+AeqlDMi4VyacqJPzX9Yuc7eqrredTmKThtd6KU5VLKRQA 7w0Ye8Qv2M3Y8lfo+iaPf+ac/CSZmiWYgxVTY7BlIr2ExGVTT5DsOL+4n0LHicYwFRdB cDwZDlsNWed5Wrqj3H5hgo2zVaNT7U/uUoJXpQ5rwcO77Xc+iKuMak0oKp3oeMq9HNbZ C9Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e1aZ+o8kUOGYYPE2I8Uql3rIMOoNeVnZ6eovO9V2SYI=; b=EB51dh4AHw3O2FQhCtx0kA5jOcv0WvAo7T+L7ergx5sr5Py1ku5eGJplKHsdCBKnK4 FfbhyWfHRJt8QCVYCiiekdEB1emTomVXqz0hKZ0nAtEdwpqWcfWx+fKvxrJXXjCB0YgI Xw5zDTfWqGJcmG4ixbhDqo55kzObuWfqdSPniRWyN6tKQGrV0Spsu5MVxr6/j9tWq/b3 i9OyCkHk4FxVFRsnKl8pdXxvW1ICfQx+KZPZCZ5PDV/U5sDpJ+i+vGYgLQ39CDQRlnCg 8MrNq9ZNY00Sx9PkG6tI5aNw5z8XWz5AV35zc3+64lzRKNYyJugnR5I0jVMKQHESoJC6 Qc5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e0kcc9cM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd25-20020a1709076e1900b00718c04a51a5si13917270ejc.591.2022.07.25.00.54.03; Mon, 25 Jul 2022 00:54:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e0kcc9cM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231127AbiGYHjy (ORCPT + 99 others); Mon, 25 Jul 2022 03:39:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbiGYHjx (ORCPT ); Mon, 25 Jul 2022 03:39:53 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4247212091 for ; Mon, 25 Jul 2022 00:39:52 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id n185so6238879wmn.4 for ; Mon, 25 Jul 2022 00:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=e1aZ+o8kUOGYYPE2I8Uql3rIMOoNeVnZ6eovO9V2SYI=; b=e0kcc9cMVIDcngDRSTaZnB9OpBUCxX3qmlG7Rf8UF8KxVdSSsYTKRRoayVBXIw3Sng wu03r67IdDvHjuKRBxBG/MxS7zaI0Fo1WODf40DlybOy4RWF2zFeZBXFfeKyNY0k3tY0 9acd2YlEjpByWP6lqxFmT8VFC6fWMD8ow89/760tUyLKH0o9qeiprvAj+2sNGlgZhJZI P/HxJLpuRxogFWVWPIjIQAFfo0PO7Gp9AJcrqgFGB0IZOyTnjDFWfH0tafCnnyRMGVx7 qdcnwKIosMyB5F+UvM7GWAw6I/korbMgwAcezOoI6zLqC6A5RcxfoKxbs4WKBmEsKJwO BYPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=e1aZ+o8kUOGYYPE2I8Uql3rIMOoNeVnZ6eovO9V2SYI=; b=Bccz2s2pLLYS6ZovlsWDK6q6rB4Wx9BQEcRMY8jmXGnHEc10/crHz94KKUJkixAEmP YNyVuP7JXlQJ8sF07LDswiXbUyUcFhmq3/lp4HAfdyNPIuiKdYCkr1FyEc3GNkGyJ3F9 US0ABZ2WC162vuJ0xtMo1OvDztyfdVuZGs6vgvWhVimgb5ZEEyZFt+Joo7CfblXzPivW PpAHIeAwwYLcoXSHzhStjWpZiiW6xzvqrqoqauLcgBw/83aSsXr5ICKujfR4wG3WVP1O JFrRl/Ty+RzMjySBJLhHikBClkS7E08XscCM7xvfo/R6LXYc0913x7/X9SqR5QZszgSS mkvg== X-Gm-Message-State: AJIora/G13Va8EukTjAVpHFRLjKi/lypk3+ewi/mSMySbVbpXxDnfAwn kAxWMZpUGrIdCMXqSb+TSLhz6A== X-Received: by 2002:a05:600c:17c7:b0:3a3:f1:148c with SMTP id y7-20020a05600c17c700b003a300f1148cmr20833043wmo.32.1658734790751; Mon, 25 Jul 2022 00:39:50 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id f9-20020adfb609000000b0021e519eba9bsm11085090wre.42.2022.07.25.00.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 00:39:50 -0700 (PDT) Date: Mon, 25 Jul 2022 08:39:23 +0100 From: Jean-Philippe Brucker To: Baolu Lu Cc: Jason Gunthorpe , Joerg Roedel , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Vinod Koul , Eric Auger , Liu Yi L , Jacob jun Pan , Zhangfei Gao , Zhu Tony , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 08/12] iommu/sva: Refactoring iommu_sva_bind/unbind_device() Message-ID: References: <20220705050710.2887204-1-baolu.lu@linux.intel.com> <20220705050710.2887204-9-baolu.lu@linux.intel.com> <20220723142650.GH79279@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 24, 2022 at 09:48:15PM +0800, Baolu Lu wrote: > /* > * iommu_detach_device_pasid() - Detach the domain from pasid of device > * @domain: the iommu domain. > * @dev: the attached device. > * @pasid: the pasid of the device. > * > * The @domain must have been attached to @pasid of the @dev with > * iommu_detach_device_pasid(). > */ > void iommu_detach_device_pasid(struct iommu_domain *domain, struct device > *dev, > ioasid_t pasid) > { > struct iommu_group *group = iommu_group_get(dev); > struct group_pasid *param; > > mutex_lock(&group->mutex); > domain->ops->set_dev_pasid(group->blocking_domain, dev, pasid); Please also pass the old domain to this detach() function, so that the IOMMU driver doesn't have to keep track of them internally. In addition to clearing contexts, detach() also needs to invalidate TLBs, and for that the SMMU driver needs to know the old ASID (!= PASID) that was used by the context descriptor. Thanks, Jean