All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Andy Fleming <afleming@freescale.com>
Cc: Netdev <netdev@oss.sgi.com>,
	Embedded PPC Linux list <linuxppc-embedded@ozlabs.org>
Subject: Re: RFC: PHY Abstraction Layer II
Date: Wed, 01 Jun 2005 14:19:15 -0700	[thread overview]
Message-ID: <429E2653.6010101@osdl.org> (raw)
In-Reply-To: <92F1428A-0B26-428B-8C06-35C7E5B9EEE3@freescale.com>

Andy Fleming wrote:

>
> On May 31, 2005, at 12:59, Stephen Hemminger wrote:
>
>> Here are some patches:
>>     * allow phy's to be modules
>>     * use driver owner for ref count
>>     * make local functions static where ever possible
>
>
> I agree with all these.
>
>>     * get rid of bus read may sleep implication in comment.
>>       since you are holding phy spin lock it better not!!
>
>
> But not this one.  The phy_read and phy_write functions are reading  
> from and writing to a bus.  It is a reasonable implementation to have  
> the operation block in the bus driver, and be awoken when an  
> interrupt signals the operation is done.  All of the phydev spinlocks  
> have been arranged so as to prevent the lock being taken during  
> interrupt time.
>
> Unless I've misunderstood spinlocks (it wouldn't be the first time),  
> as long as the lock is never taken in interrupt time, it should be ok  
> to hold the lock, and wait for an interrupt before clearing the lock.


The problem is that sleeping is defined in the linux kernel as meaning 
waiting on a mutual exclusion
primitive (like semaphore) that puts the current thread to sleep. It is 
not legal to sleep with a spinlock held.
In the phy_read code you do:
   
   spin_lock_bh(&bus->mdio_lock);
    retval = bus->read(bus, phydev->addr, regnum);
    spin_unlock_bh(&bus->mdio_lock);

If the bus->read function were to do something like start a request and 
wait on a semaphore, then
you would be sleeping with a spin lock held.  So bus->read can not 
sleep! (as sleep is defined in the
linux kernel).

   

  reply	other threads:[~2005-06-01 21:19 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-09  1:47 RFC: PHY Abstraction Layer II Andy Fleming
2005-03-09  1:47 ` Andy Fleming
2005-03-09  2:14 ` Benjamin Herrenschmidt
2005-03-09  3:42   ` David S. Miller
2005-03-09  3:42     ` David S. Miller
2005-03-09  3:50     ` Benjamin Herrenschmidt
2005-03-09  3:50       ` Benjamin Herrenschmidt
2005-03-09 17:24       ` Andy Fleming
2005-03-10 23:01         ` James Chapman
2005-03-10 23:01           ` James Chapman
2005-03-10 23:06           ` Benjamin Herrenschmidt
2005-03-10 23:06             ` Benjamin Herrenschmidt
2005-03-10 23:27             ` Jeff Garzik
2005-03-10 23:27               ` Jeff Garzik
2005-03-10 23:27               ` Benjamin Herrenschmidt
2005-03-10 23:27                 ` Benjamin Herrenschmidt
2005-03-15  0:41           ` Andy Fleming
2005-03-15  0:41             ` Andy Fleming
2005-03-15 19:18             ` James Chapman
2005-03-15 19:18               ` James Chapman
2005-03-18 23:14               ` Andy Fleming
2005-03-18 23:14                 ` Andy Fleming
2005-03-24 21:48               ` Andy Fleming
2005-03-24 21:48                 ` Andy Fleming
2005-03-25 22:56                 ` Andy Fleming
2005-03-25 22:56                   ` Andy Fleming
2005-03-28 23:45                   ` Kumar Gala
2005-03-28 23:45                     ` Kumar Gala
2005-03-29  4:11                     ` Problem when accessing variables Hiep Tran
2005-04-17 13:00                 ` RFC: PHY Abstraction Layer II James Chapman
2005-05-10 17:04                   ` Andy Fleming
2005-05-10 17:04                     ` Andy Fleming
2005-05-12  6:08                     ` Pantelis Antoniou
2005-05-25 23:00                     ` Kumar Gala
2005-05-25 23:00                       ` Kumar Gala
2005-03-09 17:17   ` Andy Fleming
2005-05-26 18:32 ` Stephen Hemminger
2005-05-26 18:45   ` Andy Fleming
2005-05-31 17:59 ` Stephen Hemminger
2005-06-01 20:45   ` Andy Fleming
2005-06-01 21:19     ` Stephen Hemminger [this message]
2005-06-01 22:42       ` Andy Fleming
2005-06-01 21:41     ` Stephen Hemminger
2005-06-01 22:36       ` Andy Fleming
2005-06-05 20:29         ` Glen Turner
2005-06-09 21:32           ` Andy Fleming
2005-06-28  6:38             ` Glen Turner

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=429E2653.6010101@osdl.org \
    --to=shemminger@osdl.org \
    --cc=afleming@freescale.com \
    --cc=linuxppc-embedded@ozlabs.org \
    --cc=netdev@oss.sgi.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.