From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E19FC31E5D for ; Wed, 19 Jun 2019 03:07:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 17D5320657 for ; Wed, 19 Jun 2019 03:07:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="G096vJ/m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729898AbfFSDHg (ORCPT ); Tue, 18 Jun 2019 23:07:36 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:38822 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbfFSDHg (ORCPT ); Tue, 18 Jun 2019 23:07:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=AixH9ESZvfDH28I8mSEmpRr0X0vbsD2WpNmHZWsXSvo=; b=G096vJ/mvORPe5syshMT/McfRZ GQp7+YgCBOxqh8/3F+cgK5JMNRkAEoQwr4UecZfmws1MCx8AnFA2l2UY08LjW4wTUP2jgHHHggG7Y bkPv+0VdzdcqH1BxqcBzDu6koTwDzPi62OvZG1Sm9S5M2jSnXoXOT5equNJ/KCaur08M=; Received: from andrew by vps0.lunn.ch with local (Exim 4.89) (envelope-from ) id 1hdQwb-000725-Ue; Wed, 19 Jun 2019 05:07:29 +0200 Date: Wed, 19 Jun 2019 05:07:29 +0200 From: Andrew Lunn To: Voon Weifeng Cc: "David S. Miller" , Maxime Coquelin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jose Abreu , Giuseppe Cavallaro , Florian Fainelli , Alexandre Torgue , Vinicius Costa Gomes , Ong Boon Leong Subject: Re: [RFC net-next 1/5] net: stmmac: introduce IEEE 802.1Qbv configuration functionalities Message-ID: <20190619030729.GA26784@lunn.ch> References: <1560893778-6838-1-git-send-email-weifeng.voon@intel.com> <1560893778-6838-2-git-send-email-weifeng.voon@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1560893778-6838-2-git-send-email-weifeng.voon@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Jun 19, 2019 at 05:36:14AM +0800, Voon Weifeng wrote: Hi Voon > +static int est_poll_srwo(void *ioaddr) > +{ > + /* Poll until the EST GCL Control[SRWO] bit clears. > + * Total wait = 12 x 50ms ~= 0.6s. > + */ > + unsigned int retries = 12; > + unsigned int value; > + > + do { > + value = TSN_RD32(ioaddr + MTL_EST_GCL_CTRL); > + if (!(value & MTL_EST_GCL_CTRL_SRWO)) > + return 0; > + msleep(50); > + } while (--retries); > + > + return -ETIMEDOUT; Maybe use one of the readx_poll_timeout() macros? > +static int est_read_gce(void *ioaddr, unsigned int row, > + unsigned int *gates, unsigned int *ti_nsec, > + unsigned int dbgb, unsigned int dbgm) > +{ > + struct tsn_hw_cap *cap = &dw_tsn_hwcap; > + unsigned int ti_wid = cap->ti_wid; > + unsigned int gates_mask; > + unsigned int ti_mask; > + unsigned int value; > + int ret; > + > + gates_mask = (1 << cap->txqcnt) - 1; > + ti_mask = (1 << ti_wid) - 1; > + > + ret = est_read_gcl_config(ioaddr, &value, row, 0, dbgb, dbgm); > + if (ret) { > + TSN_ERR("Read GCE failed! row=%u\n", row); It is generally not a good idea to put wrappers around the kernel print functions. It would be better if all these functions took struct stmmac_priv *priv rather than ioaddr, so you could then do netdev_err(priv->dev, "Read GCE failed! row=%u\n", row); > + /* Ensure that HW is not in the midst of GCL transition */ > + value = TSN_RD32(ioaddr + MTL_EST_CTRL); Also, don't put wrapper around readl()/writel(). > + value &= ~MTL_EST_CTRL_SSWL; > + > + /* MTL_EST_CTRL value has been read earlier, if TILS value > + * differs, we update here. > + */ > + if (tils != dw_tsn_hwtunable[TSN_HWTUNA_TX_EST_TILS]) { > + value &= ~MTL_EST_CTRL_TILS; > + value |= (tils << MTL_EST_CTRL_TILS_SHIFT); > + > + TSN_WR32(value, ioaddr + MTL_EST_CTRL); > + dw_tsn_hwtunable[TSN_HWTUNA_TX_EST_TILS] = tils; > + } > + > + return 0; > +} > + > +static int est_set_ov(void *ioaddr, > + const unsigned int *ptov, > + const unsigned int *ctov) > +{ > + unsigned int value; > + > + if (!dw_tsn_feat_en[TSN_FEAT_ID_EST]) > + return -ENOTSUPP; > + > + value = TSN_RD32(ioaddr + MTL_EST_CTRL); > + value &= ~MTL_EST_CTRL_SSWL; > + > + if (ptov) { > + if (*ptov > EST_PTOV_MAX) { > + TSN_WARN("EST: invalid PTOV(%u), max=%u\n", > + *ptov, EST_PTOV_MAX); It looks like most o the TSN_WARN should actually be netdev_dbg(). Andrew