From: "Jan Beulich" Subject: Re: [PATCH V4] ns16550: Add support for UART present in Broadcom TruManage capable NetXtreme chips Date: Fri, 22 Nov 2013 12:29:58 +0000 Message-ID: <528F5C560200007800105D01@nat28.tlf.novell.com> References: <1385074236-2100-1-git-send-email-Aravind.Gopalakrishnan@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1385074236-2100-1-git-send-email-Aravind.Gopalakrishnan@amd.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Aravind Gopalakrishnan , xen-devel@lists.xen.org Cc: Thomas Lendacky , shurd@broadcom.com, Suravee Suthikulpanit , sherry.hurwitz@amd.com List-Id: xen-devel@lists.xenproject.org >>> On 21.11.13 at 23:50, Aravind Gopalakrishnan wrote: > @@ -432,9 +474,16 @@ static void __init ns16550_endboot(struct serial_port *port) > { > #ifdef HAS_IOPORTS > struct ns16550 *uart = port->uart; > - > + unsigned long sfn, efn; > + Stray blanks. > if ( uart->remapped_io_base ) > + { > + sfn = paddr_to_pfn((unsigned long) uart->io_base + PAGE_SIZE); > + efn = paddr_to_pfn((unsigned long) uart->io_base + uart->io_size - 1); These casts aren't correct for 32-bit hosts (even if we don't have any that define HAS_IOPORTS). And anyway, using PFN_UP() and PFN_DOWN() here respectively would be much easier to read. > + if ( iomem_deny_access(dom0, sfn, efn) != 0 ) You need to handle the case of sfn > efn, I think. > + /* Handle 64 bit BAR if found */ > + if ( bar & PCI_BASE_ADDRESS_MEM_TYPE_64 ) > + { Do you really need that (and the respective changes elsewhere)? I'd be fine with simply bailing in that case for the time being. > + } > + else > + { > + len &= PCI_BASE_ADDRESS_MEM_MASK; > + uart->io_size = len & ~(len - 1); Once again: "len & -len" is the simpler alternative. > + /* IO based */ > + else > + { > + pci_conf_write32(0, b, d, f, > + PCI_BASE_ADDRESS_0 + bar_idx*4, ~0u); > + len = pci_conf_read32(0, b, d, f, PCI_BASE_ADDRESS_0); > + pci_conf_write32(0, b, d, f, > + PCI_BASE_ADDRESS_0 + bar_idx*4, bar); > + len &= PCI_BASE_ADDRESS_IO_MASK; > + len &= ~(len - 1); len &= -len (PCI_BASE_ADDRESS_IO_MASK being ~0x03UL I don't see why this would be incorrect, as you indicated in a reply to v3). Jan