public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* jsm: two or more 4/8-port boards can not initialize ports properly
@ 2009-05-12 21:22 Alexander Y. Fomichev
  2009-05-12 21:49 ` Alexander Beregalov
  2009-05-13  0:24 ` Alan Cox
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Y. Fomichev @ 2009-05-12 21:22 UTC (permalink / raw)
  To: linux-kernel

G' day

The patch bellow fix for me problem with jsm_uart_port_init
which still thinking it works for 2-ports borads only.
drivers/serial/jsm/jsm_tty.c +462
brd->channels[i]->uart_port.line = brd->channels[i]->ch_portnum +
brd->boardnum * 2;

                         ^^^^^^^^^^^^^^^^^^^^^^
so for line numbers of the second and further boards
may/will be assigned values with the same range.
in my case of two digi neo-8 -- 6 ports of 8 failed to be
added for the second board.

[    1.331294] serial 0000:04:09.0: PCI INT A -> GSI 51 (level, low) -> IRQ 51
[    1.338337] serial 0000:04:09.0: PCI INT A disabled
[    1.343313] serial 0000:03:09.0: PCI INT A -> GSI 27 (level, low) -> IRQ 27
[    1.350345] serial 0000:03:09.0: PCI INT A disabled
[    1.355482] jsm 0000:04:09.0: PCI INT A -> GSI 51 (level, low) -> IRQ 51
[    1.362279] IRQ 51/JSM: IRQF_DISABLED is not guaranteed on shared IRQs
[    1.368905] ttyn0 at MMIO 0x0 (irq = 51) is a jsm
[    1.374079] Added device
[    1.376771] ttyn1 at MMIO 0x0 (irq = 51) is a jsm
[    1.381796] Added device
[    1.384485] ttyn2 at MMIO 0x0 (irq = 51) is a jsm
[    1.389502] Added device
[    1.392191] ttyn3 at MMIO 0x0 (irq = 51) is a jsm
[    1.397200] Added device
[    1.399886] ttyn4 at MMIO 0x0 (irq = 51) is a jsm
[    1.404886] Added device
[    1.407573] ttyn5 at MMIO 0x0 (irq = 51) is a jsm
[    1.412578] Added device
[    1.415260] ttyn6 at MMIO 0x0 (irq = 51) is a jsm
[    1.420267] Added device
[    1.422947] ttyn7 at MMIO 0x0 (irq = 51) is a jsm
[    1.427955] Added device
[    1.430642] jsm 0000:04:09.0: board 1: Digi Neo (rev 9), irq 51
[    1.436660] jsm 0000:03:09.0: PCI INT A -> GSI 27 (level, low) -> IRQ 27
[    1.443446] IRQ 27/JSM: IRQF_DISABLED is not guaranteed on shared IRQs
[    1.450077] Added device failed
[    1.453286] Added device failed
[    1.456492] Added device failed
[    1.459691] Added device failed
[    1.462899] Added device failed
[    1.466105] Added device failed
[    1.469314] ttyn8 at MMIO 0x0 (irq = 27) is a jsm
[    1.474377] Added device
[    1.477074] ttyn9 at MMIO 0x0 (irq = 27) is a jsm
[    1.482101] Added device
[    1.484793] jsm 0000:03:09.0: board 2: Digi Neo (rev 2), irq 27

