Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6739121rwr; Tue, 9 May 2023 21:20:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lPdJJusB9YdsmTJgYc7SMMleKTb3vPV77Uh/SdQstp87MKr5a+K9zXtWA1SzubHqPWGDT X-Received: by 2002:a17:90b:1103:b0:250:6c76:fd9b with SMTP id gi3-20020a17090b110300b002506c76fd9bmr10556973pjb.38.1683692403945; Tue, 09 May 2023 21:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683692403; cv=none; d=google.com; s=arc-20160816; b=tlbJ3T6oVvrflnDVB1YHDTu6RKxuZMVf4vtkiryltjxkIP9eOpuNjdecWztlVSUQaf +EbBi4MNEsnDgo1JX7DJcx5/HEh0PB+1CIjdkxuajiJ1+GQVL60dr3CdkSNha9X5uv1p TJXev0Vl3opAxQTCJgYQHFsXeSn/fEhT0Sc3sMtHd6Wh+xyCSHu2ugONCCgbp56hxK0n C7EB0JTNneYK3Nl3EzBFKy0cQsjVcJIy5lApMGOJMYyQ/3IaYbC/yy2rm5a/C9XNrojO /1GE1riUZFUQGU6u2COqRPSvP31QS/tegECChhZeZ5Cxz3OMqJvX+IkF2rpu90w9lUkN hlIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=EI3dcKXw4MhS4ti0/DI9c0u69YLYabnxg/e6vkj4TDk=; b=uNbp8wKfRWrSwt5UQUmBJkNEhXpBR17nPKvr5meW23QZqCKYEIkL0tY7mYWtBopY/J KPRTXV0U3PbfjyuJOhC/gQco8HYHR7pp3/RqINq5t6vbpOfkXD92ndG3Nh/TzchXLAXR 6qBqdSd1H4E8mngL2S6g+jliij/7neFsQxyZhgOvlOzN9O00H4v+WxkGqInhKlCg4/4N LtJpGxMMe3shTSxGsgzxo+ANnS+spnghzFH9yC0Jb6A3Jb1NMfNb3HZm62xa5TC6XxgS 7mN9XFi3NSYo2reNCCCSWydR0NFigAJrIUjYPWQOJGURatCATkRDW5GEl7LY+CZHITjI W8nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20221208.gappssmtp.com header.s=20221208 header.b=3eLCbR86; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a17090a854400b0024e35ef410fsi18084141pjw.131.2023.05.09.21.19.52; Tue, 09 May 2023 21:20:03 -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=@igel-co-jp.20221208.gappssmtp.com header.s=20221208 header.b=3eLCbR86; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235560AbjEJDts (ORCPT + 99 others); Tue, 9 May 2023 23:49:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230423AbjEJDtq (ORCPT ); Tue, 9 May 2023 23:49:46 -0400 Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06D80210A for ; Tue, 9 May 2023 20:49:45 -0700 (PDT) Received: by mail-vs1-xe2f.google.com with SMTP id ada2fe7eead31-436161f2cf2so459346137.2 for ; Tue, 09 May 2023 20:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20221208.gappssmtp.com; s=20221208; t=1683690584; x=1686282584; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EI3dcKXw4MhS4ti0/DI9c0u69YLYabnxg/e6vkj4TDk=; b=3eLCbR86w+2RQbTKOZka2AFvBx7g3Zj+idJSXkQMLalMFcGXeUz+XfvSjS5T3uv4tC ipbYKnmAnxFqtIVoYb9RRc5rWc8sSZhMBetTu/C84ZGz+xO5n46P7DxYAjCWVKh/bbB6 zQ7X8BJpXXEa5XKfssyss21KSZ2HVUbaWfYmpNAR+B9M1rfFQrCE33GyKnSywu0Srhcy wlA6oN61GpbDDJunhNaEKhWlN2tYP9Cvy7flCv1W+OC1dPkdup2MESB1tUqfcZBxCqdI AwXrCWE2QhMWEc+DDu0ix4QKDbYBsc/wFjMoh7T7VtmDSWtwZi63QsOKmJzpVGp9lmaD x4tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683690584; x=1686282584; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EI3dcKXw4MhS4ti0/DI9c0u69YLYabnxg/e6vkj4TDk=; b=dAAxtRUntlhcP3kLEht6giV+n2NkMWUqElplAxzZQXzRh1RpCB5v6noQnVZ31Frq6s g64S/oLgG67xjAGp4vgZMP565THsw6S8DYRYM2u016Ax1ggrVSCMln1gy80rbrmOYfBw ymlyjunU69qGw6jCgOF46F8GxgRdJRqCa81FKrl5DZvPqOcElQM3iMX+5djXvv67pa+n ECXOrYr4nDUoW7guyMw6ouVkYdgS3csJRQNfqRs1gWqAqi9NuYPXX2higBgehLqWSiLi 7G8IfZfBZRl1kXrFvFKdMKPXdcTHvGsgEz/Nd9ApisYGVfnohrs/OtX72jbRtTthJrHd lUMw== X-Gm-Message-State: AC+VfDxH+7l/cYWa39XCFFfiJV5Prq9YkGXAZuaBQOYkCGC0ZO4wEdzh kBBXY5JV71wA1WULfF25GK0hKWAZLU6hFgeo5wrRMQ== X-Received: by 2002:a67:f9c2:0:b0:435:5255:a1fd with SMTP id c2-20020a67f9c2000000b004355255a1fdmr3666179vsq.3.1683690584107; Tue, 09 May 2023 20:49:44 -0700 (PDT) MIME-Version: 1.0 References: <20230427104428.862643-2-mie@igel.co.jp> <20230427182812.GA262399@bhelgaas> In-Reply-To: <20230427182812.GA262399@bhelgaas> From: Shunsuke Mie Date: Wed, 10 May 2023 12:49:33 +0900 Message-ID: Subject: Re: [RFC PATCH v2 1/3] PCI: endpoint: introduce a helper to implement pci ep virtio function To: Bjorn Helgaas Cc: Lorenzo Pieralisi , Kishon Vijay Abraham I , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Randy Dunlap , "Michael S. Tsirkin" , linux-pci@vger.kernel.org, Manivannan Sadhasivam , Frank Li , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Ren Zhijie , Jon Mason , Bjorn Helgaas Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, 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 I'll fix the typo and some styles you mentioned. In this e-mail, I reply to the other comments. 2023=E5=B9=B44=E6=9C=8828=E6=97=A5(=E9=87=91) 3:28 Bjorn Helgaas : > > Simple typos, don't repost until there's more substantive feedback. > > On Thu, Apr 27, 2023 at 07:44:26PM +0900, Shunsuke Mie wrote: > > The Linux PCIe Endpoint framework supports to implement PCIe endpoint > > functions using a PCIe controller operating in endpoint mode. > > It is possble to realize the behavior of PCIe device, such as virtio PC= I > > device. This patch introduces a setof helper functions and data structu= res > > to implement a PCIe endpoint function that behaves as a virtio device. > > s/possble/possible/ > s/setof/set of/ > > > Those functions enable the implementation PCIe endpoint function that > > comply with the virtio lecacy specification. Because modern virtio > > specifications require devices to implement custom PCIe capabilities, w= hich > > are not currently supported by either PCIe controllers/drivers or the P= CIe > > endpoint framework. > > s/implementation PCIe endpoint function/implementation of PCIe endpoint f= unctions/ > s/lecacy/legacy/ (What does "legacy" mean? Is there a spec for this?) Yes, it is defined in spec. > I guess "legacy virtio" devices need not implement custom PCIe > capabilities, but "modern virtio" devices must implement them? That I wanted to explain here. > Capitalize "Endpoint framework" consistently; sometimes it's > "Endpoint", other times it's "endpoint". I'll take care to be consistent. > > While this patch provides functions for negotiating with host drivers a= nd > > copying data, each PCIe function driver must impl ement operations that > > depend on each specific device, such as network, block, etc. > > s/impl ement/implement/ > > > +#include > > +#include > > +#include > > Typically the header includes would be alphabetized if possible. I'll try to reorder them. > > + vq_virt =3D pci_epc_map_addr(epf->epc, epf->func_no, epf->vfunc_n= o, > > + vq_pci_addr, vq_phys, vq_size); > > + if (IS_ERR(vq_virt)) { > > + pr_err("Failed to map virtuqueue to local"); > > s/virtuqueue/virtqueue/ > > I know you probably don't have any way to use dev_err(), but this > message really needs some context, like a driver name and instance or > something. I'll try to use the dev_* function appropriately If possible. > > +#define VIRTIO_PCI_LEGACY_CFG_BAR 0 > > What makes this a "legacy cfg BAR"? Is there some spec that covers > virtio BAR usage? Yes. Virtio Legacy interface defines the PCI BAR number to use. https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html= #x1-14500010 > > + * epf_virtio_init - initialize struct epf_virtio and setup BAR for vi= rtio > > + * @evio: struct epf_virtio to initialize. > > + * @hdr: pci configuration space to show remote host. > > + * @bar_size: pci BAR size it depends on the virtio device type. > > s/pci/PCI/ (there were also a few more instances above in messages or > comments) > > > + * epf_virtio_final - finalize struct epf_virtio. it frees bar and mem= ories > > + * @evio: struct epf_virtio to finalize. > > s/bar/BAR/ > > > +static void epf_virtio_monitor_qnotify(struct epf_virtio *evio) > > +{ > > + const u16 qn_default =3D evio->nvq; > > + u16 tmp; > > + > > + /* Since there is no way to synchronize between the host and EP f= unctions, > > + * it is possible to miss multiple notifications. > > Multi-line comment style. > > > + err =3D epf_virtio_negotiate_vq(evio); > > + if (err < 0) { > > + pr_err("failed to negoticate configs with driver\n"); > > s/negoticate/negotiate/ > > > + * epf_virtio_reset - reset virtio status > > Some of the function descriptions end with a period (".") and others > don't. Please figure out what the most common style is and use that > consistently. I agree. I'll fix to be consistent. > > + dst =3D pci_epc_map_addr(epf->epc, epf->func_no, > > + epf->vfunc_no, dbase, &phy= s, > > + slen); > > + if (IS_ERR(dst)) { > > + pr_err("failed to map pci mmoery spact to= local\n"); > > s/pci/PCI/ > s/mmoery/memory/ > s/spact/space/ ? > > Also below. > > IIRC some previous messages started with a capital letter. Please > make them all consistent. Sure. > > + if (dir =3D=3D DMA_MEM_TO_DEV) { > > + pci_epc_unmap_addr(epf->epc, epf->func_no, > > + epf->vfunc_no, phys, dst, slen= ); > > + } else { > > + pci_epc_unmap_addr(epf->epc, epf->func_no, > > + epf->vfunc_no, phys, src, slen= ); > > + } > > + } > > + > > + return 1; > > I guess this function returns either a negative error code or the > value 1? That seems sort of weird (I think "negative error code or > *zero* is more typical), but maybe you're following some convention? It has to be 0. It is my mistake. Some vringh functions return 0 (data does not exist), 1 (it exists), or error. But this functions is not related. > > +#include > > +#include > > +#include > > +#include > > Alpha order if possible Yes. > > + /* Virtual address of pci configuration space */ > > s/pci/PCI/ > > > + /* Callback function and parameter for queue notifcation > > + * Note: PCI EP function cannot detect qnotify accurately, theref= ore this > > + * callback function should check all of virtqueue's changes. > > + */ > > Multi-line comment style. > > Bjorn Best regards, Shunsuke