All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"keir@xen.org" <keir@xen.org>,
	Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	"JBeulich@novell.com" <JBeulich@novell.com>,
	Ian Campbell <Ian.Campbell@eu.citrix.com>,
	"roger.cruz@virtualcomputer.com" <roger.cruz@virtualcomputer.com>,
	"tom.goetz@virtualcomputer.com" <tom.goetz@virtualcomputer.com>
Subject: Re: [PATCH 4 of 5] xen: Update pci_uart_config to save the BAR1 contents if com2 is used
Date: Wed, 13 Jul 2011 11:07:36 +0100	[thread overview]
Message-ID: <1310551656.448.5.camel@elijah> (raw)
In-Reply-To: <841e8a1304e707bb9f07.1310493191@localhost6.localdomain6>

On Tue, 2011-07-12 at 18:53 +0100, Konrad Rzeszutek Wilk wrote:
> # HG changeset patch
> # User Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> # Date 1310493175 14400
> # Node ID 841e8a1304e707bb9f077d014fb59d46133fbeae
> # Parent  ded47a2ba411fefc614c773ae78518a162f912f9
> xen: Update pci_uart_config to save the BAR1 contents if com2 is used
> 
> Jan Beulich pointed out that the pci_uart_config can be called for
> com2 and we should probe the second BAR instead of the first one.
> 
> This patch will probe the BAR0 if it is com1, and BAR1 if its com2.
> It also cleans up some of the whitespace problems and changes the
> name of the parameter and function from 'magic' to 'pci'.
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> 
> diff -r ded47a2ba411 -r 841e8a1304e7 xen/drivers/char/ns16550.c
> --- a/xen/drivers/char/ns16550.c	Tue Jul 12 13:06:05 2011 -0400
> +++ b/xen/drivers/char/ns16550.c	Tue Jul 12 13:52:55 2011 -0400
> @@ -49,7 +49,7 @@ 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 bar0, cr;
> +    int bar, cr, bar_idx;
>  } ns16550_com[2] = { { 0 } };
>  
>  /* Register offsets */
> @@ -338,9 +338,10 @@ static void ns16550_resume(struct serial
>      ns16550_setup_preirq(port->uart);
>      ns16550_setup_postirq(port->uart);
>  
> -    if (uart->bar0) {
> +    if (uart->bar) {
>         pci_conf_write32(uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
> -                        PCI_BASE_ADDRESS_0, uart->bar0);
> +                        PCI_BASE_ADDRESS_0 + sizeof(uint32_t) * uart->bar_idx,
> +                        uart->bar);
>         pci_conf_write32(uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
>                          PCI_COMMAND, uart->cr);
>      }
> @@ -368,9 +369,10 @@ static void ns16550_suspend(struct seria
>      struct ns16550 *uart = port->uart;
>  
>      stop_timer(&uart->timer);
> -    if (uart->bar0) {
> -       uart->bar0 = pci_conf_read32(uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
> -                                    PCI_BASE_ADDRESS_0);
> +    if (uart->bar) {
> +       uart->bar = pci_conf_read32(uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
> +                                   PCI_BASE_ADDRESS_0 +
> +                                   (sizeof(uint32_t) * uart->bar_idx));
>         uart->cr = pci_conf_read32(uart->pb_bdf[0], uart->pb_bdf[1], uart->pb_bdf[2],
>                                      PCI_COMMAND);
>      }
> @@ -460,37 +462,40 @@ static int __init check_existence(struct
>  }
>  
>  static int
> -magic_uart_config (struct ns16550 *uart,int skip_amt)
> +pci_uart_config (struct ns16550 *uart, int skip_amt, int bar_idx)
>  {
>    uint16_t class;
> -  uint32_t bar0, len;
> +  uint32_t bar, len;
>    int b, d, f;
>  
>  /*Skanky hack - start at bus 1 to avoid AMT, a plug in card cannot be on bus 1 */
>  
> -  if (skip_amt) b=1;
> -	else b=0;
> +  if (skip_amt)
> +    b=1;
> +  else
> +    b=0;
>  
>    for (; b < 0x100; ++b)
> +  {
> +    for (d = 0; d < 0x20; ++d)
>      {
> -    for (d = 0; d < 0x20; ++d)
> -        {
>            for (f = 0; f < 0x8; ++f)
> -            {
> -
> +          {
>                class = pci_conf_read16 (b, d, f, PCI_CLASS_DEVICE);
>                if (class != 0x700)
>                  continue;;
>  
> -              bar0 = pci_conf_read32 (b, d, f, PCI_BASE_ADDRESS_0);
> +              bar = pci_conf_read32 (b, d, f, PCI_BASE_ADDRESS_0 +
> +                                     (sizeof(uint32_t) * bar_idx));
>  
>                /* Not IO */
> -              if (!(bar0 & 1))
> +              if (!(bar & 1))
>                  continue;
>  
>                pci_conf_write32 (b, d, f, PCI_BASE_ADDRESS_0, 0xffffffff);
>                len = pci_conf_read32 (b, d, f, PCI_BASE_ADDRESS_0);
> -              pci_conf_write32 (b, d, f, PCI_BASE_ADDRESS_0, bar0);
> +              pci_conf_write32 (b, d, f, PCI_BASE_ADDRESS_0 +
> +                                (sizeof(uint32_t) * bar_idx), bar);
>  
>                /* Not 8 bytes */
>                if ((len & 0xffff) != 0xfff9)
> @@ -499,8 +504,9 @@ magic_uart_config (struct ns16550 *uart,
>                uart->pb_bdf[0] = b;
>                uart->pb_bdf[1] = d;
>                uart->pb_bdf[2] = f;
> -              uart->bar0 = bar0;
> -              uart->io_base = bar0 & 0xfffe;
> +              uart->bar = bar;
> +              uart->bar_idx = bar_idx;
> +              uart->io_base = bar & 0xfffe;
>                uart->irq = 0;
>  
>                return 0;
> @@ -569,15 +575,14 @@ static void __init ns16550_parse_port_co
>      if ( *conf == ',' )
>      {
>          conf++;
> -        
> -        if ( strncmp(conf,"magic",5) == 0 ) {
> -	    if (magic_uart_config(uart,1)) 
> -		return;
> -	    conf+=5;
> -        } else if ( strncmp(conf,"amt",3) == 0 ) {
> -	    if (magic_uart_config(uart,0)) 
> -		return;
> -	    conf+=3;
> +        if ( strncmp(conf, "pci", 5) == 0 ) {
> +	        if (pci_uart_config(uart, 1/* skip AMT */, uart - ns16550_com))
> +		        return;
> +	        conf += 3;

Isn't fixing issues found in earlier patches in later patches a bit
skanky? :-)

 -George

  reply	other threads:[~2011-07-13 10:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-12 17:53 [PATCH 0 of 5] Patches for PCI serial cards (v2) Konrad Rzeszutek Wilk
2011-07-12 17:53 ` [PATCH 1 of 5] xen: Automatically find serial port on PCI/PCIe and AMT devices Konrad Rzeszutek Wilk
2011-07-12 17:53 ` [PATCH 2 of 5] xen: Support suspend in ns16550 code Konrad Rzeszutek Wilk
2011-07-12 17:53 ` [PATCH 3 of 5] xen: Restore the BAR and PCI command after resume Konrad Rzeszutek Wilk
2011-07-12 17:53 ` [PATCH 4 of 5] xen: Update pci_uart_config to save the BAR1 contents if com2 is used Konrad Rzeszutek Wilk
2011-07-13 10:07   ` George Dunlap [this message]
2011-07-13 13:23     ` Konrad Rzeszutek Wilk
2011-07-12 17:53 ` [PATCH 5 of 5] doc: Update the com1, com2 section with pci and amt options Konrad Rzeszutek Wilk

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=1310551656.448.5.camel@elijah \
    --to=george.dunlap@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=JBeulich@novell.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=keir@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=roger.cruz@virtualcomputer.com \
    --cc=tom.goetz@virtualcomputer.com \
    --cc=xen-devel@lists.xensource.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.