Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1558183rwd; Thu, 15 Jun 2023 12:09:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ad4hctBmokA8VN/zxA0YQohEV4FTzowt7wWMn8SV51qfXvpB858ScfooHlrNusRO9au2r X-Received: by 2002:aa7:d1c9:0:b0:514:95b1:f0ba with SMTP id g9-20020aa7d1c9000000b0051495b1f0bamr11967543edp.34.1686856156795; Thu, 15 Jun 2023 12:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686856156; cv=none; d=google.com; s=arc-20160816; b=wYDggFvFtHzeiOUY5VPvXVRa/Fgm9ttCQlZ5EZBcV5f0WgQlR6R/tpt1LAW91Mfc75 +MO9+XAneG0ovGMEsZKFrdnlWvyJiZr3e4Iv06i1kC5qywf6hEitvcz0PcMiM/03V9On Zdz1BNijYkH/XS0pjNH6Me1MnwPB79vuBNKkwh/4Vj4dGtqFFtzoV/x/GSX+CxTnZIGj MH1fbk0p+ZJ7agQzkC/8X1SOOt2mjp7secJ4uTl5w3rh4i/pITncOP70ZWE5FBpnGdEs +GdyWxBeMNKkJhYH4rEysqk2NfPEr2cSPN/q9kIX3/O+tbArse6RoAf9yG9jZAQ2QGE9 IkCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=58OsdpTMcNRMu1F+GfxrNCdlF+h/0XOQpROaCg3BpAs=; b=e7+P/H7H2apmfgwv/ioCmdh4cHdF1TLnR59T7zbNprB81cd4GJFrMxzXonNILE50fG RSCt3EkbKCr9Ar9hQuGNyCfIwmY4kjH67WEQIvrOj7of8hpi0sl2xeGcHrNTLv2Q0MUA V35Si4fqW0XKKERSE3AmSrdOvHECXSvb249E+YGQoCQTXW5Vixre2HrCgffZuP2L9rjc yqLBYWbiVAODXYOus1s33nhVZqVDhp2+zTKzqQ4MvJ/53KF5Aq2ppmwNH66m68rHett3 Yagom84ALk2zCWXjd+VhtJ2RixpLl9IeJ4RLY8k9R5TW91cCSrmKMd3W82ez4ZRnbrBd 9PsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BODNwPZa; 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 m26-20020a056402051a00b0051827a182edsi8014491edv.642.2023.06.15.12.08.44; Thu, 15 Jun 2023 12:09:16 -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=BODNwPZa; 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 S230133AbjFOSh7 (ORCPT + 99 others); Thu, 15 Jun 2023 14:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbjFOSh6 (ORCPT ); Thu, 15 Jun 2023 14:37:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 929C110F6; Thu, 15 Jun 2023 11:37:57 -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 DB8C662154; Thu, 15 Jun 2023 18:37:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB540C433C0; Thu, 15 Jun 2023 18:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686854276; bh=GrZU4Bzfm1Xqzo5EgU4CnnNwyScGSBZsQwfpSFcUTy4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=BODNwPZatG3b2JqhSWG5D/9wG7DxCwcU0n+OVYJJsEK8PJtcktivpxxL/Ml2BRlgr AsmVfkubwqS1mWQi6oj5pwJFFfffaG2LN8l4gjYmn8D3F6/64Vz2nmwAfm/xpcWrKz AI+zE2z1Ze9jLJ8o1OkjbkXOCTr7nu4ALkWKZBTRBuxvU2XmCxtJtSdU3CYXREzKcr usrwH7iDCLZiPtl7TnZKHoKfA7qMDvSSyhqA6EjiV1ayFEvty4vb2Amh7S/WzbZ+vD UJBUnhU2ZYt1DFC1JnGNmAdFb8cNNG9wr+5Tin6sZhpKNdwR3ocy9vj/ANs6CxYGL+ BeCL+54TSTW9Q== Date: Thu, 15 Jun 2023 13:37:54 -0500 From: Bjorn Helgaas To: "Maciej W. Rozycki" Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Oliver O'Halloran , Stefan Roese , Leon Romanovsky , linux-rdma@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Jim Wilson , Nicholas Piggin , Alex Williamson , Bjorn Helgaas , Mika Westerberg , David Abdurachmanov , linuxppc-dev@lists.ozlabs.org, Mahesh J Salgaonkar , "David S. Miller" , Lukas Wunner , netdev@vger.kernel.org, Pali =?iso-8859-1?Q?Roh=E1r?= , Saeed Mahameed Subject: Re: [PATCH v9 00/14] pci: Work around ASMedia ASM2824 PCIe link training failures Message-ID: <20230615183754.GA1483387@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Thu, Jun 15, 2023 at 01:41:10AM +0100, Maciej W. Rozycki wrote: > On Wed, 14 Jun 2023, Bjorn Helgaas wrote: > > > > This is v9 of the change to work around a PCIe link training phenomenon > > > where a pair of devices both capable of operating at a link speed above > > > 2.5GT/s seems unable to negotiate the link speed and continues training > > > indefinitely with the Link Training bit switching on and off repeatedly > > > and the data link layer never reaching the active state. > > > > > > With several requests addressed and a few extra issues spotted this > > > version has now grown to 14 patches. It has been verified for device > > > enumeration with and without PCI_QUIRKS enabled, using the same piece of > > > RISC-V hardware as previously. Hot plug or reset events have not been > > > verified, as this is difficult if at all feasible with hardware in > > > question. > > static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) > > { > > - bool retrain = true; > > int delay = 1; > > + bool retrain = false; > > + struct pci_dev *bridge; > > + > > + if (pci_is_pcie(dev)) { > > + retrain = true; > > + bridge = pci_upstream_bridge(dev); > > + } > > If doing it this way, which I actually like, I think it would be a little > bit better performance- and style-wise if this was written as: > > if (pci_is_pcie(dev)) { > bridge = pci_upstream_bridge(dev); > retrain = !!bridge; > } > > (or "retrain = bridge != NULL" if you prefer this style), and then we > don't have to repeatedly check two variables iff (pcie && !bridge) in the > loop below: Done, thanks, I do like that better. I did: bridge = pci_upstream_bridge(dev); if (bridge) retrain = true; because it seems like it flows more naturally when reading. Bjorn