Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4056403rwd; Mon, 29 May 2023 23:05:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79X2K0f7biXW4Io8Oe8G2itAaPjubY6Tf0S9VDH2pw/GbuHHfYnUv2iE46bfklnoibKT6R X-Received: by 2002:a05:6a20:7345:b0:10c:1076:ff69 with SMTP id v5-20020a056a20734500b0010c1076ff69mr1482429pzc.48.1685426716942; Mon, 29 May 2023 23:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685426716; cv=none; d=google.com; s=arc-20160816; b=MhH6gsN9jhuVVVgZTlRET4X1u84fyIK/RnB74fyLFG6gC+p1ZknEA6uVGndYEfKPqs 3kuu5B3bFnBKdJg/R0PH3uv9QE0BIlD1kLopagfC7jvHcmsPYQbJS4EF1x+EIfZw9Uh1 V8nlPMYkNmAMmP3Yy3+xUL61/X86ciY+KPrQZr1oaxcoe16tTQyNgKkPVN8GRDNvuHRQ 361iTifvgPSvDodi9s5FnU95cAM8zlcsoEHgGR6HCxbM8r0T5SuFsls4WmJz9bMMW9mD I9qawiOrIIHedRtZZdVA56sFrxdXFPACRPvtKZt8xdVMQRn7AQEWvJmV++FJ4xMVqqZ8 5kIA== 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=bgc87USjk/gQno7+0RDtAomonTDVzADRtP6oEdAW2MI=; b=mmKTdwINSjSY5Dp8sM5406yvDJyeip4FSUmVaNvbKLiqioKUfY6ndHQIA0RYHGhYab ovq0bKsZufuyzXabAADy0r6CcmyBmtHmERxbOSS8EAlY+Fn0P7jwfaPkr6dK5TPhjC0l uxXRKU0w4bdWZtn4LHZsITztSzfLKIUbIaqM/XyNQd5erKlo5/a/C+eAld9h0t1cg37/ Q4b/cIH+v/O4uO3bqmLY+mPOc+HOXMUU0yNsMh35TsyDC7GohelczcMaI3YncetC0K39 rXeS3qRalqpesrtcTDtrVt7a/riRSRwUKeTb/a8vgRBDhCvNarluKNR8hgJYU+dpsUL8 L47g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UvsvPeUu; 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 z7-20020aa79487000000b0063b82925d69si1145503pfk.337.2023.05.29.23.05.02; Mon, 29 May 2023 23:05:16 -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=UvsvPeUu; 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 S230228AbjE3Fis (ORCPT + 99 others); Tue, 30 May 2023 01:38:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbjE3Fim (ORCPT ); Tue, 30 May 2023 01:38:42 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E10AD; Mon, 29 May 2023 22:38: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=1685425119; x=1716961119; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1ZqasWAA5mVjNHn5DIUADADIinyg0cr8B//uQHoZisM=; b=UvsvPeUuSesiB8u0JipVkBQuxRQZvIhbsB5BjeJ6QBhoNbueq4XS1UyZ 26Gwo9C0YLZD+fnIzfm8MBeT8Dr2kQq2iJlkaRfkw70C1M/YrvwP9Vehz hK0Z0/GOHoxcUdv8EKI/U+qClbgb6CVN6iocevrDEGhSYn77fVX2LQUjH 8gQMqAxrQDAb8ybR5s1l9yVOB1S6Sbtnapro5OhUHRjMCn12hL2kT/3QB FphRlkqgqs5vBtwMLeNGk1tFnQVU2JV4IoLGhYWCbHyrvTYIkPS0mLuS6 n1H4q834FF8m0NGQDAdp/a5oJkM504lWzxW8peuwf6109PYV+V04UK8/t A==; X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="420579652" X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="420579652" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2023 22:38:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="739369467" X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="739369467" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga001.jf.intel.com with ESMTP; 29 May 2023 22:38:32 -0700 From: Lu Baolu To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan Cc: iommu@lists.linux.dev, linux-kselftest@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [RFC PATCHES 03/17] iommu: Add helper to set iopf handler for domain Date: Tue, 30 May 2023 13:37:10 +0800 Message-Id: <20230530053724.232765-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530053724.232765-1-baolu.lu@linux.intel.com> References: <20230530053724.232765-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 To avoid open code everywhere. No intentional functionality change. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 10 ++++++++++ drivers/iommu/iommu.c | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index fce7ad81206f..f554328528bc 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -273,6 +273,16 @@ static inline bool iommu_is_dma_domain(struct iommu_domain *domain) return domain->type & __IOMMU_DOMAIN_DMA_API; } +static inline void +iommu_domain_set_iopf_handler(struct iommu_domain *domain, + enum iommu_page_response_code (*handler)(struct iommu_fault *fault, + void *data), + void *data) +{ + domain->iopf_handler = handler; + domain->fault_data = data; +} + enum iommu_cap { IOMMU_CAP_CACHE_COHERENCY, /* IOMMU_CACHE is supported */ IOMMU_CAP_NOEXEC, /* IOMMU_NOEXEC flag */ diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 13a2e0e26884..fd65ed1d3642 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3419,8 +3419,7 @@ struct iommu_domain *iommu_sva_domain_alloc(struct device *dev, domain->type = IOMMU_DOMAIN_SVA; mmgrab(mm); domain->mm = mm; - domain->iopf_handler = iommu_sva_handle_iopf; - domain->fault_data = mm; + iommu_domain_set_iopf_handler(domain, iommu_sva_handle_iopf, mm); return domain; } -- 2.34.1