Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1653672ioo; Sun, 22 May 2022 23:08:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsvhHDdO6kktmd0Gub95vZZEs3/vJoFdNgeSW3Gq70T+grZQxmksqJKwN9oZvNF2ZGB6u/ X-Received: by 2002:a17:902:9b84:b0:161:db34:61ef with SMTP id y4-20020a1709029b8400b00161db3461efmr20122739plp.138.1653286104942; Sun, 22 May 2022 23:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653286104; cv=none; d=google.com; s=arc-20160816; b=BxzlTzA0SrlpZ0B1fwX46knqSN1zZiHQeO4ibZ4J5toSkBME405cJG+xX30nC3rpdc m8irM/eDI/CxallULxrYi+F4Rp26IJB14AzO4zZSYdUhtpD2V60ySehhZEnxMCv7Lytd C6xeSEIO7snt4mYNV1xxLC+D0nlazAm3dhjO39YxrMU9RYGOeS0MJGh/8/2IvzxywN4/ iJ2mXJyoNrB/JNBG9oCKD+wJ6Ri0xk2jJK7ipAiddJoQBiRN+SLYp4F1CK+QHafM6amZ bObUIUjav1FCL/CVIQXRihXpK81pz8zwqGTar5QoWpaalbnamfaaDlTrRPZ0mR6Wo9L7 /zbg== 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=ZsHmLgLLSgY0MLwN1X6bgmdvqzeP1I6ThI/cyzfxqTs=; b=YS/54kR6KMBOZ89Re+l+V+EKuahaWDrIOvR5b8yDodi8E4fPY4quQgroSzmsWZUMs+ 1jJTpbPV8EAMNfnAqO8a2b3PNf466j+NXdQIvkMpM4Pd2ITiP5ty5i6RQ+5sNIFfqJnJ XpPQfsf9X9KJKP0UPr/2/hyGdlnQtoQjgu5xAymuDtBLd+wuKx+UjoeqcNW44iQrbGZW c2EIpvhLbS3bw8hd4QsrE8uY8FuoDQ9dWom41LAdtk0gAK2Vrpiw4YVJVRDrOuRvDbFg Q2sDOVz2rzZHbKqT3gXZv2Y2khvNXegUHzL5PWjBF1s5rnI6cHqjRxxKPK10k+LjRpO6 4CHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GramgafI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 195-20020a6302cc000000b003f644503490si9314241pgc.329.2022.05.22.23.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:08:24 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GramgafI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A9A7B38DB8; Sun, 22 May 2022 22:59:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345478AbiETEz4 (ORCPT + 99 others); Fri, 20 May 2022 00:55:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345472AbiETEzz (ORCPT ); Fri, 20 May 2022 00:55:55 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B61338A for ; Thu, 19 May 2022 21:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653022552; x=1684558552; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=X9avb/d0O6a8NxBxoEs+XuMddItGnculjWwGxAs+/8k=; b=GramgafIRMj27tn5PDEqQ3Gm7zhVbImaAIsKYjbPbjTUiGA1oCrXY8OT lGkxFjKRdVpAQNuOj93422O0atRKOl4+Bo1+hgjV2uG20f+S76PrYBR5D Ec63qfpZFY9iQvgVOfwLfSKg2RuHq18fH78lOFGNsoUxvbaXhjXG8LSGg BJ8MznlaFBMoS3RO1EYjVEhzNZIe6AfOg7nS46Pfb/McpJZNhtfwudlBR Hopr8a3VWX1XyT9FY4fElGL/95ZiLL0gpzfRHt+7hpvvfVGrgG8F93MUh toAOeWa+RnGHdk+DGcFZUjO/EB2MrDXK33v5M2BlH2B/0gewQfyzbvdAD A==; X-IronPort-AV: E=McAfee;i="6400,9594,10352"; a="272615718" X-IronPort-AV: E=Sophos;i="5.91,238,1647327600"; d="scan'208";a="272615718" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2022 21:55:48 -0700 X-IronPort-AV: E=Sophos;i="5.91,238,1647327600"; d="scan'208";a="599005699" Received: from wangyu5-mobl.ccr.corp.intel.com (HELO [10.249.172.121]) ([10.249.172.121]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2022 21:55:44 -0700 Message-ID: Date: Fri, 20 May 2022 12:55:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Cc: baolu.lu@linux.intel.com, Joerg Roedel , Jason Gunthorpe , 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 , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 03/10] iommu/sva: Add iommu_sva_domain support Content-Language: en-US To: Jean-Philippe Brucker References: <20220519072047.2996983-1-baolu.lu@linux.intel.com> <20220519072047.2996983-4-baolu.lu@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE 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 2022/5/20 00:33, Jean-Philippe Brucker wrote: >> diff --git a/drivers/iommu/iommu-sva-lib.h b/drivers/iommu/iommu-sva-lib.h >> index 8909ea1094e3..1be21e6b93ec 100644 >> --- a/drivers/iommu/iommu-sva-lib.h >> +++ b/drivers/iommu/iommu-sva-lib.h >> @@ -7,6 +7,7 @@ >> >> #include >> #include >> +#include >> >> int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max); >> struct mm_struct *iommu_sva_find(ioasid_t pasid); >> @@ -16,6 +17,20 @@ struct device; >> struct iommu_fault; >> struct iopf_queue; >> >> +struct iommu_sva_domain { >> + struct iommu_domain domain; >> + struct mm_struct *mm; >> +}; >> + >> +#define to_sva_domain(d) container_of_safe(d, struct iommu_sva_domain, domain) > Is there a reason to use the 'safe' version of container_of()? Callers of > to_sva_domain() don't check the return value before dereferencing it so > they would break anyway if someone passes an error pointer as domain. I > think it matters because there is no other user of container_of_safe() in > the kernel (the only user, lustre, went away in 2018) so someone will want > to remove it. Fair enough. I wondered why there's no user in the tree. Thanks for the explanation. I will replace it with container_of(). > > Apart from that > > Reviewed-by: Jean-Philippe Brucker > Thank you! Best regards, baolu