All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ns16550: adjust suspend/resume logic
@ 2012-05-07 15:29 Jan Beulich
  2012-05-07 15:47 ` Keir Fraser
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2012-05-07 15:29 UTC (permalink / raw)
  To: xen-devel; +Cc: Konrad Rzeszutek Wilk

[-- Attachment #1: Type: text/plain, Size: 2596 bytes --]

- no need to read BAR during suspend
- command register is 16-bits rather than 32
- BAR and command register must be restored before trying to access
  the device
- use ps_bdf[] for storing the device coordinates (pb_bdf[] is used to
  store the bridge's ones)

--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -49,7 +49,9 @@ static struct ns16550 {
     unsigned int ps_bdf[3]; /* pci serial port BDF */
     bool_t pb_bdf_enable;   /* if =1, pb-bdf effective, port behind bridge */
     bool_t ps_bdf_enable;   /* if =1, ps_bdf effective, port on pci card */
-    int bar, cr, bar_idx;
+    u32 bar;
+    u16 cr;
+    u8 bar_idx;
 } ns16550_com[2] = { { 0 } };
 
 /* Register offsets */
@@ -324,30 +326,24 @@ static void ns16550_suspend(struct seria
     stop_timer(&uart->timer);
 
     if ( uart->bar )
-    {
-       uart->bar = pci_conf_read32(
-           0, uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
-           PCI_BASE_ADDRESS_0 + uart->bar_idx*4);
-       uart->cr = pci_conf_read32(
-           0, uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
-           PCI_COMMAND);
-    }
+       uart->cr = pci_conf_read16(0, uart->ps_bdf[0], uart->ps_bdf[1],
+                                  uart->ps_bdf[2], PCI_COMMAND);
 }
 
 static void ns16550_resume(struct serial_port *port)
 {
     struct ns16550 *uart = port->uart;
 
-    ns16550_setup_preirq(port->uart);
-    ns16550_setup_postirq(port->uart);
-
     if ( uart->bar )
     {
-       pci_conf_write32(0, uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
+       pci_conf_write32(0, uart->ps_bdf[0], uart->ps_bdf[1], uart->ps_bdf[2],
                         PCI_BASE_ADDRESS_0 + uart->bar_idx*4, uart->bar);
-       pci_conf_write32(0, uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
+       pci_conf_write16(0, uart->ps_bdf[0], uart->ps_bdf[1], uart->ps_bdf[2],
                         PCI_COMMAND, uart->cr);
     }
+
+    ns16550_setup_preirq(port->uart);
+    ns16550_setup_postirq(port->uart);
 }
 
 #ifdef CONFIG_X86
@@ -483,9 +479,9 @@ pci_uart_config (struct ns16550 *uart, i
                 if ( (len & 0xffff) != 0xfff9 )
                     continue;
 
-                uart->pb_bdf[0] = b;
-                uart->pb_bdf[1] = d;
-                uart->pb_bdf[2] = f;
+                uart->ps_bdf[0] = b;
+                uart->ps_bdf[1] = d;
+                uart->ps_bdf[2] = f;
                 uart->bar = bar;
                 uart->bar_idx = bar_idx;
                 uart->io_base = bar & 0xfffe;



[-- Attachment #2: sercon-ns16550-suspend.patch --]
[-- Type: text/plain, Size: 2632 bytes --]

ns16550: adjust suspend/resume logic

- no need to read BAR during suspend
- command register is 16-bits rather than 32
- BAR and command register must be restored before trying to access
  the device
- use ps_bdf[] for storing the device coordinates (pb_bdf[] is used to
  store the bridge's ones)

--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -49,7 +49,9 @@ static struct ns16550 {
     unsigned int ps_bdf[3]; /* pci serial port BDF */
     bool_t pb_bdf_enable;   /* if =1, pb-bdf effective, port behind bridge */
     bool_t ps_bdf_enable;   /* if =1, ps_bdf effective, port on pci card */
-    int bar, cr, bar_idx;
+    u32 bar;
+    u16 cr;
+    u8 bar_idx;
 } ns16550_com[2] = { { 0 } };
 
 /* Register offsets */
@@ -324,30 +326,24 @@ static void ns16550_suspend(struct seria
     stop_timer(&uart->timer);
 
     if ( uart->bar )
-    {
-       uart->bar = pci_conf_read32(
-           0, uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
-           PCI_BASE_ADDRESS_0 + uart->bar_idx*4);
-       uart->cr = pci_conf_read32(
-           0, uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
-           PCI_COMMAND);
-    }
+       uart->cr = pci_conf_read16(0, uart->ps_bdf[0], uart->ps_bdf[1],
+                                  uart->ps_bdf[2], PCI_COMMAND);
 }
 
 static void ns16550_resume(struct serial_port *port)
 {
     struct ns16550 *uart = port->uart;
 
-    ns16550_setup_preirq(port->uart);
-    ns16550_setup_postirq(port->uart);
-
     if ( uart->bar )
     {
-       pci_conf_write32(0, uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
+       pci_conf_write32(0, uart->ps_bdf[0], uart->ps_bdf[1], uart->ps_bdf[2],
                         PCI_BASE_ADDRESS_0 + uart->bar_idx*4, uart->bar);
-       pci_conf_write32(0, uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
+       pci_conf_write16(0, uart->ps_bdf[0], uart->ps_bdf[1], uart->ps_bdf[2],
                         PCI_COMMAND, uart->cr);
     }
+
+    ns16550_setup_preirq(port->uart);
+    ns16550_setup_postirq(port->uart);
 }
 
 #ifdef CONFIG_X86
@@ -483,9 +479,9 @@ pci_uart_config (struct ns16550 *uart, i
                 if ( (len & 0xffff) != 0xfff9 )
                     continue;
 
-                uart->pb_bdf[0] = b;
-                uart->pb_bdf[1] = d;
-                uart->pb_bdf[2] = f;
+                uart->ps_bdf[0] = b;
+                uart->ps_bdf[1] = d;
+                uart->ps_bdf[2] = f;
                 uart->bar = bar;
                 uart->bar_idx = bar_idx;
                 uart->io_base = bar & 0xfffe;

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2012-05-07 15:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-07 15:29 [PATCH] ns16550: adjust suspend/resume logic Jan Beulich
2012-05-07 15:47 ` Keir Fraser

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.