Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1288592iob; Fri, 29 Apr 2022 01:53:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwyai8AsXNUMqA5YlL1An1dQBK5FlHbP3wLrDq04LIReF3jG6thPc6wAQtv45MZ4Fsz62r X-Received: by 2002:a17:90a:ba15:b0:1cb:be7d:bbca with SMTP id s21-20020a17090aba1500b001cbbe7dbbcamr2691670pjr.143.1651222410884; Fri, 29 Apr 2022 01:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651222410; cv=none; d=google.com; s=arc-20160816; b=BOQ+Zl8sQcZyjCgApG8HUbrzWos3g7pKjcPUqt1k/csPWPkFhXKkLvmSbYBwPUaZI2 BspOHYaTW3Hrz6W4efFQmWUrtTlwgniMpI4sZ9rPWcIVnB/5HSpvT71XMf7J7oEiBSiS DiwIi28LOA/ArKYr06wPJ7WB6Yii3Ew9fHM1nKbPZewmyYZfzxWcOK0GkaroMXxG4Ui0 KPko9aPL1AOU4hdJoyJnIDxVJi6Ceyf0+B5e1WyY+5eAv0e/FoANarAPojeKDjcNzdcC PsNxvRIsE4SXkiN0cEjtyMmZWbZB34KsHv4sZ83N1w2+F+Mck919NcYrIv+hoOg2f3DL kGUA== 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=+Oatp214EwoNcQfNGb/ga75M/gnCMQvp4FQ1OdCp+0E=; b=uFijqE5wo1WzO3Y31lTivaqTWGSo2h07W+rFUfPJWeT+HLfiAHlTG3n359uxbCvI4T UL1BTpU1RXqACKCDTyqyDVzqApDZNhJ/rT4JuzxfXhoHxGb1kBGXZ9jOcaDKFM1zhwqj +Wc6UgGE3MrSCiYBrFY0y+5x8ZVHl82ZKLbmhEZeFNfeO6Mzmk5jh8blKaDRUTmcTkLB q1kghNWLLihXGwEDzdnB0nNdBj/mrf8719UXOOcLmijGV5qCldpy+6vgVYVC0UNcxwQ8 x0B2WAMIMbnLsvPocXfsCDejK/Xdn2nISqI2EpeDzqfrRmwZQNVY2gzxOR8mdyu3OFs5 uc5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XGccVBbY; 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 a11-20020a170902eccb00b00158721713e3si486486plh.449.2022.04.29.01.53.16; Fri, 29 Apr 2022 01:53:30 -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=XGccVBbY; 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 S1348665AbiD1PA7 (ORCPT + 99 others); Thu, 28 Apr 2022 11:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243847AbiD1PA6 (ORCPT ); Thu, 28 Apr 2022 11:00:58 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EACC6D4F7 for ; Thu, 28 Apr 2022 07:57:43 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id m20so10073157ejj.10 for ; Thu, 28 Apr 2022 07:57:43 -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=+Oatp214EwoNcQfNGb/ga75M/gnCMQvp4FQ1OdCp+0E=; b=XGccVBbYbqQHavxmDFlET858W8/jpfKwAvu1iXwcz1UiPEkSDm4RDz9Eu5dw1AhpzT S18Q+f+L9h8jeW7AaNE5yH9d0DBvna/nIClQHP/oUVdE+fveKG2Vo8Vjkb65yaiY2lDo GLFbb4SKTTewbGyXbWZvT/y+IZobtPOV7LtbOmSSHyGh+hgJLcUX7gA6jWZVdcLut3Hg doYBJ9b573W3HowU4BG64IaVxziqIeSesfP2EGnXBsVwNoBgibOfC9ADDsLCWsF89YbO h3SVONb7e6Cl7zhLd0ruB5rns3Zc3vA90/KYWaMMtxMpPlkIv8cNVK2RsrBJorLEFytG lbJg== 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=+Oatp214EwoNcQfNGb/ga75M/gnCMQvp4FQ1OdCp+0E=; b=L3+jVGEN1l8bjxXdwTDetufnjil6PX6DpXaDo/I6lLC9PyTyFgMKRL31jVVPXayAck pUYUJeB/WcT2mpGzAhHN1GAV1Cg5ZJ0toarrhqxxAxlbHWCR62tgbpvobRym0ChzScCR 9nbgbb2NsCin0dJNPmwnPhtL4atkbtE6OHD46Qcv+Px0KvGZ5Z+g7W3sFfLbaeBhPbOz 6to0kZ0HU5q1yctmy6F3Rl+IWGXr0Oz1SD4KGGrjYa5D5DJ/VvyywBp0/oZWk+3GYmoC v7AUnbz4I7+OtMMjq//wTI+sWp2zVEpyPuIvoDbtYhl2eXAqH43DpXz02zoyc5nFcEfo BEXw== X-Gm-Message-State: AOAM5304sD0GJDBamF7yrLwa8etNm5RoxCqJT9EikUu1lp9j87GiON3i ErUOqP2QdwIKSxcUZwU1vB5uaw== X-Received: by 2002:a17:907:6d17:b0:6f3:e4ef:cd4a with SMTP id sa23-20020a1709076d1700b006f3e4efcd4amr2947973ejc.646.1651157861714; Thu, 28 Apr 2022 07:57:41 -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 l21-20020a056402345500b0042617ba6393sm1706454edc.29.2022.04.28.07.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 07:57:41 -0700 (PDT) Date: Thu, 28 Apr 2022 15:57:16 +0100 From: Jean-Philippe Brucker To: Lu Baolu Cc: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 11/12] iommu: Per-domain I/O page fault handling Message-ID: References: <20220421052121.3464100-1-baolu.lu@linux.intel.com> <20220421052121.3464100-12-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220421052121.3464100-12-baolu.lu@linux.intel.com> 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 Thu, Apr 21, 2022 at 01:21:20PM +0800, Lu Baolu wrote: > static void iopf_handle_group(struct work_struct *work) > { > struct iopf_group *group; > @@ -134,12 +78,23 @@ static void iopf_handle_group(struct work_struct *work) > group = container_of(work, struct iopf_group, work); > > list_for_each_entry_safe(iopf, next, &group->faults, list) { > + struct iommu_domain *domain; > + > + domain = iommu_get_domain_for_dev_pasid_async(group->dev, > + iopf->fault.prm.pasid); Reading the PCIe spec again (v6.0 10.4.1.1 PASID Usage), all faults within the group have the same PASID so we could move the domain fetch out of the loop. It does deviate from the old behavior, though, so we could change it later. Thanks, Jean > + if (!domain || !domain->iopf_handler) > + status = IOMMU_PAGE_RESP_INVALID; > + > /* > * For the moment, errors are sticky: don't handle subsequent > * faults in the group if there is an error. > */ > if (status == IOMMU_PAGE_RESP_SUCCESS) > - status = iopf_handle_single(iopf); > + status = domain->iopf_handler(&iopf->fault, > + domain->fault_data); > + > + if (domain) > + iommu_domain_put_async(domain); > > if (!(iopf->fault.prm.flags & > IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE))