From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753421AbbJOUxb (ORCPT ); Thu, 15 Oct 2015 16:53:31 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:57904 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753054AbbJOUx3 (ORCPT ); Thu, 15 Oct 2015 16:53:29 -0400 From: Arnd Bergmann To: "Kwok, WingMan" Cc: "linux-arm-kernel@lists.infradead.org" , "robh+dt@kernel.org" , "pawel.moll@arm.com" , "mark.rutland@arm.com" , "ijc+devicetree@hellion.org.uk" , "galak@codeaurora.org" , KISHON VIJAY ABRAHAM , "Quadros, Roger" , "Karicheri, Muralidharan" , "bhelgaas@google.com" , "ssantosh@kernel.org" , "linux@arm.linux.org.uk" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" Subject: Re: [PATCH v1 1/2] phy: keystone: serdes driver for gbe 10gbe and pcie Date: Thu, 15 Oct 2015 22:53:16 +0200 Message-ID: <9008744.UmMoJzNEVK@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <230CBA6E4B6B6B418E8730AC28E6FC7E04228DB8@DFLE11.ent.ti.com> References: <1444919145-30845-1-git-send-email-w-kwok2@ti.com> <5192855.p6QLDWTiVi@wuerfel> <230CBA6E4B6B6B418E8730AC28E6FC7E04228DB8@DFLE11.ent.ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:Dm/3i1zWKdCBZkKLXn7MT69XFq+z6a0LHuR98X31O89IAdeINYR 29cuMz/vosci3yRuKFW4sXZddefhlxanXqZD3Zayjv3Vy1yflbDl3mm84x8m7Eli+qJ8Xq1 bJDZg5OueVoZYQc6QeJcfk867m7ezNTweqGOZnYS8UrEDXOzS/Q2JlhBqXGwucxnFtPcSl/ 2RHI0xsqPmgtXDo5A+9hQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:Zd3uP+vDRzk=:hFDczs4WabFwY1kRoQ+x04 81q1PJHRoTzwGSFm9y80L3YX4Gr6KUJEBn29ZiigrFDin9c1+3Vo7IGCAPuhqy6b586HGR2AP GuFSqwVtDAo1DqSSvlBSDhutv2mWlA7eJpgsG0UknJgaOo3NTAPT2vCbupFeAWs9ZHN/8s2eS 1a8Wq0M+XkBR41kRqn3QPrVmCwEwV1fDudLGqcHqV1pH26M79g6oWD/RED+pIORlMvCZkcDN0 8q9j/JcEuB4cD2lFQ6QMLJ1lQeFRKy9HGCby8TQyCPT+D64WoAkMROsARhMPGcF1zkahHqPi1 Sz7kzZPdWF8ZHkN11WvVT/7z+C/fFlVomL40n8AKvggnd9aSE125FXqb2QxsUGo2UPRtsDB8l ZOBWiDMFv2ryNksgynTp4fpi6x+uINkKZdxSmm7ION8yySyEwOwM1DChK48f4zECjZZ4jbP43 FyeLk340zqX+2xtI+cfA+h+sqIf06/q0zNnff/ykYxr0Br5uBY/m9PCnd5SpQnHZpAq3E1veC Et1zT6LUp1EPRDgw+ZefW+P3odX6OWl/UIhbrQ6x6OU4wX7K78f/WvSi9wn8hV2xxWZvh3yYc HY1sd/ty82Tpem42xzgxEJjKgQRVvgAFwAvfTkziruGZcE0I/zFp7Xz90uSCIeqVPgI3I2fiq VnyG/PfyhZNNyxQOO98JymYdDjBBOJ0zcUHZG21Nhz0Ur1tkRO0Zo2Zn/TLcpIuvzuCOgnhcz kD6poAgHnmUOA9F0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 15 October 2015 20:08:32 Kwok, WingMan wrote: > > > > +#define reg_rmw(addr, value, mask) \ > > > + __raw_writel(((__raw_readl(addr) & (~(mask))) | \ > > > + (value & (mask))), (addr)) > > > > not endian safe, and potentially racy. > > > > will change to > > #define reg_rmw(addr, value, mask) \ > writel(((readl(addr) & (~(mask))) | \ > (value & (mask))), (addr)) Ok, sounds good. Note that if any of this is performance critical, better use readl_relaxed(), but as long as this is just for setup code and not for data transfers, staying with readl() as you suggest is better. > > > +static inline void _kserdes_reset_cdr(void __iomem *sregs, int lane) > > > +{ > > > + /* toggle signal detect */ > > > + _kserdes_force_signal_detect_low(sregs, lane); > > > + mdelay(1); > > > + _kserdes_force_signal_detect_high(sregs, lane); > > > +} > > > > Can you change the code so you can use msleep(1) here? > > > > will replace delays with usleep_range() Ok. > > > + > > > + do { > > > + mdelay(10); > > > + memset(lane_down, 0, sizeof(lane_down)); > > > + > > > + link_up = _kserdes_check_link_status(dev, sregs, > > > + pcsr_regmap, lanes, > > > + lanes_enable, > > > + current_state, lane_down); > > > + > > > + /* if we did not get link up then wait 100ms > > > + * before calling it again > > > + */ > > > + if (link_up) > > > + break; > > > + > > > + for (i = 0; i < lanes; i++) { > > > + if ((lanes_enable & (1 << i)) && lane_down[i]) > > > + dev_dbg(dev, > > > + "XGE: detected lane down on lane %d\n", > > > + i); > > > + } > > > + > > > + if (++retries > 100) > > > + return -ETIMEDOUT; > > > + > > > + } while (!link_up); > > > > an more importantly here. Blocking the CPU for over one second is not good. > > > > Any use of mdelay() should have a comment explaining why you cannot use > > msleep() in that instance. > > > > will replace delays with usleep_range() Here you have to be careful with the total runtime. Using usleep_range() is a good idea, and you can have a particularly wide range, but then you should changen the timeout condition from number of retries to total elapsed time like unsigned long timeout = jiffies + HZ; /* 1 second maximum */ do { ... if (link_up) break; if (time_after(jiffies, timeout) return -ETIMEOUT; usleep_range(1000, 50000); } while (1); Arnd