Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4407029pxb; Mon, 21 Feb 2022 20:34:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJznr+O59DUlsF7xg7XArOm2KoWld+1xFQH6wiV2kMzxFasyT3M83PGrTLaXdGujcYC+/m5H X-Received: by 2002:a63:64a:0:b0:36c:6d40:5688 with SMTP id 71-20020a63064a000000b0036c6d405688mr18353275pgg.554.1645504483170; Mon, 21 Feb 2022 20:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645504483; cv=none; d=google.com; s=arc-20160816; b=aBzXtPQml25aFGXiajKZofrTxem4agRXXv9PmhqhR9AFaBemGBMM7zmDDAOXF8TY3w JFSG9X9JYccCuf1ri9G2y8caiXugXTl/sAdBFHIUIlF58QG9NGLHU3EakxWN5hH1W79g k+F7+E7VrfNOh4csx8uy0xleEIhN2nw+o3xKugJ3ofrUevqQnfJmPJ+IwbpwB/VDWDUC hK5cXo/Xweu+LzNXVgx+YJXhXkWLul5A0gFuVkCgfSAHDlRni0ZOZtv4MP/9yv1WtVO3 FZlOdvfMXmJtIZPFd3c5KOd2iQS4oxpMlJZpOg7NvZUbCGvmf7rbUN2dj/46pvpZJxJ3 hUMg== 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:dkim-signature; bh=uR7SiZmKCUIFK/y/tnK8VR20eBceG4PVTblPsXxfzUo=; b=pkv4iGIdNP8DrULWxahsT9v1wbgyDYKt2WlIWwCcSNx4QCRc0i0nGr1aEPAmCy6hLu wHOqfU8Y3sJuNlZT0swVKW+lUxZ+w2Npjak+5E14Yn+hajnWkfOadtOUMv4lIPi0UU7y Vvwl5p7B5fzP+mf9B8TT9Oh1KLpduR6bhq12kcRoH1/+i78JBnz3p/jCklgzxVzBTbNg DEk9PG8l3xoqs+0wl4rnzH/Be+WB/PeyGxuI2ZVKH1GO1pUI4bB3mAaRi/RSMoZ8roYf U2NoxSbSPcjWWshTH8t8Ba/oQurre8w1Q2hi72pbAhhOTnsXIFiEj17Qmr8GBhfj5ni7 zwAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FYMx+9Kk; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y5si35482316plg.169.2022.02.21.20.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 20:34:43 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FYMx+9Kk; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EDB113B3E2; Mon, 21 Feb 2022 20:23:10 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbiBUSBO (ORCPT + 99 others); Mon, 21 Feb 2022 13:01:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbiBUR7P (ORCPT ); Mon, 21 Feb 2022 12:59:15 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5ADD12AD8 for ; Mon, 21 Feb 2022 09:52:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645465919; 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=uR7SiZmKCUIFK/y/tnK8VR20eBceG4PVTblPsXxfzUo=; b=FYMx+9KkY46/b0Bd10lgmO3nVAOjSxjFebiz9jlWUil7IQfQT/S0PuqKxd+QeKIihgz1mu CoweTlrytRqnIHXjkYW+ZUWiqcZ7cdy/mhSwibzKWOx4BC/0fzg7VA4R1LSm5a7yGtDMky 5l8VEj+3bCPJ3nezXzkEf5jrBsfhNF8= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-65-sL_r1IM4NHGnqUYNOf1uLg-1; Mon, 21 Feb 2022 12:51:58 -0500 X-MC-Unique: sL_r1IM4NHGnqUYNOf1uLg-1 Received: by mail-qv1-f72.google.com with SMTP id fq2-20020a056214258200b0042c39c09e5dso17898196qvb.18 for ; Mon, 21 Feb 2022 09:51:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=uR7SiZmKCUIFK/y/tnK8VR20eBceG4PVTblPsXxfzUo=; b=HRWYOu2yXpmKPmWJon3DjjIk1pLZ4B2uv8T/VgyIAyKlpRVzi6oSNahb4hqOLyNgRX Q/LLmRQ5wB0+Zvg6R/JhToE31Eckebdhh8zaX5t7EOz56OCIP4WCZjZ2yvP40ylg56LB hmZhMMByNq07Hr3fjExhDRTQbN48MBfZY1ifT2bwpYA2LIg7WD0BObB0ZFtzsQQ/03yA JUk1WWJUrt2/BTAwbpgBFgu56uNXXUQrgWrjSNOKxkDlV9ung31iUUKYvil6AaAESrqo 722sJBvCUO9gmkU2FDRDmdqGSCUupgYRaOtZX1ty+2hMBtBvgQ0aa/o5ARi4qSodJlf6 NGFA== X-Gm-Message-State: AOAM533UkzLqDAD4PylawVisA4NJbCzaXhkN7LHmhJW4Bfb8uk8tosw0 B4XrIun4uzYkUjXClI6XYdYqbx7HkVds38iXcPgDZ0MEGIFrdrvBtRC6fvDJ55I+qdt1amzZ/co 3ki3okxxSvY1k9sKi5rY1Xv3w X-Received: by 2002:a05:620a:178d:b0:648:e091:6ddc with SMTP id ay13-20020a05620a178d00b00648e0916ddcmr3932720qkb.553.1645465918289; Mon, 21 Feb 2022 09:51:58 -0800 (PST) X-Received: by 2002:a05:620a:178d:b0:648:e091:6ddc with SMTP id ay13-20020a05620a178d00b00648e0916ddcmr3932703qkb.553.1645465918085; Mon, 21 Feb 2022 09:51:58 -0800 (PST) Received: from localhost.localdomain (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id x83sm7541757qkb.68.2022.02.21.09.51.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Feb 2022 09:51:57 -0800 (PST) Subject: Re: [PATCH v1 3/7] fpga: dfl: Allow for ports with no local bar space. To: matthew.gerlach@linux.intel.com Cc: "Zhang, Tianfei" , "Wu, Hao" , "mdf@kernel.org" , "Xu, Yilun" , "linux-fpga@vger.kernel.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "corbet@lwn.net" References: <20220214112619.219761-1-tianfei.zhang@intel.com> <20220214112619.219761-4-tianfei.zhang@intel.com> <0fdd3d0d-d280-8104-eccc-8fa8d8a992c2@redhat.com> From: Tom Rix Message-ID: <8137a208-43e3-3843-eca9-f6ec627e8d0e@redhat.com> Date: Mon, 21 Feb 2022 09:51:55 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 On 2/21/22 9:22 AM, matthew.gerlach@linux.intel.com wrote: > > > On Fri, 18 Feb 2022, Tom Rix wrote: > >> >> On 2/17/22 11:31 PM, Zhang, Tianfei wrote: >>> >>>> -----Original Message----- >>>> From: Tom Rix >>>> Sent: Tuesday, February 15, 2022 11:06 PM >>>> To: Zhang, Tianfei ; Wu, Hao >>>> ; >>>> mdf@kernel.org; Xu, Yilun ; >>>> linux-fpga@vger.kernel.org; >>>> linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org >>>> Cc: corbet@lwn.net; Matthew Gerlach >>>> Subject: Re: [PATCH v1 3/7] fpga: dfl: Allow for ports with no >>>> local bar space. >>>> >>>> >>>> On 2/14/22 3:26 AM, Tianfei zhang wrote: >>>>> From: Matthew Gerlach >>>>> >>>>>   From a fpga partial reconfiguration standpoint, a port may not be >>>>> connected any local BAR space.  The port could be connected to a >>>>> different PCIe Physical Function (PF) or Virtual Function (VF), in >>>>> which case another driver instance would manage the endpoint. >>>> It is not clear if this is part of iofs or a bug fix. >>> This is the new implementation/feature of IOFS. >>> On IOFS support multiple methods to access the AFU. >>> 1. Legacy Model. This is used for N3000 and N5000 card. >>> In this model the entire AFU region is a unit of PR, and there is a >>> Port device connected to this AFU. >>> On DFL perspective, there is "Next AFU" point to the AFU, and the >>> "BarID" is  the PCIe Bar ID of AFU. >>> In this model, we can use the AFU APIs to access the entire AFU >>> resource, like MMIO. >>> 2. Micro-Personas in AFU. >>> IOFS intruding new model for PR and AFU access. >>> Micro-Personas allow the RTL developer to designate their own >>> AFU-defined PR regions. >>> In this model the unit of PR is not the entire AFU, instead >>> the unit of PR can be any size block or blocks inside the AFU. >>> 3. Multiple VFs per PR slot. >>> In this method, we can instance multiple VFs over SRIOV for one PR >>> slot, and access the AFU resource >>> by different VFs in virtualization usage. In this case, the Port >>> device would not connected to AFU (the BarID of Port device >>> should be set to invalid), so this patch want to support this use >>> model. >> >> What I am looking for is how the older cards using (my term) dfl 1 >> will still work with dfl 2 and vice versa. >> >> No where do I see a version check for dfl 2 nor a pci id check so >> either this just works or backward compatibility has not be considered. >> >> Please add a backward compatibility section to the doc patch >> >>> >>>>> Signed-off-by: Matthew Gerlach >>>>> Signed-off-by: Tianfei Zhang >>>>> --- >>>>>    drivers/fpga/dfl-pci.c | 8 ++++++++ >>>>>    1 file changed, 8 insertions(+) >>>>> >>>>> diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c index >>>>> 4d68719e608f..8abd9b408403 100644 >>>>> --- a/drivers/fpga/dfl-pci.c >>>>> +++ b/drivers/fpga/dfl-pci.c >>>>> @@ -243,6 +243,7 @@ static int find_dfls_by_default(struct pci_dev >>>>> *pcidev, >>>>>            v = readq(base + FME_HDR_CAP); >>>>>            port_num = FIELD_GET(FME_CAP_NUM_PORTS, v); >>>>> >>>>> +        dev_info(&pcidev->dev, "port_num = %d\n", port_num); >>>>>            WARN_ON(port_num > MAX_DFL_FPGA_PORT_NUM); >>>>> >>>>>            for (i = 0; i < port_num; i++) { >>>>> @@ -258,6 +259,13 @@ static int find_dfls_by_default(struct >>>>> pci_dev *pcidev, >>>>>                 */ >>>>>                bar = FIELD_GET(FME_PORT_OFST_BAR_ID, v); >>>>>                offset = FIELD_GET(FME_PORT_OFST_DFH_OFST, v); >>>>> +            if (bar >= PCI_STD_NUM_BARS) { >>>> Is bar set to a better magic number that pci_std_num_bars ? maybe >>>> 0xff's >>>> >>>> How do you tell between this case and broken hw ? >>> Yes, I agree that magic number is better, Currently the RTL using >>> PCI_STD_NUM_BARS for an invalid PCIe bar number. >> >> How do you tell between this case and broken hw ? >> >> Tom > > The field, FME_PORT_OFST_BAR_ID, is a three bit field, which is pretty > common for BARs on PCI.  PCI_STD_NUM_BARS is defined as 6. Current HW > implementations are filing this field with the value, 7, which is > close to the suggestion of 0xff's.  How about we define the following > magic number? > #define NO_LOCAL_PORT_BAR    7 > > We should also change the dev_info to be a dev_dbg and more precise to > something like the following: > >     if (bar == NO_LOCAL_PORT_BAR) { >         dev_dbg(&pcidev->dev, "No local port BAR space.\n"); >         continue; >     } What I am looking for is way generally is to tell if this is an old framework or a new one. Maybe a flag and/or version added to dfl_fpga_cdev on probing ? (The meaning of released_port_num likely needs to change there as well) So in this case you could check if this was the new framework before doing the bar check. Similar checks other places where ofs stuff is being fit it. My concern is the fitting in without checking will break the old stuff. And why I wanted to see a probing writeup in the dfl.rst doc Tom > >> >>>> Move up a line and skip getting an offset that will not be used. >>> Yes, this line is not necessary, I will remove it on next version >>> patch. >>> >>>>> + dev_info(&pcidev->dev, "skipping port without >>>> local BAR space %d\n", >>>>> +                     bar); >>>>> +                continue; >>>>> +            } else { >>>>> +                dev_info(&pcidev->dev, "BAR %d offset %u\n", >>>> bar, offset); >>>>> +            } >>>>>                start = pci_resource_start(pcidev, bar) + offset; >>>>>                len = pci_resource_len(pcidev, bar) - offset; >>>>> >>>> Is similar logic needed for else-if (port) block below this ? >>> I think, the else-if is not necessary. I will remove it on next >>> version patch. >>>> Tom >> >> >