Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1848648rwo; Thu, 3 Aug 2023 00:07:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlH9KMBt2yUxpfWSLM9H1Z8j/ekQDdMcJL9ePkQmEXaAt144XuHPhbNQ0eeFFVGgi6D9x8HQ X-Received: by 2002:a17:906:847b:b0:993:db29:d27d with SMTP id hx27-20020a170906847b00b00993db29d27dmr7602679ejc.34.1691046457361; Thu, 03 Aug 2023 00:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691046457; cv=none; d=google.com; s=arc-20160816; b=oKvnqyzSzOSS4T1udAcdopVmTiyDkvvFghb88q70mjowbqypbLJm9ihXb3c6YOjnZD u96yzmHvvwZqhfTKNTHAkO4uWx/UHGzvOw8+5mqe+Do1xWBzr6I/P8/2ddCGUN/TEq80 z7/7Anh3ug7QJxbur4YUFgAW9sob7Q0Vxugw7vMLoG1V8Yy77/UE8zfFbeLye/Ezm2TJ KCd7aFG833GfdtojG6VIE9Upcy8wlQrd5UFHFpV1JvAUz7Lpm6yuzuytBWb+/3CdOBIk X44AcfhxSFzmWB0zM6RyX/M2zd3IN9mXeNcAU+ruvamnbnY8qaHwcrGwiP13CXnDbnrR 4rSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=JZ6NoGCNekn1bAGfuYzzHwBPv/yt1/t32OYwePviQ4k=; fh=zil4cExmtwakTdfFwOyHTGAyoGYCxcRX0Y2i3qYb4RI=; b=AGit2RBtFm2Wge1vbZ71OvhbnbxjxEbxDy4DB+ONQXE7qAGyqT+aWJqBNnF5YSCkZr If4AyZrNWrvcC4eSoQpSCjSpMonGx9+oYISXqhqZGOY9+VbE5yvP3loxCVUbK29L2jG4 oJqt4N/vr+3Z47igcvv+34eiy6ri0ljT5xJHYhvRDpxyEDzddHHqnM6QxRhaVDVF98HA Y/jvt65icBtT58lhI9EmWY8+ocgtQChWZqcqNX0aZaRYCfskRGS+lMbTl3tNmLvTcrJt IU20CXWxObMo700n+9yAzydFj60W6IEYGTq0SMETig9/06t0q01lgFoKNrFCcd0j63yk 5izQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pwpVGu32; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a17090686cd00b0098d2f715b89si7710388ejy.102.2023.08.03.00.07.13; Thu, 03 Aug 2023 00:07:37 -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=@kernel.org header.s=k20201202 header.b=pwpVGu32; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231717AbjHCG6m (ORCPT + 99 others); Thu, 3 Aug 2023 02:58:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbjHCG6l (ORCPT ); Thu, 3 Aug 2023 02:58:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8B5410EA; Wed, 2 Aug 2023 23:58:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7196B61C1E; Thu, 3 Aug 2023 06:58:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F461C433C9; Thu, 3 Aug 2023 06:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691045918; bh=sqSreMbIGrWV0DPZRg5162ALe8Otsvrn0WlWCkXOoKU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pwpVGu32s8kTis/hGZpdhhczYy+byBo1QyijdUrRpq1agDkzY3ihd9kC3w49MS+MK +sv6t+3TMBnFVclOELLDz99O6cjOTTIP24m5ueEqLfGToNJlECpe4fVCgD4s5VzN+W ZPQdj169c4/sscvY6QFclLuY9Fduv/C8+6pPmbWHkl6J14/jI8ZCt+IpvFpKkK+HkX mbwI1f+WjNHC0hve4CxhG4tJkh5iKmeTN7ZwpVWDonxf7W8G/ICXkg3c2w79rD+svy D2tpDcskFFcTjTwC3kqrzv2zd6plPXwWFKjXfhx9XNRYclsdp2EPfTnCZiAH0ptWFJ thcMc6IGBMsIQ== Received: by pali.im (Postfix) id 4A8C167C; Thu, 3 Aug 2023 08:58:35 +0200 (CEST) Date: Thu, 3 Aug 2023 08:58:35 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Kevin Xie Cc: Bjorn Helgaas , Minda Chen , Daire McNamara , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Bjorn Helgaas , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Emil Renner Berthing , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Mika Westerberg , "Maciej W. Rozycki" , Marek =?utf-8?B?QmVow7pu?= Subject: Re: [PATCH v1 8/9] PCI: PLDA: starfive: Add JH7110 PCIe controller Message-ID: <20230803065835.twdicvx62mgzzzqi@pali> References: <20230802171805.GA62238@bhelgaas> <1c546489-40dd-25c5-3ac2-9e3b3fd5a670@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c546489-40dd-25c5-3ac2-9e3b3fd5a670@starfivetech.com> User-Agent: NeoMutt/20180716 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Thursday 03 August 2023 10:23:47 Kevin Xie wrote: > On 2023/8/3 1:18, Bjorn Helgaas wrote: > > On Tue, Aug 01, 2023 at 03:05:46PM +0800, Kevin Xie wrote: > >> On 2023/8/1 7:12, Bjorn Helgaas wrote: > >> ... > > > >> > The delay required by sec 6.6.1 is a minimum of 100ms following exit > >> > from reset or, for fast links, 100ms after link training completes. > >> > > >> > The comment at the call of advk_pcie_wait_for_link() [2] says it is > >> > the delay required by sec 6.6.1, but that doesn't seem right to me. > >> > > >> > For one thing, I don't think 6.6.1 says anything about "link up" being > >> > the end of a delay. So if we want to do the delay required by 6.6.1, > >> > "wait_for_link()" doesn't seem like quite the right name. > >> > > >> > For another, all the *_wait_for_link() functions can return success > >> > after 0ms, 90ms, 180ms, etc. They're unlikely to return after 0ms, > >> > but 90ms is quite possible. If we avoided the 0ms return and > >> > LINK_WAIT_USLEEP_MIN were 100ms instead of 90ms, that should be enough > >> > for slow links, where we need 100ms following "exit from reset." > >> > > >> > But it's still not enough for fast links where we need 100ms "after > >> > link training completes" because we don't know when training > >> > completed. If training completed 89ms into *_wait_for_link(), we only > >> > delay 1ms after that. > >> > >> That's the point, we will add a extra 100ms after PERST# de-assert > >> in the patch-v3 according to Base Spec r6.0 - 6.6.1: > >> msleep(100); > >> gpiod_set_value_cansleep(pcie->reset_gpio, 0); > >> > >> + /* As the requirement in PCIe base spec r6.0, system must wait a > >> + * minimum of 100 ms following exit from a Conventional Reset > >> + * before sending a Configuration Request to the device.*/ > >> + msleep(100); > >> + > >> if (starfive_pcie_host_wait_for_link(pcie)) > >> return -EIO; > > > > For fast links (links that support > 5.0 GT/s), the 100ms starts > > *after* link training completes. The above looks OK if starfive only > > supports slow links, but then I'm not sure why we would need > > starfive_pcie_host_wait_for_link(). > > > Yes, the maximum speed of JH7110 PCIe is 5.0 GT/s (Gen2x1). > > About starfive_pcie_host_wait_for_link(): > JH7110 SoC only has one root port in each PCIe controller (2 in total) > and they do not support hot-plug yet. Beware that even if HW does not support hotplug, endpoint PCIe card still may drop the link down and later put it up (for example if FW in the card crashes or when card want to do internal reset, etc...; this is very common for wifi cards). So drivers for non-hotplug controllers still have to handle hotplug events generated by link up/down state. So it means that, if endpoint PCIe card is not detected during probe time, it may be detected later. So this check to completely stop registering controller is not a good idea. Note that userspace can tell kernel (via sysfs) to rescan all PCIe buses and try to discover new PCIea devices. > Thus, We add starfive_pcie_host_wait_for_link() to poll if it is a empty slot. > If nothing here, we will exit the probe() of this controller, and it will not > go into pci_host_probe() too. > This may not be a very standard logic, should we remove it or rewrite in a better way? > > > Bjorn Rather to remove this starfive_pcie_host_wait_for_link logic. Better option would be to teach PCI core code to wait for the link before trying to read vendor/device ids, like I described in my old proposal.