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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 36E99C433ED for ; Wed, 28 Apr 2021 10:09:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0707D6142E for ; Wed, 28 Apr 2021 10:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239073AbhD1KKI (ORCPT ); Wed, 28 Apr 2021 06:10:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40588 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238803AbhD1KKH (ORCPT ); Wed, 28 Apr 2021 06:10:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619604562; 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=tCmCVcCGcXEgbhMIg1rIIz1DwzlDEOvC3LtivSI+s+8=; b=HtEjH5NRcUoEcZLYNwH7VK13eSI/Rqp3qLR+u/7HASB6PLoJrCNg3trAz/OGjLhoG1LwLG LGkly5mXwtEpBjnO3qlGtdXaUjDCliUkebnSqE9TOLr/sNm/RWezGRtoliEICTCWikA5XZ w4OQjYJAQwdrIq02If43nksw9Hki3mo= 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-384-mXh6x8uYMpOqAsImOovtJw-1; Wed, 28 Apr 2021 06:09:19 -0400 X-MC-Unique: mXh6x8uYMpOqAsImOovtJw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F34CF801106; Wed, 28 Apr 2021 10:09:17 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-12-25.pek2.redhat.com [10.72.12.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5A021001B2C; Wed, 28 Apr 2021 10:09:12 +0000 (UTC) Subject: Re: [PATCH 1/2] vDPA/ifcvf: record virtio notify base To: "Zhu, Lingshan" , 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> From: Jason Wang Message-ID: <4cee04f1-a3fc-eaf0-747a-004ca09b06c0@redhat.com> Date: Wed, 28 Apr 2021 18:09:11 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <3243eeef-2891-5b79-29cb-bc969802c5dc@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 在 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. 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 { >> >