From patchwork Mon Jan 9 01:49:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 40609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1932550wrt; Sun, 8 Jan 2023 18:02:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXusP2qWPlArlgTsU6ngorKjOCF1+ezU5Pbjl7fKxba9/aJOs0PDj93I7cdB26Ly0xoMklLz X-Received: by 2002:a05:6a20:13a8:b0:b0:a35:b763 with SMTP id w40-20020a056a2013a800b000b00a35b763mr100141662pzh.5.1673229729924; Sun, 08 Jan 2023 18:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673229729; cv=none; d=google.com; s=arc-20160816; b=NZcvMS6/5wS/EdX8m/5STZlSn+RH0mcJkaPu3WIXiQHZssPASkJjU8Z+9THUaTA2x8 sGmYS76dSxuyvzNa9CvPHW/2js56khJx/IfiQ+C84gQ7U3ivvEQlYJc8v79QpDoc9UAN j4Rll24Ygh9MZ+Gk+dT4XPXoMSg1CBsqXYMseQfuUfWbtxGgvpJWBp4NArfk3GM9h/VE Tvn8wWpqR5i2atBXYo5gN29pyGLD7i6laCQyPqh7vff9T/WOpGivRBhVDWaRdjay+YfT X8TTMHKastfwxiB8nelhiKjFa7c0DB5+EUwuYvlKCHTAmDb+tr5HqmSnM1YBN/WcfH5v SHAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P7Kx4wKb1/N7ZT5r42pIsvm4ZP5DsjxPW0iifJFh+kY=; b=Z0XqxlryuLZ2snUiSWH+S3Cpzx/0ZlrHKEFCtgUKO9I0i0P54UGWBm2R4FCWigqSyb tjApMbNIrHVkEUYjqG+r3o8HM2XtTZDQj3omWBKdeNLo4qhGPJEnjRXjkK8gRB5p+OMY kU6FjQNwCOiH/F7lkEIUTZ+wNp2Osezh3Jt2nBQ9rUVtHZzQWEuetNu6eV9rhSf8Egit GE5WGCS5V+DnOKWsNUVhQe5uJLl8K1PY6cNtmK6CekuTxNl6lPbr/n3t+G+hC06oCkVT eYLjCkyGb65zHyqcVE9J9vRG61TA6zyDrZ8sM/h8/avVAGbtqT+6DTc7E+qJAfGM6ZN3 K93A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OZAxV0Rg; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v14-20020a63d54e000000b00477d314a66fsi7956032pgi.585.2023.01.08.18.01.56; Sun, 08 Jan 2023 18:02:09 -0800 (PST) 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=@intel.com header.s=Intel header.b=OZAxV0Rg; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234142AbjAIB6V (ORCPT + 99 others); Sun, 8 Jan 2023 20:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233961AbjAIB6F (ORCPT ); Sun, 8 Jan 2023 20:58:05 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AB62101DD for ; Sun, 8 Jan 2023 17:58:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673229484; x=1704765484; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nBq2eOVotOHuuNbaX+AJBZNl0TFASfXTuzkriWWUcT4=; b=OZAxV0RgsEE3PyfJOVwOolCjD8lee4F9jRvEJ4E/VcHJly74mZhbr8vi WUh20d8415JsoO+3wwPYWCOkbqqubJ4VphYL+BDelKcSpiVra08DDWQfY /h6+tTwrGk3Ousw5iumSwlHF+yH4OgRY7j77AgLPP/rIwtMUlUmOukSwG GYOayvaH8Pw/ub1nWpsMTzErqJxWCSf636e7KkHe8B6JorfpHLeyrqDeX 2ZZQ71YFeqHVDH3lcuaM2oJ/5128OJc7q718PUnVYN8KHPnhKM4yhfayM Y3z2kYyTCVuJ92l6jVZNPQNSFk6pXgkPylmaYSvL9x6w3GJMv7+pdfYNJ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="322848746" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="322848746" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2023 17:57:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="649867438" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="649867438" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga007.jf.intel.com with ESMTP; 08 Jan 2023 17:57:55 -0800 From: Lu Baolu To: iommu@lists.linux.dev Cc: Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 4/4] iommu/vt-d: Remove sva from intel_svm_dev Date: Mon, 9 Jan 2023 09:49:55 +0800 Message-Id: <20230109014955.147068-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109014955.147068-1-baolu.lu@linux.intel.com> References: <20230109014955.147068-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754508537564556548?= X-GMAIL-MSGID: =?utf-8?q?1754508537564556548?= After commit be51b1d6bbff ("iommu/sva: Refactoring iommu_sva_bind/unbind_device()"), the iommu driver doesn't need to return an iommu_sva pointer anymore. This removes the sva field from intel_svm_dev and cleanups the code accordingly. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.h | 1 - drivers/iommu/intel/svm.c | 23 +++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index 2a1619ff0d79..f0222ad38757 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -761,7 +761,6 @@ struct intel_svm_dev { struct rcu_head rcu; struct device *dev; struct intel_iommu *iommu; - struct iommu_sva sva; u16 did; u16 sid, qdep; }; diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index c7dc53e40c26..e7b9bedebcc0 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -298,9 +298,8 @@ static int pasid_to_svm_sdev(struct device *dev, unsigned int pasid, return 0; } -static struct iommu_sva *intel_svm_bind_mm(struct intel_iommu *iommu, - struct device *dev, - struct mm_struct *mm) +static int intel_svm_bind_mm(struct intel_iommu *iommu, struct device *dev, + struct mm_struct *mm) { struct device_domain_info *info = dev_iommu_priv_get(dev); struct intel_svm_dev *sdev; @@ -312,7 +311,7 @@ static struct iommu_sva *intel_svm_bind_mm(struct intel_iommu *iommu, if (!svm) { svm = kzalloc(sizeof(*svm), GFP_KERNEL); if (!svm) - return ERR_PTR(-ENOMEM); + return -ENOMEM; svm->pasid = mm->pasid; svm->mm = mm; @@ -322,14 +321,14 @@ static struct iommu_sva *intel_svm_bind_mm(struct intel_iommu *iommu, ret = mmu_notifier_register(&svm->notifier, mm); if (ret) { kfree(svm); - return ERR_PTR(ret); + return ret; } ret = pasid_private_add(svm->pasid, svm); if (ret) { mmu_notifier_unregister(&svm->notifier, mm); kfree(svm); - return ERR_PTR(ret); + return ret; } } @@ -343,7 +342,6 @@ static struct iommu_sva *intel_svm_bind_mm(struct intel_iommu *iommu, sdev->iommu = iommu; sdev->did = FLPT_DEFAULT_DID; sdev->sid = PCI_DEVID(info->bus, info->devfn); - sdev->sva.dev = dev; init_rcu_head(&sdev->rcu); if (info->ats_enabled) { sdev->qdep = info->ats_qdep; @@ -360,7 +358,7 @@ static struct iommu_sva *intel_svm_bind_mm(struct intel_iommu *iommu, list_add_rcu(&sdev->list, &svm->devs); - return &sdev->sva; + return 0; free_sdev: kfree(sdev); @@ -371,7 +369,7 @@ static struct iommu_sva *intel_svm_bind_mm(struct intel_iommu *iommu, kfree(svm); } - return ERR_PTR(ret); + return ret; } /* Caller must hold pasid_mutex */ @@ -843,13 +841,10 @@ static int intel_svm_set_dev_pasid(struct iommu_domain *domain, struct device_domain_info *info = dev_iommu_priv_get(dev); struct intel_iommu *iommu = info->iommu; struct mm_struct *mm = domain->mm; - struct iommu_sva *sva; - int ret = 0; + int ret; mutex_lock(&pasid_mutex); - sva = intel_svm_bind_mm(iommu, dev, mm); - if (IS_ERR(sva)) - ret = PTR_ERR(sva); + ret = intel_svm_bind_mm(iommu, dev, mm); mutex_unlock(&pasid_mutex); return ret;