Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2372196rwl; Sat, 1 Apr 2023 06:47:00 -0700 (PDT) X-Google-Smtp-Source: AKy350Y/tneBTYVXEPQHL9MaQsQf+UHyLi9uh298iBLLulf9/JmwjRVd3wMuXypgp/ezdRXvByQf X-Received: by 2002:a17:906:f294:b0:932:a14e:4c57 with SMTP id gu20-20020a170906f29400b00932a14e4c57mr29750021ejb.76.1680356820509; Sat, 01 Apr 2023 06:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680356820; cv=none; d=google.com; s=arc-20160816; b=yG9ofWgsfOrKT7aHxxGw5gRMeYR0crNVou1+AgJPXUH60MvW51VPt433jR+EH3z9x5 pX5Z+mDZsxcyXxsaAoeDj9l7byTMyaLUvsNOpWYFag25rLdQ0IFln5RCMSaijI12akO1 5IXNwwa/7O0svhHA5MdKe14vsNal5w7H6ojoN0PzF6gY4PB0vDKPaZ03X9OR02d7Iam1 Uf6XnmCW3BpO6yXVrr8ZusX3sNxkfc9dsWEiuizVZ0TLyhNg4xOUOI6iAFNEBRMpUHuV 9zk07u/mOSSF28aUVTfBjriBszHpmFYTSANQexzGlrvdcT1/gVIRxd2U17YtzCa3JVtY eglQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=ThP/V3JjFrBLGzL7GhPehRESjCpWArypugIj+mwfEXI=; b=LBh5suDsrx8xnlENHOkOI4n8Xg9+62BCYXAPZpqJScB915qD/gCjCOdk2Ktuquhu0w R4XfU+Pq/OiFArF2maVJtgX5VaHgmu/cg3j1jSX8oIJ7X43ogrURzXGXHrpV37D+3XAr iRvbI7VnEtcRvU/T9yFbROX9GP14Pl4rcB8wNSFa+wL1PtbSjVlQNVDoWDNjhIDCjnJ1 6U32pdBh3+v887k2LveXrVaum79PGBxawJCR2z/0/mgPfslO3DyP6Yl1AVoFA/GZjHTF r22iSJCEan+ndopzJ3y9+eBm0kb6iybIrMF1EMw7jh+RFkktm9MBPaEqWGGj30h0TkJX Vhhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lmSZOabw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a1709061e4500b00932e6d5bd8asi2931646ejj.980.2023.04.01.06.46.35; Sat, 01 Apr 2023 06:47:00 -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=@intel.com header.s=Intel header.b=lmSZOabw; 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 S229963AbjDANjm (ORCPT + 99 others); Sat, 1 Apr 2023 09:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjDANjk (ORCPT ); Sat, 1 Apr 2023 09:39:40 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72EA7191E8; Sat, 1 Apr 2023 06:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680356379; x=1711892379; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=uUCZhoSNiRXoLoz4XiiHkdrKLRqbdL1JjvL+YhsnEOQ=; b=lmSZOabwME5cYIopbi/5u/8RwpoLyo7F6h0dRmJsi1Lstv/ap3XvE0TL vBylJbY+AS6XZqaQiAfh/FaPI8h0UWJCFIOLtUPcNLyUxKzEJ8Tk0snCp CM93/obcsSwvWHCX6qj7ZD8BNvYFUt/Ol0I74FX8BobpxPitaf9GTsAHy s/05qgOfD+Tx/FRMMpsbTo2OoA5Omns7Vu5yc3Yj9s/EqhHzdbiQ+WRHO BlNIgW7uUUoqOGHmtXWgosGGXE5A6GwZaHFOSRfn4chIE+OUlzdjeSOna R6kw0/DlBYP9Y1JoY9tj2t1EeS7SUvn2O2dyvxtzdUH2g1f8Mmhhe8uSN w==; X-IronPort-AV: E=McAfee;i="6600,9927,10667"; a="344198906" X-IronPort-AV: E=Sophos;i="5.98,310,1673942400"; d="scan'208";a="344198906" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2023 06:39:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10667"; a="796459152" X-IronPort-AV: E=Sophos;i="5.98,310,1673942400"; d="scan'208";a="796459152" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.254.211.241]) ([10.254.211.241]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2023 06:39:34 -0700 Message-ID: <07b7a01f-8a0d-6eca-e436-df5135d679cb@linux.intel.com> Date: Sat, 1 Apr 2023 21:39:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Cc: baolu.lu@linux.intel.com, Will Deacon , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , "Yu, Fenghua" , Dave Jiang , Tony Luck , "Zanussi, Tom" Subject: Re: [PATCH v3 7/7] dmaengine/idxd: Re-enable kernel workqueue under DMA API Content-Language: en-US To: Jacob Pan , LKML , iommu@lists.linux.dev, Robin Murphy , Jason Gunthorpe , Joerg Roedel , dmaengine@vger.kernel.org, vkoul@kernel.org References: <20230331231137.1947675-1-jacob.jun.pan@linux.intel.com> <20230331231137.1947675-8-jacob.jun.pan@linux.intel.com> From: Baolu Lu In-Reply-To: <20230331231137.1947675-8-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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 2023/4/1 7:11, Jacob Pan wrote: > static void idxd_disable_system_pasid(struct idxd_device *idxd) > { > + struct pci_dev *pdev = idxd->pdev; > + struct device *dev = &pdev->dev; > + struct iommu_domain *domain; > + union gencfg_reg gencfg; > + > + domain = iommu_get_domain_for_dev(dev); > + if (!domain || domain->type == IOMMU_DOMAIN_BLOCKED) > + return; Out of curiosity, why do you need to check the domain type? And, in which case could the domain for the device be changed to a blocking one? Once a driver is bound to the device, the driver "owns" the DMA of the device. No one else could change the domain except the driver itself. > + > + iommu_detach_device_pasid(domain, dev, idxd->pasid); > + iommu_free_global_pasid(idxd->pasid); > > - iommu_sva_unbind_device(idxd->sva); > + gencfg.bits = ioread32(idxd->reg_base + IDXD_GENCFG_OFFSET); > + gencfg.user_int_en = 0; > + iowrite32(gencfg.bits, idxd->reg_base + IDXD_GENCFG_OFFSET); > idxd->sva = NULL; > + idxd->pasid = IOMMU_PASID_INVALID; > } Best regards, baolu