Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp30491pxf; Tue, 16 Mar 2021 21:10:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyclnXrj05zpmYE64ts5KesNdXF9RJ2FHZqwojo4W3T7Myj/BnfQdYuJ9J2NNQ0NmH2RRRW X-Received: by 2002:a17:906:d8d3:: with SMTP id re19mr33449652ejb.440.1615954209637; Tue, 16 Mar 2021 21:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615954209; cv=none; d=google.com; s=arc-20160816; b=VJNVjc2TwzikKAGSuS0h1hsujIdH2rBjwG93PhC3317OT0n+bRBSBpgeZH3Uvtietd DvlONTUiMXkR7nN8n1sN8xnO1xG/f/Ohp/ANXJ0AJWB6DPjVkjNuUYvgWH2B3UaOuGUR svSLSlXuWCQ/HGujpZoHqknoR8XQqYOh4LGIKtlL/xrjZic0nhIO5WoyaZ2/RHoU1F4H mEt9Q9TU5ppJWgFt3T33iixWT6uy6PtR3aTdQ0pWYn/9sjpZJW7dhQnx8YhTW4bstj09 batBzoHhzyopwHj4HaNQecOs6gYorPaK+6OtVQZD3Jk1cRq36OI6WmdvM/xu6caLeVAo 4+hg== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject:dkim-signature; bh=t9laViWHXxg7PRqj/pmoMOkbiM/RKp8I4VgNFTiTAsQ=; b=eGGGu6mQxiDupXXybdj3BRn44tWtw2g83/ygFLR9Khs+cmiQr9jVSulB4k667prSs9 bWVsRJv/oGBI8dALlJWHwU7OjoHXEsKLjk97xRq9GeFRbTEI56cOksJKS6YwHyZ1O+Rr 4TQ6rx2mhF02jwF1uhBVsk/HPnzCSFi8T5VpC5rUPMQMLRj/muj6G+pjI0zQoC/+hp7I RA7KPR71kVJoG629Nq5N9cXq87E3NkR2ZqFtXY37EqLJbedHVx/g/EJtv8FYU1YB1evI s3o+7+00kHfvaPIGu53q8EaS6V2bWcF9e43aBTYfzQekPS7yiyARLEd2wl+VBNP1OVHW nJaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jmx951VW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si16014191ejp.450.2021.03.16.21.09.47; Tue, 16 Mar 2021 21:10:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jmx951VW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230500AbhCQD6Y (ORCPT + 99 others); Tue, 16 Mar 2021 23:58:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43265 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbhCQD5w (ORCPT ); Tue, 16 Mar 2021 23:57:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615953471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t9laViWHXxg7PRqj/pmoMOkbiM/RKp8I4VgNFTiTAsQ=; b=Jmx951VWyPhYcAidgz3rg302yURmY/iTQNAlRANJy6Exnv6cEPO8bDVz0ngR4qkzorjDpg CCNvAPwK5Wj/RK2pv19/1l3seVAAA8xkqiXdfr38q+xBKZa4/oSJGKErmrccREJDehSf+q Se+ZxrRqEGXKKhjf8PGEgAOiXvia9PE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-68-_DWUUqDrOBy6mp4INC2e9Q-1; Tue, 16 Mar 2021 23:57:49 -0400 X-MC-Unique: _DWUUqDrOBy6mp4INC2e9Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22EAE363A1; Wed, 17 Mar 2021 03:57:48 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-12-188.pek2.redhat.com [10.72.12.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60E2560C13; Wed, 17 Mar 2021 03:57:41 +0000 (UTC) Subject: Re: [PATCH V4 5/7] vDPA/ifcvf: fetch device feature bits when probe To: 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: <20210315074501.15868-1-lingshan.zhu@intel.com> <20210315074501.15868-6-lingshan.zhu@intel.com> From: Jason Wang Message-ID: <9ab3f888-2201-54de-1390-6bc181316453@redhat.com> Date: Wed, 17 Mar 2021 11:57:39 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210315074501.15868-6-lingshan.zhu@intel.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2021/3/15 ????3:44, Zhu Lingshan ะด??: > This commit would read and store device feature > bits when probe. > > rename ifcvf_get_features() to ifcvf_get_hw_features(), > it reads and stores features of the probed device. > > new ifcvf_get_features() simply returns stored > feature bits. > > Signed-off-by: Zhu Lingshan Acked-by: Jason Wang > --- > drivers/vdpa/ifcvf/ifcvf_base.c | 12 ++++++++++-- > drivers/vdpa/ifcvf/ifcvf_base.h | 2 ++ > drivers/vdpa/ifcvf/ifcvf_main.c | 2 ++ > 3 files changed, 14 insertions(+), 2 deletions(-) > > diff --git a/drivers/vdpa/ifcvf/ifcvf_base.c b/drivers/vdpa/ifcvf/ifcvf_base.c > index f2a128e56de5..ea6a78791c9b 100644 > --- a/drivers/vdpa/ifcvf/ifcvf_base.c > +++ b/drivers/vdpa/ifcvf/ifcvf_base.c > @@ -202,10 +202,11 @@ static void ifcvf_add_status(struct ifcvf_hw *hw, u8 status) > ifcvf_get_status(hw); > } > > -u64 ifcvf_get_features(struct ifcvf_hw *hw) > +u64 ifcvf_get_hw_features(struct ifcvf_hw *hw) > { > struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; > u32 features_lo, features_hi; > + u64 features; > > ifc_iowrite32(0, &cfg->device_feature_select); > features_lo = ifc_ioread32(&cfg->device_feature); > @@ -213,7 +214,14 @@ u64 ifcvf_get_features(struct ifcvf_hw *hw) > ifc_iowrite32(1, &cfg->device_feature_select); > features_hi = ifc_ioread32(&cfg->device_feature); > > - return ((u64)features_hi << 32) | features_lo; > + features = ((u64)features_hi << 32) | features_lo; > + > + return features; > +} > + > +u64 ifcvf_get_features(struct ifcvf_hw *hw) > +{ > + return hw->hw_features; > } > > void ifcvf_read_net_config(struct ifcvf_hw *hw, u64 offset, > diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h > index 794d1505d857..dbb8c10aa3b1 100644 > --- a/drivers/vdpa/ifcvf/ifcvf_base.h > +++ b/drivers/vdpa/ifcvf/ifcvf_base.h > @@ -83,6 +83,7 @@ struct ifcvf_hw { > void __iomem *notify_base; > u32 notify_off_multiplier; > u64 req_features; > + u64 hw_features; > struct virtio_pci_common_cfg __iomem *common_cfg; > void __iomem *net_cfg; > struct vring_info vring[IFCVF_MAX_QUEUE_PAIRS * 2]; > @@ -121,6 +122,7 @@ void ifcvf_set_status(struct ifcvf_hw *hw, u8 status); > void io_write64_twopart(u64 val, u32 *lo, u32 *hi); > void ifcvf_reset(struct ifcvf_hw *hw); > u64 ifcvf_get_features(struct ifcvf_hw *hw); > +u64 ifcvf_get_hw_features(struct ifcvf_hw *hw); > u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid); > int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num); > struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw); > diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c > index c34e1eec6b6c..25fb9dfe23f0 100644 > --- a/drivers/vdpa/ifcvf/ifcvf_main.c > +++ b/drivers/vdpa/ifcvf/ifcvf_main.c > @@ -458,6 +458,8 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id) > for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++) > vf->vring[i].irq = -EINVAL; > > + vf->hw_features = ifcvf_get_hw_features(vf); > + > ret = vdpa_register_device(&adapter->vdpa); > if (ret) { > IFCVF_ERR(pdev, "Failed to register ifcvf to vdpa bus");