Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3456731rdh; Thu, 28 Sep 2023 12:10:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHx4bvWL4qsQZ0AoCNT8us9nqebdzB2QJ4nYjsjC7nulDGsHkXXhmaFQh4oInsfiVGzRFTR X-Received: by 2002:a05:6808:1885:b0:3a7:5557:16ba with SMTP id bi5-20020a056808188500b003a7555716bamr2558351oib.27.1695928217028; Thu, 28 Sep 2023 12:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695928216; cv=none; d=google.com; s=arc-20160816; b=n6r32CLhcjJROcJiOi62rmUu3rFeYYVdC2JMYl3jthHVmqE5BYmj0WmyxI1Q6Hen/S 7JvSBtD2HqI7FJJ2GhtMQiZ1AJS/Hl9rfkZh9VeXeAcw4XYsI6dS/q0Z6NRwkAQMaPZH SX/FLWz5NsVxmQ0KsWqzRTigzzVkkTo7phAsXAUGlt3hLvB/ACdw6uNkAYKt+zA002Cj jjfStVzVKZSNFQx8Tu6W7FuZ7fSKkyN7jz+3Dwd92V286yA3o7+HbhcA++pME+UbTgBo +pVqESiI2heGT6OONseY2n5FxdsE5GS2QasoZMqKMmcKlt4qA0g9qhE/sfOEQk5NuZ5h 1Eyw== 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 :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FJiGbzqyQX60TGKIqUfn5XiUIwT1jRAcgoyuoh2o3Xw=; fh=5CHWFM5viytVs+flWhOkNaAbzusUvbhLAkNuRdKmqLE=; b=mn9x/uKDV9bMxdC3z9NKfqMuxoKudvdJ+Ot1b5AEULYqStFeMK/gHsZidl70YN/+fQ JakgOqAL/V2dhHtHw0zZtnTJUv5TWRouj46p6ikBfJMEh9bLlDYHCUVqDDJfl8wmF0Oy 6Ge39/CYrnsw5E2Y2uhj6t3RMDPni0vyr2Ai1uiQusaXghjySJqGHvLw1KO2KZbnsYWO H2AKPNBGnX9xwQ2eZx5azCdFblghngYUDNOUxu+ggnuhKgvd6CADRIzB1F+VCj6pE75W MrfhFDu1t3Smqp7fYHiIDA+06txzM+tty6w+BSLEBIhsVXBLpPwGTlDqwU8jzgddUeZj sJ/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lLGzXOq2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id u14-20020a63f64e000000b005653283b8a4si20271438pgj.785.2023.09.28.12.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 12:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lLGzXOq2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E28878083482; Thu, 28 Sep 2023 12:07:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbjI1THE (ORCPT + 99 others); Thu, 28 Sep 2023 15:07:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjI1THD (ORCPT ); Thu, 28 Sep 2023 15:07:03 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 048C1194 for ; Thu, 28 Sep 2023 12:07:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D88F5C433C7; Thu, 28 Sep 2023 19:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695928021; bh=h2mLoXWXVYbN/GQUNVZLyj+AYwIemw9Pknt/ZTBSAtY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lLGzXOq2aAtYKG/F6iMP7gKCBmkSnjG2JKjrrQ9ac0EPmzbdeR0vAmbZ0z9gLBxwg /y6cWE7fN7+U0ULhn+k4lVPa74I1608uALI4irvkXq1d6wpcaB8jpmlKHy5VxIM1yN AvLTC2cnoOGdbgCTAwDFFvpBIRUoH9fssv7nfzzgx6OOheMdmwoQwM0hoThdXRXbfv Nee1UCyFQtrsdxqrnxEuPtr7h6VZfPea2SOzXynmWppp2FIl+1nAdZWvwpvtWjtawl k/H5S/NDSrEEXannR7tjrevGChbO+tYsTiKDFB+L+ddc6BORcOqk679oLQIWDdSpKw JcWsWUR/30reQ== Date: Thu, 28 Sep 2023 21:06:54 +0200 From: Simon Horman To: Vladimir Oltean Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: Re: [RFC PATCH v2 net-next 14/15] net: pcs: mtip_backplane: add driver for MoreThanIP backplane AN/LT core Message-ID: <20230928190654.GP24230@kernel.org> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> <20230923134904.3627402-15-vladimir.oltean@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230923134904.3627402-15-vladimir.oltean@nxp.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 28 Sep 2023 12:07:14 -0700 (PDT) On Sat, Sep 23, 2023 at 04:49:03PM +0300, Vladimir Oltean wrote: ... > +static int mtip_rx_c72_coef_update(struct mtip_backplane *priv, > + struct c72_coef_update *upd, > + bool *rx_ready) > +{ > + char upd_buf[C72_COEF_UPDATE_BUFSIZ], stat_buf[C72_COEF_STATUS_BUFSIZ]; > + struct device *dev = &priv->mdiodev->dev; > + struct c72_coef_status stat = {}; > + int err, val; > + > + err = read_poll_timeout(mtip_read_lt_lp_coef_if_not_ready, > + val, val < 0 || *rx_ready || LT_COEF_UPD_ANYTHING(val), > + MTIP_COEF_STAT_SLEEP_US, MTIP_COEF_STAT_TIMEOUT_US, > + false, priv, rx_ready); > + if (val < 0) > + return val; > + if (*rx_ready) { > + if (!priv->any_request_received) > + dev_warn(dev, > + "LP says its RX is ready, but there was no coefficient request (LP_STAT = 0x%x, LD_STAT = 0x%x)\n", > + mtip_read_lt(priv, LT_LP_STAT), > + mtip_read_lt(priv, LT_LD_STAT)); > + else > + dev_dbg(dev, "LP says its RX is ready\n"); > + return 0; > + } > + if (err) { > + dev_err(dev, > + "LP did not request coefficient updates; LP_COEF = 0x%x\n", > + val); > + return err; > + } > + > + upd->com1 = LT_COM1_X(val); > + upd->coz = LT_COZ_X(val); > + upd->cop1 = LT_COP1_X(val); > + upd->init = !!(val & LT_COEF_UPD_INIT); > + upd->preset = !!(val & LT_COEF_UPD_PRESET); > + Hi Vladimir, I'm unsure if this can actually happen. But if the while loop runs zero times then err is used uninitialised here. As flagged by Smatch. > + mtip_an_restart_from_lt(priv); > + > + kfree(lt_work); > +} > + > +/* Train the link partner TX, so that the local RX quality improves */ > +static void mtip_remote_tx_lt_work(struct kthread_work *work) > +{ > + struct mtip_lt_work *lt_work = container_of(work, struct mtip_lt_work, > + work); > + struct mtip_backplane *priv = lt_work->priv; > + struct device *dev = &priv->mdiodev->dev; > + int err; > + > + while (true) { > + struct c72_coef_status status = {}; > + union phy_configure_opts opts = { > + .ethernet = { > + .type = C72_REMOTE_TX, > + }, > + }; > + > + if (READ_ONCE(priv->lt_stop_request)) > + goto out; Likewise, I'm unsure if this can happen. But if the condition above is met on the first iteration of the loop then the out label will use err without it being initialised. Also flagged by Smatch. > + > + err = mtip_lt_in_progress(priv); > + if (err) { > + dev_err(dev, "Remote TX LT failed: %pe\n", ERR_PTR(err)); > + goto out; > + } > + > + err = phy_configure(priv->serdes, &opts); > + if (err) { > + dev_err(dev, > + "Failed to get remote TX training request from SerDes: %pe\n", > + ERR_PTR(err)); > + goto out; > + } > + > + if (opts.ethernet.remote_tx.rx_ready) > + break; > + > + err = mtip_tx_c72_coef_update(priv, &opts.ethernet.remote_tx.update, > + &status); > + if (opts.ethernet.remote_tx.cb) > + opts.ethernet.remote_tx.cb(opts.ethernet.remote_tx.cb_priv, > + err, opts.ethernet.remote_tx.update, > + status); > + if (err) > + goto out; > + } > + > + /* Let the link partner know we're done */ > + err = mtip_modify_lt(priv, LT_LD_STAT, LT_COEF_STAT_RX_READY, > + LT_COEF_STAT_RX_READY); > + if (err < 0) { > + dev_err(dev, "Failed to update LT_LD_STAT: %pe\n", > + ERR_PTR(err)); > + goto out; > + } > + > + err = mtip_remote_tx_lt_done(priv); > + if (err) { > + dev_err(dev, "Failed to finalize remote LT: %pe\n", > + ERR_PTR(err)); > + goto out; > + } > + > +out: > + if (err && !READ_ONCE(priv->lt_stop_request)) > + mtip_an_restart_from_lt(priv); > + > + kfree(lt_work); > +} ...