---------------------------------------------------------------------------------------------------
diff -urNp a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
--- a/drivers/serial/jsm/jsm.h  2009-05-12 17:29:02.117674090 +0400
+++ b/drivers/serial/jsm/jsm.h  2009-05-12 17:51:35.197811282 +0400
@@ -61,6 +61,7 @@ enum {
        if ((DBG_##nlevel & jsm_debug))                 \
        dev_printk(KERN_##klevel, pdev->dev, fmt, ## args)

+#define MAXBOARDS      32
 #define MAXPORTS       8
 #define MAX_STOPS_SENT 5

@@ -94,6 +95,7 @@ enum {

 struct jsm_board;
 struct jsm_channel;
+extern struct jsm_board *jsm_boards[];

 /************************************************************************
  * Per board operations structure                                      *
diff -urNp a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
--- a/drivers/serial/jsm/jsm_driver.c   2009-05-12 17:29:02.117674090 +0400
+++ b/drivers/serial/jsm/jsm_driver.c   2009-05-12 17:55:42.597168409 +0400
@@ -52,6 +52,8 @@ int jsm_debug;
 module_param(jsm_debug, int, 0);
 MODULE_PARM_DESC(jsm_debug, "Driver debugging level");

+struct jsm_board *jsm_boards[MAXBOARDS];
+
 static int __devinit jsm_probe_one(struct pci_dev *pdev, const struct
pci_device_id *ent)
 {
        int rc = 0;
@@ -80,6 +82,7 @@ static int __devinit jsm_probe_one(struc

        /* store the info for the board we've found */
        brd->boardnum = adapter_count++;
+       jsm_boards[brd->boardnum] = brd;
        brd->pci_dev = pdev;
        if (pdev->device == PCIE_DEVICE_ID_NEO_4_IBM)
                brd->maxports = 4;
@@ -171,6 +174,7 @@ static int __devinit jsm_probe_one(struc
  out_iounmap:
        iounmap(brd->re_map_membase);
  out_kfree_brd:
+       jsm_boards[brd->boardnum] = NULL;
        kfree(brd);
  out_release_regions:
        pci_release_regions(pdev);
@@ -203,6 +207,7 @@ static void __devexit jsm_remove_one(str
        pci_release_regions(pdev);
        pci_disable_device(pdev);
        kfree(brd->flipbuf);
+       jsm_boards[brd->boardnum] = NULL;
        kfree(brd);
 }

diff -urNp a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
--- a/drivers/serial/jsm/jsm_tty.c      2009-05-12 17:28:51.849172254 +0400
+++ b/drivers/serial/jsm/jsm_tty.c      2009-05-12 17:59:49.287494614 +0400
@@ -432,8 +432,9 @@ int __devinit jsm_tty_init(struct jsm_bo

 int __devinit jsm_uart_port_init(struct jsm_board *brd)
 {
-       int i;
+       int i, j;
        struct jsm_channel *ch;
+       u32 jsm_ports = 0;

        if (!brd)
                return -ENXIO;
@@ -446,6 +447,10 @@ int __devinit jsm_uart_port_init(struct

        brd->nasync = brd->maxports;

+       for (j = 0; j < brd->boardnum; j++)
+               if (jsm_boards[j])
+                       jsm_ports += jsm_boards[j]->maxports;
+
        /* Set up channel variables */
        for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) {

@@ -459,7 +464,7 @@ int __devinit jsm_uart_port_init(struct
                brd->channels[i]->uart_port.membase = brd->re_map_membase;
                brd->channels[i]->uart_port.fifosize = 16;
                brd->channels[i]->uart_port.ops = &jsm_ops;
-               brd->channels[i]->uart_port.line =
brd->channels[i]->ch_portnum + brd->boardnum * 2;
+               brd->channels[i]->uart_port.line =
brd->channels[i]->ch_portnum + jsm_ports;
                if (uart_add_one_port (&jsm_uart_driver,
&brd->channels[i]->uart_port))
                        printk(KERN_INFO "Added device failed\n");

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: jsm: two or more 4/8-port boards can not initialize ports  properly
  2009-05-12 21:22 jsm: two or more 4/8-port boards can not initialize ports properly Alexander Y. Fomichev
@ 2009-05-12 21:49 ` Alexander Beregalov
  2009-05-13 21:54   ` Alexander Y. Fomichev
  2009-05-13  0:24 ` Alan Cox
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Beregalov @ 2009-05-12 21:49 UTC (permalink / raw)
  To: Alexander Y. Fomichev; +Cc: linux-kernel

2009/5/13 Alexander Y. Fomichev <git.user@gmail.com>:
> G' day
>
> The patch bellow fix for me problem with jsm_uart_port_init
> which still thinking it works for 2-ports borads only.
> drivers/serial/jsm/jsm_tty.c +462
> brd->channels[i]->uart_port.line = brd->channels[i]->ch_portnum +
> brd->boardnum * 2;
>
>                         ^^^^^^^^^^^^^^^^^^^^^^
> so for line numbers of the second and further boards
> may/will be assigned values with the same range.
> in my case of two digi neo-8 -- 6 ports of 8 failed to be
> added for the second board.

Hi Alexander,

Your patch is broken, your mail client wraps long lines.
Please read Documentation/email-clients.txt.
Please add linux-serial@vger.kernel.org,
alan@lxorguk.ukuu.org.uk and Scott.Kilau@digi.com to CC list.
Please add Signed-off-by line as described in Documentation/SubmittingPatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: jsm: two or more 4/8-port boards can not initialize ports properly
  2009-05-12 21:22 jsm: two or more 4/8-port boards can not initialize ports properly Alexander Y. Fomichev
  2009-05-12 21:49 ` Alexander Beregalov
@ 2009-05-13  0:24 ` Alan Cox
  2009-05-13 21:58   ` Alexander Y. Fomichev
  1 sibling, 1 reply; 5+ messages in thread
From: Alan Cox @ 2009-05-13  0:24 UTC (permalink / raw)
  To: Alexander Y. Fomichev; +Cc: linux-kernel

> +struct jsm_board *jsm_boards[MAXBOARDS];
> +

adapter_count increments each time regardless of boards present so that
doesn't work after a few hotplugs it seems ?

>         brd->boardnum = adapter_count++;
> +       jsm_boards[brd->boardnum] = brd;
>         brd->pci_dev = pdev;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: jsm: two or more 4/8-port boards can not initialize ports  properly
  2009-05-12 21:49 ` Alexander Beregalov
@ 2009-05-13 21:54   ` Alexander Y. Fomichev
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Y. Fomichev @ 2009-05-13 21:54 UTC (permalink / raw)
  To: Alexander Beregalov; +Cc: linux-kernel

On Wed, May 13, 2009 at 1:49 AM, Alexander Beregalov
<a.beregalov@gmail.com> wrote:
> 2009/5/13 Alexander Y. Fomichev <git.user@gmail.com>:
>> G' day
>>
>> The patch bellow fix for me problem with jsm_uart_port_init
>> which still thinking it works for 2-ports borads only.
>> drivers/serial/jsm/jsm_tty.c +462
>> brd->channels[i]->uart_port.line = brd->channels[i]->ch_portnum +
>> brd->boardnum * 2;
>>
>>                         ^^^^^^^^^^^^^^^^^^^^^^
>> so for line numbers of the second and further boards
>> may/will be assigned values with the same range.
>> in my case of two digi neo-8 -- 6 ports of 8 failed to be
>> added for the second board.
>
> Hi Alexander,
>
> Your patch is broken, your mail client wraps long lines.
> Please read Documentation/email-clients.txt.
> Please add linux-serial@vger.kernel.org,
> alan@lxorguk.ukuu.org.uk and Scott.Kilau@digi.com to CC list.
> Please add Signed-off-by line as described in Documentation/SubmittingPatches

tnx for advise



-- 
Best regards.
       Alexander Y. Fomichev <git.user@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: jsm: two or more 4/8-port boards can not initialize ports properly
  2009-05-13  0:24 ` Alan Cox
@ 2009-05-13 21:58   ` Alexander Y. Fomichev
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Y. Fomichev @ 2009-05-13 21:58 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

On Wed, 13 May 2009 01:24:31 +0100
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:

> > +struct jsm_board *jsm_boards[MAXBOARDS];
> > +
> 
> adapter_count increments each time regardless of boards present so that
> doesn't work after a few hotplugs it seems ?

it's true, i missing hotplug at all tnx.
as of hotplug it seems easier to do this allocating/deallocating
line numbers one by one storing assigned numbers in bitmap (though
it could lead to sparse ttyns belonging to a sigle board)
could you pls take a look on the patch bellow?


> >         brd->boardnum = adapter_count++;
> > +       jsm_boards[brd->boardnum] = brd;
> >         brd->pci_dev = pdev;

diff -urNp a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
--- a/drivers/serial/jsm/jsm.h  2009-05-12 17:29:02.117674090 +0400
+++ b/drivers/serial/jsm/jsm.h  2009-05-13 15:52:56.152889038 +0400
@@ -61,6 +61,7 @@ enum {
        if ((DBG_##nlevel & jsm_debug))                 \
        dev_printk(KERN_##klevel, pdev->dev, fmt, ## args)

+#define        MAXLINES        256
 #define MAXPORTS       8
 #define MAX_STOPS_SENT 5

diff -urNp a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
--- a/drivers/serial/jsm/jsm_tty.c      2009-05-12 17:28:51.849172254 +0400
+++ b/drivers/serial/jsm/jsm_tty.c      2009-05-14 01:15:02.542589990 +0400
@@ -33,6 +33,8 @@

 #include "jsm.h"

+static DECLARE_BITMAP(linemap,MAXLINES);
+
 static void jsm_carrier(struct jsm_channel *ch);

 static inline int jsm_get_mstat(struct jsm_channel *ch)
@@ -433,6 +435,7 @@ int __devinit jsm_tty_init(struct jsm_bo
 int __devinit jsm_uart_port_init(struct jsm_board *brd)
 {
        int i;
+       unsigned int line;
        struct jsm_channel *ch;

        if (!brd)
@@ -459,7 +462,13 @@ int __devinit jsm_uart_port_init(struct
                brd->channels[i]->uart_port.membase = brd->re_map_membase;
                brd->channels[i]->uart_port.fifosize = 16;
                brd->channels[i]->uart_port.ops = &jsm_ops;
-               brd->channels[i]->uart_port.line = brd->channels[i]->ch_portnum + brd->boardnum * 2;
+               line = find_first_zero_bit(linemap,MAXLINES);
+               if (line >= MAXLINES) {
+                       printk(KERN_INFO "linemap is full, added device failed\n");
+                       continue;
+               } else
+                       __set_bit((int)line, linemap);
+               brd->channels[i]->uart_port.line = line;
                if (uart_add_one_port (&jsm_uart_driver, &brd->channels[i]->uart_port))
                        printk(KERN_INFO "Added device failed\n");
                else
@@ -494,6 +503,7 @@ int jsm_remove_uart_port(struct jsm_boar

                ch = brd->channels[i];

+               __clear_bit((int)(ch->uart_port.line), linemap);
                uart_remove_one_port(&jsm_uart_driver, &brd->channels[i]->uart_port);
        }

-- 
Best regards
	Alexander Y. Fomichev <git.user@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-05-13 21:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-12 21:22 jsm: two or more 4/8-port boards can not initialize ports properly Alexander Y. Fomichev
2009-05-12 21:49 ` Alexander Beregalov
2009-05-13 21:54   ` Alexander Y. Fomichev
2009-05-13  0:24 ` Alan Cox
2009-05-13 21:58   ` Alexander Y. Fomichev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox