All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carl-Daniel Hailfinger <c-d.hailfinger.kernel.2004@gmx.net>
To: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Francois Romieu <romieu@fr.zoreil.com>,
	Brian Lazara <blazara@nvidia.com>,
	Christoph Hellwig <hch@infradead.org>,
	Manfred Spraul <manfred@colorfullife.com>,
	Andrew de Quincey <adq@lidskialf.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] new device support for forcedeth.c second try
Date: Sat, 19 Jun 2004 16:35:09 +0200	[thread overview]
Message-ID: <40D44F1D.6090701@gmx.net> (raw)
In-Reply-To: <200406191615.48903.bzolnier@elka.pw.edu.pl>

Bartlomiej Zolnierkiewicz wrote:
> On Saturday 19 of June 2004 15:55, Francois Romieu wrote:
> 
>>Carl-Daniel Hailfinger <c-d.hailfinger.kernel.2004@gmx.net> :
>>[...]
>>
>>
>>>+static int phy_reset(struct net_device *dev)
>>>+{
>>>+	struct fe_priv *np = get_nvpriv(dev);
>>>+	u32 miicontrol;
>>>+	u32 microseconds = 0;
>>>+	u32 milliseconds = 0;
>>>+
>>>+	miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
>>>+	miicontrol |= BMCR_RESET;
>>>+	if (mii_rw(dev, np->phyaddr, MII_BMCR, miicontrol)) {
>>>+		return -1;
>>>+	}
>>>+
>>>+	//wait for 500ms
>>>+	mdelay(500);
>>>+
>>>+	//must wait till reset is deasserted
>>>+	while (miicontrol & BMCR_RESET) {
>>>+		udelay(NV_MIIBUSY_DELAY);
>>>+		miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
>>>+		microseconds++;
>>>+		if (microseconds == 20) {
>>>+			microseconds = 0;
>>>+			milliseconds++;
>>>+		}
>>>+		if (milliseconds > 50)
>>>+			return -1;
>>>+	}
>>>+	return 0;
>>>+}
>>
>>Afaiks this function is not called from a spinlocked nor is it
>>time-critical. You should make it use schedule_timeout().

Thanks for highlighting the above code. I saw it and wanted to fix it, but
then I got sidetracked and forgot.

> msleep()

Bartlomiej, could you prepare a patch to move the msleep() function from
drivers/scsi/libata-core.c to include/linux/delay.h ? This is going to
benefit users besides libata.


New version:

static int phy_reset(struct net_device *dev)
{
        struct fe_priv *np = get_nvpriv(dev);
        u32 miicontrol;
        unsigned int tries = 0;

        miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
        miicontrol |= BMCR_RESET;
        if (mii_rw(dev, np->phyaddr, MII_BMCR, miicontrol)) {
                return -1;
        }

        //wait for 500ms
        msleep(500);

        //must wait till reset is deasserted
        while (miicontrol & BMCR_RESET) {
                udelay(NV_MIIBUSY_DELAY);
                miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
                /* FIXME: 1000 tries seem excessive */
                if (tries++ > 1000)
                        return -1;
        }
        return 0;
}


Better?

Regards,
Carl-Daniel
-- 
http://www.hailfinger.org/


  reply	other threads:[~2004-06-19 14:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-19 13:21 [PATCH] new device support for forcedeth.c second try Carl-Daniel Hailfinger
2004-06-19 13:55 ` Francois Romieu
2004-06-19 14:15   ` Bartlomiej Zolnierkiewicz
2004-06-19 14:35     ` Carl-Daniel Hailfinger [this message]
2004-06-19 14:56       ` Bartlomiej Zolnierkiewicz
2004-06-19 15:08       ` Francois Romieu
2004-06-19 16:18 ` Manfred Spraul
2004-06-19 16:50   ` Carl-Daniel Hailfinger
2004-06-19 16:56     ` Christoph Hellwig
2004-06-21  3:06       ` [PATCH] new device support for forcedeth.c third try Carl-Daniel Hailfinger
  -- strict thread matches above, loose matches on Subject: below --
2004-06-21 17:10 [PATCH] new device support for forcedeth.c second try Brian Lazara
2004-06-21 17:36 ` Carl-Daniel Hailfinger
2004-06-21 19:00   ` Kalin KOZHUHAROV
2004-06-21 19:48     ` Carl-Daniel Hailfinger
2004-06-21 21:38       ` Kalin KOZHUHAROV

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40D44F1D.6090701@gmx.net \
    --to=c-d.hailfinger.kernel.2004@gmx.net \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=adq@lidskialf.net \
    --cc=blazara@nvidia.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=romieu@fr.zoreil.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.