All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ns16550: reset bar_64 on each iteration
@ 2015-11-12 15:52 Jan Beulich
  2015-11-12 16:58 ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2015-11-12 15:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell, Keir Fraser, Ian Jackson, Tim Deegan

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

Re-using the possibly non-zero value from a previous iteration can't
do any good.

Take the opportunity and
- limit a few other variables' scopes at once,
- adjust a few types.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- unstable.orig/xen/drivers/char/ns16550.c	2015-11-12 16:15:21.000000000 +0100
+++ unstable/xen/drivers/char/ns16550.c	2015-11-12 16:21:51.000000000 +0100
@@ -830,14 +830,11 @@ static int __init check_existence(struct
 
 #ifdef HAS_PCI
 static int __init
-pci_uart_config (struct ns16550 *uart, int skip_amt, int bar_idx)
+pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int bar_idx)
 {
-    uint32_t bar, bar_64 = 0, len, len_64;
-    u64 size, mask, orig_base;
+    u64 orig_base = uart->io_base;
     unsigned int b, d, f, nextf, i;
-    u16 vendor, device;
 
-    orig_base = uart->io_base;
     uart->io_base = 0;
     /* NB. Start at bus 1 to avoid AMT: a plug-in card cannot be on bus 0. */
     for ( b = skip_amt ? 1 : 0; b < 0x100; b++ )
@@ -846,6 +843,9 @@ pci_uart_config (struct ns16550 *uart, i
         {
             for ( f = 0; f < 8; f = nextf )
             {
+                uint32_t bar, bar_64 = 0, len, len_64;
+                u64 size;
+
                 nextf = (f || (pci_conf_read16(0, b, d, f, PCI_HEADER_TYPE) &
                                0x80)) ? f + 1 : 8;
 
@@ -869,8 +869,8 @@ pci_uart_config (struct ns16550 *uart, i
                 /* MMIO based */
                 if ( !(bar & PCI_BASE_ADDRESS_SPACE_IO) )
                 {
-                    vendor = pci_conf_read16(0, b, d, f, PCI_VENDOR_ID);
-                    device = pci_conf_read16(0, b, d, f, PCI_DEVICE_ID);
+                    u16 vendor = pci_conf_read16(0, b, d, f, PCI_VENDOR_ID);
+                    u16 device = pci_conf_read16(0, b, d, f, PCI_DEVICE_ID);
 
                     pci_conf_write32(0, b, d, f,
                                      PCI_BASE_ADDRESS_0 + bar_idx*4, ~0u);
@@ -889,8 +889,8 @@ pci_uart_config (struct ns16550 *uart, i
                                     PCI_BASE_ADDRESS_0 + (bar_idx+1)*4);
                         pci_conf_write32(0, b, d, f,
                                     PCI_BASE_ADDRESS_0 + (bar_idx+1)*4, bar_64);
-                        mask = ((u64)~0 << 32) | PCI_BASE_ADDRESS_MEM_MASK;
-                        size = (((u64)len_64 << 32) | len) & mask;
+                        size  = ((u64)~0 << 32) | PCI_BASE_ADDRESS_MEM_MASK;
+                        size &= ((u64)len_64 << 32) | len;
                     }
                     else
                         size = len & PCI_BASE_ADDRESS_MEM_MASK;




[-- Attachment #2: ns16550-bar_64-reset.patch --]
[-- Type: text/plain, Size: 2718 bytes --]

ns16550: reset bar_64 on each iteration

Re-using the possibly non-zero value from a previous iteration can't
do any good.

Take the opportunity and
- limit a few other variables' scopes at once,
- adjust a few types.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- unstable.orig/xen/drivers/char/ns16550.c	2015-11-12 16:15:21.000000000 +0100
+++ unstable/xen/drivers/char/ns16550.c	2015-11-12 16:21:51.000000000 +0100
@@ -830,14 +830,11 @@ static int __init check_existence(struct
 
 #ifdef HAS_PCI
 static int __init
-pci_uart_config (struct ns16550 *uart, int skip_amt, int bar_idx)
+pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int bar_idx)
 {
-    uint32_t bar, bar_64 = 0, len, len_64;
-    u64 size, mask, orig_base;
+    u64 orig_base = uart->io_base;
     unsigned int b, d, f, nextf, i;
-    u16 vendor, device;
 
-    orig_base = uart->io_base;
     uart->io_base = 0;
     /* NB. Start at bus 1 to avoid AMT: a plug-in card cannot be on bus 0. */
     for ( b = skip_amt ? 1 : 0; b < 0x100; b++ )
@@ -846,6 +843,9 @@ pci_uart_config (struct ns16550 *uart, i
         {
             for ( f = 0; f < 8; f = nextf )
             {
+                uint32_t bar, bar_64 = 0, len, len_64;
+                u64 size;
+
                 nextf = (f || (pci_conf_read16(0, b, d, f, PCI_HEADER_TYPE) &
                                0x80)) ? f + 1 : 8;
 
@@ -869,8 +869,8 @@ pci_uart_config (struct ns16550 *uart, i
                 /* MMIO based */
                 if ( !(bar & PCI_BASE_ADDRESS_SPACE_IO) )
                 {
-                    vendor = pci_conf_read16(0, b, d, f, PCI_VENDOR_ID);
-                    device = pci_conf_read16(0, b, d, f, PCI_DEVICE_ID);
+                    u16 vendor = pci_conf_read16(0, b, d, f, PCI_VENDOR_ID);
+                    u16 device = pci_conf_read16(0, b, d, f, PCI_DEVICE_ID);
 
                     pci_conf_write32(0, b, d, f,
                                      PCI_BASE_ADDRESS_0 + bar_idx*4, ~0u);
@@ -889,8 +889,8 @@ pci_uart_config (struct ns16550 *uart, i
                                     PCI_BASE_ADDRESS_0 + (bar_idx+1)*4);
                         pci_conf_write32(0, b, d, f,
                                     PCI_BASE_ADDRESS_0 + (bar_idx+1)*4, bar_64);
-                        mask = ((u64)~0 << 32) | PCI_BASE_ADDRESS_MEM_MASK;
-                        size = (((u64)len_64 << 32) | len) & mask;
+                        size  = ((u64)~0 << 32) | PCI_BASE_ADDRESS_MEM_MASK;
+                        size &= ((u64)len_64 << 32) | len;
                     }
                     else
                         size = len & PCI_BASE_ADDRESS_MEM_MASK;

[-- 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] 3+ messages in thread

* Re: [PATCH] ns16550: reset bar_64 on each iteration
  2015-11-12 15:52 [PATCH] ns16550: reset bar_64 on each iteration Jan Beulich
@ 2015-11-12 16:58 ` Andrew Cooper
  2015-11-16 16:46   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2015-11-12 16:58 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Ian Campbell, Ian Jackson, Keir Fraser, Tim Deegan

On 12/11/15 15:52, Jan Beulich wrote:
> Re-using the possibly non-zero value from a previous iteration can't
> do any good.
>
> Take the opportunity and
> - limit a few other variables' scopes at once,
> - adjust a few types.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

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

* Re: [PATCH] ns16550: reset bar_64 on each iteration
  2015-11-12 16:58 ` Andrew Cooper
@ 2015-11-16 16:46   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2015-11-16 16:46 UTC (permalink / raw)
  To: Andrew Cooper, Jan Beulich, xen-devel
  Cc: Ian Jackson, Keir Fraser, Tim Deegan

On Thu, 2015-11-12 at 16:58 +0000, Andrew Cooper wrote:
> On 12/11/15 15:52, Jan Beulich wrote:
> > Re-using the possibly non-zero value from a previous iteration can't
> > do any good.
> > 
> > Take the opportunity and
> > - limit a few other variables' scopes at once,
> > - adjust a few types.
> > 
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

On that basis, Acked-by: Ian Campbell <ian.campbell@citrix.com>

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

end of thread, other threads:[~2015-11-16 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 15:52 [PATCH] ns16550: reset bar_64 on each iteration Jan Beulich
2015-11-12 16:58 ` Andrew Cooper
2015-11-16 16:46   ` Ian Campbell

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.