* [PATCH] net: ks8851: convert to threaded IRQ
@ 2013-01-23 13:51 Felipe Balbi
2013-01-29 3:31 ` David Miller
0 siblings, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2013-01-23 13:51 UTC (permalink / raw)
To: davem; +Cc: sboyd, mjr, netdev, Felipe Balbi
just as it should have been. It also helps
removing the, now unnecessary, workqueue.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/net/ethernet/micrel/ks8851.c | 41 ++++++++++--------------------------
1 file changed, 11 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index 286816a..48ecb36 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -69,7 +69,6 @@ union ks8851_tx_hdr {
* @mii: The MII state information for the mii calls.
* @rxctrl: RX settings for @rxctrl_work.
* @tx_work: Work queue for tx packets
- * @irq_work: Work queue for servicing interrupts
* @rxctrl_work: Work queue for updating RX mode and multicast lists
* @txq: Queue of packets for transmission.
* @spi_msg1: pre-setup SPI transfer with one message, @spi_xfer1.
@@ -121,7 +120,6 @@ struct ks8851_net {
struct ks8851_rxctrl rxctrl;
struct work_struct tx_work;
- struct work_struct irq_work;
struct work_struct rxctrl_work;
struct sk_buff_head txq;
@@ -444,23 +442,6 @@ static void ks8851_init_mac(struct ks8851_net *ks)
}
/**
- * ks8851_irq - device interrupt handler
- * @irq: Interrupt number passed from the IRQ handler.
- * @pw: The private word passed to register_irq(), our struct ks8851_net.
- *
- * Disable the interrupt from happening again until we've processed the
- * current status by scheduling ks8851_irq_work().
- */
-static irqreturn_t ks8851_irq(int irq, void *pw)
-{
- struct ks8851_net *ks = pw;
-
- disable_irq_nosync(irq);
- schedule_work(&ks->irq_work);
- return IRQ_HANDLED;
-}
-
-/**
* ks8851_rdfifo - read data from the receive fifo
* @ks: The device state.
* @buff: The buffer address
@@ -595,19 +576,20 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
}
/**
- * ks8851_irq_work - work queue handler for dealing with interrupt requests
- * @work: The work structure that was scheduled by schedule_work()
+ * ks8851_irq - IRQ handler for dealing with interrupt requests
+ * @irq: IRQ number
+ * @_ks: cookie
*
- * This is the handler invoked when the ks8851_irq() is called to find out
- * what happened, as we cannot allow ourselves to sleep whilst waiting for
- * anything other process has the chip's lock.
+ * This handler is invoked when the IRQ line asserts to find out what happened.
+ * As we cannot allow ourselves to sleep in HARDIRQ context, this handler runs
+ * in thread context.
*
* Read the interrupt status, work out what needs to be done and then clear
* any of the interrupts that are not needed.
*/
-static void ks8851_irq_work(struct work_struct *work)
+static irqreturn_t ks8851_irq(int irq, void *_ks)
{
- struct ks8851_net *ks = container_of(work, struct ks8851_net, irq_work);
+ struct ks8851_net *ks = _ks;
unsigned status;
unsigned handled = 0;
@@ -688,7 +670,7 @@ static void ks8851_irq_work(struct work_struct *work)
if (status & IRQ_TXI)
netif_wake_queue(ks->netdev);
- enable_irq(ks->netdev->irq);
+ return IRQ_HANDLED;
}
/**
@@ -896,7 +878,6 @@ static int ks8851_net_stop(struct net_device *dev)
mutex_unlock(&ks->lock);
/* stop any outstanding work */
- flush_work(&ks->irq_work);
flush_work(&ks->tx_work);
flush_work(&ks->rxctrl_work);
@@ -1438,7 +1419,6 @@ static int ks8851_probe(struct spi_device *spi)
spin_lock_init(&ks->statelock);
INIT_WORK(&ks->tx_work, ks8851_tx_work);
- INIT_WORK(&ks->irq_work, ks8851_irq_work);
INIT_WORK(&ks->rxctrl_work, ks8851_rxctrl_work);
/* initialise pre-made spi transfer messages */
@@ -1505,7 +1485,8 @@ static int ks8851_probe(struct spi_device *spi)
ks8851_read_selftest(ks);
ks8851_init_mac(ks);
- ret = request_irq(spi->irq, ks8851_irq, IRQF_TRIGGER_LOW,
+ ret = request_threaded_irq(spi->irq, NULL, ks8851_irq,
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
ndev->name, ks);
if (ret < 0) {
dev_err(&spi->dev, "failed to get irq\n");
--
1.8.1.rc1.5.g7e0651a
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] net: ks8851: convert to threaded IRQ
2013-01-23 13:51 [PATCH] net: ks8851: convert to threaded IRQ Felipe Balbi
@ 2013-01-29 3:31 ` David Miller
2013-01-29 4:33 ` Joe Perches
2013-01-29 7:16 ` Felipe Balbi
0 siblings, 2 replies; 8+ messages in thread
From: David Miller @ 2013-01-29 3:31 UTC (permalink / raw)
To: balbi; +Cc: sboyd, mjr, netdev
From: Felipe Balbi <balbi@ti.com>
Date: Wed, 23 Jan 2013 15:51:38 +0200
> @@ -1505,7 +1485,8 @@ static int ks8851_probe(struct spi_device *spi)
> ks8851_read_selftest(ks);
> ks8851_init_mac(ks);
>
> - ret = request_irq(spi->irq, ks8851_irq, IRQF_TRIGGER_LOW,
> + ret = request_threaded_irq(spi->irq, NULL, ks8851_irq,
> + IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> ndev->name, ks);
You need to indent the second and third line of this function call
properly. It should be:
ret = function_call(arg1, arg2,
arg3, arg4,
arg5, arg6, etc.);
not what you have there now which has every line indented differently.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] net: ks8851: convert to threaded IRQ
2013-01-29 3:31 ` David Miller
@ 2013-01-29 4:33 ` Joe Perches
2013-01-29 7:16 ` Felipe Balbi
1 sibling, 0 replies; 8+ messages in thread
From: Joe Perches @ 2013-01-29 4:33 UTC (permalink / raw)
To: David Miller; +Cc: balbi, sboyd, mjr, netdev
On Mon, 2013-01-28 at 22:31 -0500, David Miller wrote:
> From: Felipe Balbi <balbi@ti.com>
> Date: Wed, 23 Jan 2013 15:51:38 +0200
[]
> > @@ -1505,7 +1485,8 @@ static int ks8851_probe(struct spi_device *spi)
[]
> > - ret = request_irq(spi->irq, ks8851_irq, IRQF_TRIGGER_LOW,
> > + ret = request_threaded_irq(spi->irq, NULL, ks8851_irq,
> > + IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> > ndev->name, ks);
>
> You need to indent the second and third line of this function call
> properly. It should be:
>
> ret = function_call(arg1, arg2,
> arg3, arg4,
> arg5, arg6, etc.);
Instead of writing all these emails all the time,
maybe it'd be better to make the checkpatch messages
that are currently emitted only with the --strict
option (like parenthesis alignment) emitted whenever
working on files in drivers/net/ and net/.
---
scripts/checkpatch.pl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9cec6dd..da1d15a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -35,6 +35,8 @@ my $help = 0;
my $configuration_file = ".checkpatch.conf";
my $max_line_length = 80;
+my $realfile = '';
+
sub help {
my ($exitcode) = @_;
@@ -1287,7 +1289,9 @@ sub WARN {
}
}
sub CHK {
- if ($check && report("CHECK", $_[0], $_[1])) {
+ if ($realfile =~ m@^(drivers/net|net/)@) {
+ WARN($_[0], $_[1]);
+ } elsif ($check && report("CHECK", $_[0], $_[1])) {
our $clean = 0;
our $cnt_chk++;
}
@@ -1381,7 +1385,7 @@ sub process {
our $cnt_chk = 0;
# Trace the real file/line as we go.
- my $realfile = '';
+ $realfile = '';
my $realline = 0;
my $realcnt = 0;
my $here = '';
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] net: ks8851: convert to threaded IRQ
2013-01-29 3:31 ` David Miller
2013-01-29 4:33 ` Joe Perches
@ 2013-01-29 7:16 ` Felipe Balbi
2013-01-29 18:32 ` David Miller
2013-01-29 18:53 ` Stephen Boyd
1 sibling, 2 replies; 8+ messages in thread
From: Felipe Balbi @ 2013-01-29 7:16 UTC (permalink / raw)
To: davem; +Cc: sboyd, mjr, netdev, Felipe Balbi
just as it should have been. It also helps
removing the, now unnecessary, workqueue.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/net/ethernet/micrel/ks8851.c | 43 ++++++++++--------------------------
1 file changed, 12 insertions(+), 31 deletions(-)
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index 286816a..e29ad2e 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -69,7 +69,6 @@ union ks8851_tx_hdr {
* @mii: The MII state information for the mii calls.
* @rxctrl: RX settings for @rxctrl_work.
* @tx_work: Work queue for tx packets
- * @irq_work: Work queue for servicing interrupts
* @rxctrl_work: Work queue for updating RX mode and multicast lists
* @txq: Queue of packets for transmission.
* @spi_msg1: pre-setup SPI transfer with one message, @spi_xfer1.
@@ -121,7 +120,6 @@ struct ks8851_net {
struct ks8851_rxctrl rxctrl;
struct work_struct tx_work;
- struct work_struct irq_work;
struct work_struct rxctrl_work;
struct sk_buff_head txq;
@@ -444,23 +442,6 @@ static void ks8851_init_mac(struct ks8851_net *ks)
}
/**
- * ks8851_irq - device interrupt handler
- * @irq: Interrupt number passed from the IRQ handler.
- * @pw: The private word passed to register_irq(), our struct ks8851_net.
- *
- * Disable the interrupt from happening again until we've processed the
- * current status by scheduling ks8851_irq_work().
- */
-static irqreturn_t ks8851_irq(int irq, void *pw)
-{
- struct ks8851_net *ks = pw;
-
- disable_irq_nosync(irq);
- schedule_work(&ks->irq_work);
- return IRQ_HANDLED;
-}
-
-/**
* ks8851_rdfifo - read data from the receive fifo
* @ks: The device state.
* @buff: The buffer address
@@ -595,19 +576,20 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
}
/**
- * ks8851_irq_work - work queue handler for dealing with interrupt requests
- * @work: The work structure that was scheduled by schedule_work()
+ * ks8851_irq - IRQ handler for dealing with interrupt requests
+ * @irq: IRQ number
+ * @_ks: cookie
*
- * This is the handler invoked when the ks8851_irq() is called to find out
- * what happened, as we cannot allow ourselves to sleep whilst waiting for
- * anything other process has the chip's lock.
+ * This handler is invoked when the IRQ line asserts to find out what happened.
+ * As we cannot allow ourselves to sleep in HARDIRQ context, this handler runs
+ * in thread context.
*
* Read the interrupt status, work out what needs to be done and then clear
* any of the interrupts that are not needed.
*/
-static void ks8851_irq_work(struct work_struct *work)
+static irqreturn_t ks8851_irq(int irq, void *_ks)
{
- struct ks8851_net *ks = container_of(work, struct ks8851_net, irq_work);
+ struct ks8851_net *ks = _ks;
unsigned status;
unsigned handled = 0;
@@ -688,7 +670,7 @@ static void ks8851_irq_work(struct work_struct *work)
if (status & IRQ_TXI)
netif_wake_queue(ks->netdev);
- enable_irq(ks->netdev->irq);
+ return IRQ_HANDLED;
}
/**
@@ -896,7 +878,6 @@ static int ks8851_net_stop(struct net_device *dev)
mutex_unlock(&ks->lock);
/* stop any outstanding work */
- flush_work(&ks->irq_work);
flush_work(&ks->tx_work);
flush_work(&ks->rxctrl_work);
@@ -1438,7 +1419,6 @@ static int ks8851_probe(struct spi_device *spi)
spin_lock_init(&ks->statelock);
INIT_WORK(&ks->tx_work, ks8851_tx_work);
- INIT_WORK(&ks->irq_work, ks8851_irq_work);
INIT_WORK(&ks->rxctrl_work, ks8851_rxctrl_work);
/* initialise pre-made spi transfer messages */
@@ -1505,8 +1485,9 @@ static int ks8851_probe(struct spi_device *spi)
ks8851_read_selftest(ks);
ks8851_init_mac(ks);
- ret = request_irq(spi->irq, ks8851_irq, IRQF_TRIGGER_LOW,
- ndev->name, ks);
+ ret = request_threaded_irq(spi->irq, NULL, ks8851_irq,
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+ ndev->name, ks);
if (ret < 0) {
dev_err(&spi->dev, "failed to get irq\n");
goto err_irq;
--
1.8.1.rc1.5.g7e0651a
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] net: ks8851: convert to threaded IRQ
2013-01-29 7:16 ` Felipe Balbi
@ 2013-01-29 18:32 ` David Miller
2013-01-29 18:53 ` Stephen Boyd
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2013-01-29 18:32 UTC (permalink / raw)
To: balbi; +Cc: sboyd, mjr, netdev
From: Felipe Balbi <balbi@ti.com>
Date: Tue, 29 Jan 2013 09:16:30 +0200
> just as it should have been. It also helps
> removing the, now unnecessary, workqueue.
>
> Signed-off-by: Felipe Balbi <balbi@ti.com>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] net: ks8851: convert to threaded IRQ
2013-01-29 7:16 ` Felipe Balbi
2013-01-29 18:32 ` David Miller
@ 2013-01-29 18:53 ` Stephen Boyd
2013-01-29 19:02 ` Felipe Balbi
1 sibling, 1 reply; 8+ messages in thread
From: Stephen Boyd @ 2013-01-29 18:53 UTC (permalink / raw)
To: Felipe Balbi; +Cc: davem, mjr, netdev
On 01/28/13 23:16, Felipe Balbi wrote:
> just as it should have been. It also helps
> removing the, now unnecessary, workqueue.
Tested-by: Stephen Boyd <sboyd@codeaurora.org>
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> ---
> @@ -1505,8 +1485,9 @@ static int ks8851_probe(struct spi_device *spi)
> ks8851_read_selftest(ks);
> ks8851_init_mac(ks);
>
> - ret = request_irq(spi->irq, ks8851_irq, IRQF_TRIGGER_LOW,
> - ndev->name, ks);
> + ret = request_threaded_irq(spi->irq, NULL, ks8851_irq,
> + IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> + ndev->name, ks);
I did notice one thing here. The name of the thread is irq/378-eth%d
(where 378 is the irq number). It seems that ndev->name is not fully
formed until register_netdev() is called and so when the thread is
created, the malformed name is used for the thread name.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] net: ks8851: convert to threaded IRQ
2013-01-29 18:53 ` Stephen Boyd
@ 2013-01-29 19:02 ` Felipe Balbi
2013-01-29 19:21 ` Stephen Boyd
0 siblings, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2013-01-29 19:02 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Felipe Balbi, davem, mjr, netdev
[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]
On Tue, Jan 29, 2013 at 10:53:08AM -0800, Stephen Boyd wrote:
> On 01/28/13 23:16, Felipe Balbi wrote:
> > just as it should have been. It also helps
> > removing the, now unnecessary, workqueue.
>
> Tested-by: Stephen Boyd <sboyd@codeaurora.org>
>
> > Signed-off-by: Felipe Balbi <balbi@ti.com>
> > ---
> > @@ -1505,8 +1485,9 @@ static int ks8851_probe(struct spi_device *spi)
> > ks8851_read_selftest(ks);
> > ks8851_init_mac(ks);
> >
> > - ret = request_irq(spi->irq, ks8851_irq, IRQF_TRIGGER_LOW,
> > - ndev->name, ks);
> > + ret = request_threaded_irq(spi->irq, NULL, ks8851_irq,
> > + IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> > + ndev->name, ks);
>
> I did notice one thing here. The name of the thread is irq/378-eth%d
> (where 378 is the irq number). It seems that ndev->name is not fully
> formed until register_netdev() is called and so when the thread is
> created, the malformed name is used for the thread name.
that would be a problem even before the conversion to threaded irq, the
only difference is that 378- would be omitted.
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] net: ks8851: convert to threaded IRQ
2013-01-29 19:02 ` Felipe Balbi
@ 2013-01-29 19:21 ` Stephen Boyd
0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2013-01-29 19:21 UTC (permalink / raw)
To: balbi; +Cc: davem, mjr, netdev
On 01/29/13 11:02, Felipe Balbi wrote:
> On Tue, Jan 29, 2013 at 10:53:08AM -0800, Stephen Boyd wrote:
>> On 01/28/13 23:16, Felipe Balbi wrote:
>>> just as it should have been. It also helps
>>> removing the, now unnecessary, workqueue.
>> Tested-by: Stephen Boyd <sboyd@codeaurora.org>
>>
>>> Signed-off-by: Felipe Balbi <balbi@ti.com>
>>> ---
>>> @@ -1505,8 +1485,9 @@ static int ks8851_probe(struct spi_device *spi)
>>> ks8851_read_selftest(ks);
>>> ks8851_init_mac(ks);
>>>
>>> - ret = request_irq(spi->irq, ks8851_irq, IRQF_TRIGGER_LOW,
>>> - ndev->name, ks);
>>> + ret = request_threaded_irq(spi->irq, NULL, ks8851_irq,
>>> + IRQF_TRIGGER_LOW | IRQF_ONESHOT,
>>> + ndev->name, ks);
>> I did notice one thing here. The name of the thread is irq/378-eth%d
>> (where 378 is the irq number). It seems that ndev->name is not fully
>> formed until register_netdev() is called and so when the thread is
>> created, the malformed name is used for the thread name.
> that would be a problem even before the conversion to threaded irq, the
> only difference is that 378- would be omitted.
>
It doesn't seem to be a problem in the non-threaded case presumably
because the name is pointed to directly, instead of being copied, for
the /proc/interrupts case. In other words, /proc/interrupts shows eth0
instead of eth%d with and without this patch applied.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-01-29 19:21 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-23 13:51 [PATCH] net: ks8851: convert to threaded IRQ Felipe Balbi
2013-01-29 3:31 ` David Miller
2013-01-29 4:33 ` Joe Perches
2013-01-29 7:16 ` Felipe Balbi
2013-01-29 18:32 ` David Miller
2013-01-29 18:53 ` Stephen Boyd
2013-01-29 19:02 ` Felipe Balbi
2013-01-29 19:21 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).