Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp408586pxy; Wed, 28 Apr 2021 06:47:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwppB/4hD0j6V5WmNTMk0M29z/ZbIaCXh7wZHLBgie9R5jBpoN02m5IoCoAORDSf3B4dcH4 X-Received: by 2002:a17:906:c827:: with SMTP id dd7mr18812530ejb.225.1619617560976; Wed, 28 Apr 2021 06:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619617560; cv=none; d=google.com; s=arc-20160816; b=m2RFa5LoW/QTK2QU57oHDLnxxCxgLGU79P0V6XgnAqgYfF+8Y2uh6bqXUS3eOKQ/zr 1cctl2oMq0OFMh0Kz93iLy9lGychJEZTJ+qyZK4AqZ9+byKNb65sJycQHKm63cP60JL5 zCcSM4J8+wx4hAcF2VP2wVd4gwUaxvsQvCJ2zv6pnwldAuxshdUp32z/JSzAmY0RfD6o bhMI6ws834fwGJ8YNuZHjfgdDFV/7EEJzjzZvt2ZYz7qOnW7G5w0lQRHw6g3l7Y0RDzN 9u7lQRdCcXXuw0ZY7ZKyDQNCkyoFdv+Cwh9YGcME6SjpIwd5sfV3M0Z0MzYD9pzkrfb/ LJjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=ZS6qS750uWO86LLTm3MRugdCJMBoQmznIYDAgBDEZyE=; b=a2ut2fVVazG5jeAoHIjah9dxydiExioAXn/+toeetSsAoBTgKwuZaPK/FdeQ6i6FGR QksUKO/WXXgnrjsOoYIVM6MS8C3o7Pq9fyvc6uiB3EQqmd7GtPYQT0/d0p+ddkzmx5q1 phFrcQRn0t0WEmVm7H6aMShcLc1QG5ajfoY61/etgD7AHz8vaqcNXFjdKr+7nC7wxNtU 9Kn2kupuD6OqqTUKhpdCseizKiRx+82MKCxWnQB6f5Fs4OkxAcub/Vi2LpVg1Cg8k8Px vz+U6GkLJoYdD7ea++T9qIMRF7hiWzEevZCzIhq/kV91QJhIrCggJZ8S71ybjdZHHlXA 0RgA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si5529245edv.309.2021.04.28.06.45.13; Wed, 28 Apr 2021 06:46:00 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238381AbhD1KTY (ORCPT + 99 others); Wed, 28 Apr 2021 06:19:24 -0400 Received: from mga04.intel.com ([192.55.52.120]:9704 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236343AbhD1KTY (ORCPT ); Wed, 28 Apr 2021 06:19:24 -0400 IronPort-SDR: eEHR3xipS7jmHV3goQtnhO60sQSjKCOUqPMGiXuM17dyXusl715syWSE+yzgyWO738KoHviCfe HTQR7xe+7BvA== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="194591499" X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="194591499" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 03:18:39 -0700 IronPort-SDR: 35eRNRH85RVTLRH73OYtRFxH45vSLn0DOdo8/CCZsSD6++eUPlh3sleW61lx47OALi0ulx8Rt1 jUYe0CbePGAA== X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="423462467" Received: from lingshan-mobl5.ccr.corp.intel.com (HELO [10.254.209.93]) ([10.254.209.93]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 03:18:37 -0700 Subject: Re: [PATCH 1/2] vDPA/ifcvf: record virtio notify base To: Jason Wang , mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210428082133.6766-1-lingshan.zhu@intel.com> <20210428082133.6766-2-lingshan.zhu@intel.com> <55217869-b456-f3bc-0b5a-6beaf34c19f8@redhat.com> <3243eeef-2891-5b79-29cb-bc969802c5dc@intel.com> <4cee04f1-a3fc-eaf0-747a-004ca09b06c0@redhat.com> From: "Zhu, Lingshan" Message-ID: Date: Wed, 28 Apr 2021 18:18:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <4cee04f1-a3fc-eaf0-747a-004ca09b06c0@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: linux-kernel@vger.kernel.org On 4/28/2021 6:09 PM, Jason Wang wrote: > > 在 2021/4/28 下午6:00, Zhu, Lingshan 写道: >> >> >> On 4/28/2021 4:39 PM, Jason Wang wrote: >>> >>> 在 2021/4/28 下午4:21, Zhu Lingshan 写道: >>>> This commit records virtio notify base addr to implemente >>>> doorbell mapping feature >>>> >>>> Signed-off-by: Zhu Lingshan >>>> --- >>>>   drivers/vdpa/ifcvf/ifcvf_base.c | 1 + >>>>   drivers/vdpa/ifcvf/ifcvf_base.h | 1 + >>>>   2 files changed, 2 insertions(+) >>>> >>>> diff --git a/drivers/vdpa/ifcvf/ifcvf_base.c >>>> b/drivers/vdpa/ifcvf/ifcvf_base.c >>>> index 1a661ab45af5..cc61a5bfc5b1 100644 >>>> --- a/drivers/vdpa/ifcvf/ifcvf_base.c >>>> +++ b/drivers/vdpa/ifcvf/ifcvf_base.c >>>> @@ -133,6 +133,7 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct >>>> pci_dev *pdev) >>>> &hw->notify_off_multiplier); >>>>               hw->notify_bar = cap.bar; >>>>               hw->notify_base = get_cap_addr(hw, &cap); >>>> +            hw->notify_pa = pci_resource_start(pdev, cap.bar) + >>>> cap.offset; >>> >>> >>> To be more generic and avoid future changes, let's use the math >>> defined in the virtio spec. >>> >>> You may refer how it is implemented in virtio_pci vdpa driver[1]. >> Are you suggesting every vq keep its own notify_pa? In this case, we >> still need to record notify_pa in hw when init_hw, then initialize >> vq->notify_pa accrediting to hw->notify_pa. > > > I meant you need to follow how virtio spec did to calculate the > doorbell address per vq: > >         cap.offset + queue_notify_off * notify_off_multiplier > > Obviously, you ignore queue_notify_off and notify_off_multiplier here. > This may bring troubles for the existing device IFCVF and future devices. > > If I understand correctly, this device can be probed by virtio-pci > driver which use the above math. There's no reason for using ad-hoc hack. sure, when talking about initialize vq->notify_pa, I mean calculate with with notify_base and multiplier, V2 will include this. Thanks, Zhu Lingshan > > Thanks > > >> >> Thanks >> Zhu Lingshan >>> >>> Thanks >>> >>> [1] >>> https://lore.kernel.org/virtualization/20210415073147.19331-5-jasowang@redhat.com/T/ >>> >>> >>>> IFCVF_DBG(pdev, "hw->notify_base = %p\n", >>>>                     hw->notify_base); >>>>               break; >>>> diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h >>>> b/drivers/vdpa/ifcvf/ifcvf_base.h >>>> index 0111bfdeb342..bcca7c1669dd 100644 >>>> --- a/drivers/vdpa/ifcvf/ifcvf_base.h >>>> +++ b/drivers/vdpa/ifcvf/ifcvf_base.h >>>> @@ -98,6 +98,7 @@ struct ifcvf_hw { >>>>       char config_msix_name[256]; >>>>       struct vdpa_callback config_cb; >>>>       unsigned int config_irq; >>>> +    phys_addr_t  notify_pa; >>>>   }; >>>>     struct ifcvf_adapter { >>> >> >