From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E3BC433E0 for ; Thu, 11 Mar 2021 07:35:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B657964FD4 for ; Thu, 11 Mar 2021 07:35:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231826AbhCKHfW (ORCPT ); Thu, 11 Mar 2021 02:35:22 -0500 Received: from mga05.intel.com ([192.55.52.43]:29828 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231805AbhCKHem (ORCPT ); Thu, 11 Mar 2021 02:34:42 -0500 IronPort-SDR: CAEDVrC4pyi8RRkqz7JmnAxtcvPczXDXHRQx71oJBe97+wK3vHI9lcBS6F/xwj4lJT0FPL5Y+c FzDK/pbMvJ2g== X-IronPort-AV: E=McAfee;i="6000,8403,9919"; a="273666471" X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="273666471" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 23:34:39 -0800 IronPort-SDR: NuRQBgchhrV+Vt6dNKgNTu/EnK2Uk6O5ySowyrfz123EJac6kux1f+hM1li+qNGkFydBecweTA XiJ26AKXSH9g== X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="410515964" Received: from lingshan-mobl5.ccr.corp.intel.com (HELO [10.249.170.224]) ([10.249.170.224]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 23:34:36 -0800 Subject: Re: [PATCH V3 1/6] vDPA/ifcvf: get_vendor_id returns a device specific vendor id To: Jason Wang , Zhu Lingshan , mst@redhat.com, lulu@redhat.com, leonro@nvidia.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210310090052.4762-1-lingshan.zhu@intel.com> <20210310090052.4762-2-lingshan.zhu@intel.com> <5f2d915f-e1b0-c9eb-9fc8-4b64f5d8cd0f@linux.intel.com> <05e3fbc9-be49-a208-19a4-85f891323312@redhat.com> From: "Zhu, Lingshan" Message-ID: Date: Thu, 11 Mar 2021 15:34:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <05e3fbc9-be49-a208-19a4-85f891323312@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 3/11/2021 2:13 PM, Jason Wang wrote: > > On 2021/3/11 12:21 下午, Zhu Lingshan wrote: >> >> >> On 3/11/2021 11:23 AM, Jason Wang wrote: >>> >>> On 2021/3/10 5:00 下午, Zhu Lingshan wrote: >>>> In this commit, ifcvf_get_vendor_id() will return >>>> a device specific vendor id of the probed pci device >>>> than a hard code. >>>> >>>> Signed-off-by: Zhu Lingshan >>>> --- >>>>   drivers/vdpa/ifcvf/ifcvf_main.c | 5 ++++- >>>>   1 file changed, 4 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c >>>> b/drivers/vdpa/ifcvf/ifcvf_main.c >>>> index fa1af301cf55..e501ee07de17 100644 >>>> --- a/drivers/vdpa/ifcvf/ifcvf_main.c >>>> +++ b/drivers/vdpa/ifcvf/ifcvf_main.c >>>> @@ -324,7 +324,10 @@ static u32 ifcvf_vdpa_get_device_id(struct >>>> vdpa_device *vdpa_dev) >>>>     static u32 ifcvf_vdpa_get_vendor_id(struct vdpa_device *vdpa_dev) >>>>   { >>>> -    return IFCVF_SUBSYS_VENDOR_ID; >>>> +    struct ifcvf_adapter *adapter = vdpa_to_adapter(vdpa_dev); >>>> +    struct pci_dev *pdev = adapter->pdev; >>>> + >>>> +    return pdev->subsystem_vendor; >>>>   } >>> >>> >>> While at this, I wonder if we can do something similar in >>> get_device_id() if it could be simple deduced from some simple math >>> from the pci device id? >>> >>> Thanks >> Hi Jason, >> >> IMHO, this implementation is just some memory read ops, I think other >> implementations may not save many cpu cycles, an if cost at least >> three cpu cycles. >> >> Thanks! > > > Well, I meant whehter you can deduce virtio device id from > pdev->subsystem_device. > > Thanks Oh, sure, I get you > > >>> >>> >>>>     static u32 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev) >>> >> >