Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3233172rwo; Fri, 4 Aug 2023 01:15:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgYDu4pws0a+6XoZ2prR0e66ytZ2OFP9dQ77mS8fI+0HAPyAu9QUL8oTfzuNPOiiJbBGbM X-Received: by 2002:a05:6a00:179b:b0:687:1780:aa02 with SMTP id s27-20020a056a00179b00b006871780aa02mr1148255pfg.24.1691136940952; Fri, 04 Aug 2023 01:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691136940; cv=none; d=google.com; s=arc-20160816; b=vtq9sPHA/t8zzTHunrvszD47EUzqBjVDsJgufdJ/9emlk/e3tnrJEVgrWzJhPax9n6 7s2noR1kMxCwkUYX8Kd3i7m7tmVAAxBFFQYDaAOOle35qd727UEyIFQNC3I6Zg6wwGV9 FZl6GBU5ou2mnLPJ5mpSxCpELiJT/vqQaKpMZLeQ3kQUP2mUhprpiOfugL4AnBNwbagD IAeEE51IMGHc9yiV2upVk8sNuCO+Gz6x0VWyR3SR/zy1vdtA2Lj3hlF9DHW5tBKF+rlE rqbdYK+jutDZvcN6/6lsXK/KYG/rlDn7bQUQdSHKqIII8UOLUtKzy6oz0Xzjg2am7Yn/ Khkg== 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=PD1oFlpLs7VnYfBjx0CyR6eBUUQrGm3CintTYBrQhJ0=; fh=lUKVdYiTv5UZoEavPARWrYLGgaq0Tzj7zaAZH6YskUw=; b=wPQjctJun0sqsbaz4ygtg+YlhRI1DDJFnbRRutu20OmxsNJ3/k/5YRRSByEZycDRCf 3qZCiixx4YTfy7WOOi4DZmOZLBVDO3q7zlhIvwOYa1/PgOADM0ylXhf8hSZJ1WreBkYc VRnYiqmYTM2tRzPZsosQ9rRuKACpoLJ9HUqTIepfKFfGOEg3PPXkaGJ+TtangjjHs+UW VBqAbKot0PKoAez8bX3DVSBu0NanUXB6TFMiToawoYaC3eHdowNSBZc94UL7c+ZbwnLj hNjZmGVfjPSarGuqNAUHVvgAaCIUMYr6v1sPsbGrp1oxyvBy1lZtWBYvJILPFcll03K0 7+3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="liSlHf5/"; 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 ch7-20020a056a00288700b006828c76a9f1si1354554pfb.74.2023.08.04.01.15.28; Fri, 04 Aug 2023 01:15:40 -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="liSlHf5/"; 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 S230292AbjHDFfv (ORCPT + 99 others); Fri, 4 Aug 2023 01:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjHDFft (ORCPT ); Fri, 4 Aug 2023 01:35:49 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE37F1B9; Thu, 3 Aug 2023 22:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691127347; x=1722663347; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=P8Vkq8HDONp8jpbKeWJn+P9ZXMB52Nsm8jPQHJmirLo=; b=liSlHf5/WbMcK89Bim/PJPgeqHVUwXcEeSOBja6ECEPyHj5OjfnilyZh xSDt57qiGlMVwdXkU/MMZ0Vg9gj9QJbvVpScWYEybkJpjR8uzDPd4uawt XTVCmOjAn5zf364TomC/4AYyIg9cqXI9Ez+j9/Fs3+tSyUbqMddaZovoF leMds5hThcNBm7hbmnTGRq/tg8zu9qZhkUO+J3NIf6zGbr1dYB5BRXWWn PedpEgtbJ+k64XmnBtvCjEOf/nAG0rwYZ5GJ4lcQvQ+L6LPCtHf6IrUiZ kPC1JnxAFyBge7SzjCAK+ND/AUiKGA9GtmJEcMtPlU73Hrlw0PrTjSTBr Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="367533109" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="367533109" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2023 22:35:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="764958754" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="764958754" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by orsmga001.jf.intel.com with ESMTP; 03 Aug 2023 22:35:43 -0700 Message-ID: Date: Fri, 4 Aug 2023 13:33:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: baolu.lu@linux.intel.com, "Liu, Yi L" , Jacob Pan , "iommu@lists.linux.dev" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 05/12] iommu: Change the return value of dev_iommu_get() Content-Language: en-US To: "Tian, Kevin" , Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Jean-Philippe Brucker , Nicolin Chen References: <20230727054837.147050-1-baolu.lu@linux.intel.com> <20230727054837.147050-6-baolu.lu@linux.intel.com> <0866104f-b070-405c-da27-71a138a10e7c@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,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 On 8/4/23 11:55 AM, Tian, Kevin wrote: >> From: Baolu Lu >> Sent: Friday, August 4, 2023 11:10 AM >> >> On 2023/8/3 15:59, Tian, Kevin wrote: >>>> From: Lu Baolu >>>> Sent: Thursday, July 27, 2023 1:49 PM >>>> >>>> Make dev_iommu_get() return 0 for success and error numbers for failure. >>>> This will make the code neat and readable. No functionality changes. >>>> >>>> Reviewed-by: Jacob Pan >>>> Signed-off-by: Lu Baolu >>>> --- >>>> drivers/iommu/iommu.c | 19 +++++++++++-------- >>>> 1 file changed, 11 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c >>>> index 00309f66153b..4ba3bb692993 100644 >>>> --- a/drivers/iommu/iommu.c >>>> +++ b/drivers/iommu/iommu.c >>>> @@ -290,20 +290,20 @@ void iommu_device_unregister(struct >>>> iommu_device *iommu) >>>> } >>>> EXPORT_SYMBOL_GPL(iommu_device_unregister); >>>> >>>> -static struct dev_iommu *dev_iommu_get(struct device *dev) >>>> +static int dev_iommu_get(struct device *dev) >>>> { >>>> struct dev_iommu *param = dev->iommu; >>>> >>>> if (param) >>>> - return param; >>>> + return 0; >>>> >>>> param = kzalloc(sizeof(*param), GFP_KERNEL); >>>> if (!param) >>>> - return NULL; >>>> + return -ENOMEM; >>>> >>>> mutex_init(¶m->lock); >>>> dev->iommu = param; >>>> - return param; >>>> + return 0; >>>> } >>>> >>> Jason's series [1] has been queued. Time to refine according to >>> the discussion in [2]. >>> >>> [1]https://lore.kernel.org/linux-iommu/ZLFYXlSBZrlxFpHM@8bytes.org/ >>> [2]https://lore.kernel.org/linux-iommu/c815fa2b-00df-91e1-8353- >> 8258773957e4@linux.intel.com/ >> >> I'm not sure I understand your point here. This only changes the return >> value of dev_iommu_get() to make the code more concise. >> > I thought the purpose of this patch was to prepare for next patch which > moves dev->fault_param initialization to dev_iommu_get(). Yes. > > with Jason's rework IMHO that initialization more fits in iommu_init_device(). > > that's my real point. If you still want to clean up dev_iommu_get() it's fine > but then it may not belong to this series. ???? Ah, I see. Let me make a choice in the next version. Best regards, baolu