From patchwork Tue Jul 16 05:19:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 259347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C29552C0144 for ; Tue, 16 Jul 2013 15:20:35 +1000 (EST) Received: from localhost ([::1]:34757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uyxgf-0008Ne-BR for incoming@patchwork.ozlabs.org; Tue, 16 Jul 2013 01:20:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyxgM-0008MC-KM for qemu-devel@nongnu.org; Tue, 16 Jul 2013 01:20:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyxgJ-00072y-1B for qemu-devel@nongnu.org; Tue, 16 Jul 2013 01:20:14 -0400 Received: from mail-ie0-f177.google.com ([209.85.223.177]:43581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyxgI-00072Y-RU for qemu-devel@nongnu.org; Tue, 16 Jul 2013 01:20:10 -0400 Received: by mail-ie0-f177.google.com with SMTP id aq17so663303iec.36 for ; Mon, 15 Jul 2013 22:20:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=i8Z6R1hlx4npqwrVFdDBawg4DmvThu4r3J1hDLgb8qI=; b=DNlkdy82r23U7LR/JaVRZ1cmDuwewsfylprYWxaH3Oa9J3wsJ/HnmQ2FlIdws1AXm7 Y+E6zwkd1wct0guI3j8uxmEJ8SmjCl2BwmK+T0VPqye58wV84WTLzHzz6HRltdx00jY9 dmH8rpI+DO9o2mYym75NiiDbKAswnirrSkWLdjJaKcRglV0PtAyLa1RXwVVF1c9FmRxo cNpIddXa3TowE5LE/u392c8lPW5+R23ccVmYURBdCRgo44ZfC1lcEgRVHU8b9Lauq/gT JfltlhZEdZ+LbG61R/GUbekbvuPI9yU1NMj3rkKOONnBl+Gbp+mjif088yAcN/tYjatE ALsQ== X-Received: by 10.50.60.2 with SMTP id d2mr8915605igr.52.1373952010322; Mon, 15 Jul 2013 22:20:10 -0700 (PDT) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPSA id y2sm22917853igl.10.2013.07.15.22.20.05 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Jul 2013 22:20:08 -0700 (PDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Tue, 16 Jul 2013 15:19:55 +1000 Message-Id: <1373951995-9866-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: X-Gm-Message-State: ALoCoQkpwPK4MsvcPD/qu3l9PsekZm2ZHg2nAia8sL+LhHp00nBPT0A7wdDjfBqtVE+RqHyG5Fbb X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.223.177 Cc: Anthony Liguori , Alexey Kardashevskiy , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Paul Mackerras , David Gibson Subject: [Qemu-devel] [PATCH] spapr-pci: remove io ports workaround X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org In the past, IO space could not be mapped into the memory address space so we introduced a workaround for that. Nowadays it does not look necessary so we can remove the workaround and make sPAPR PCI configuration simplier. This also removes all byte swappings as it is not PHB's to take care of endiannes - devices should do convertion if they want to. And almost every PCI device which uses IO ports does that by registering IO ports region with memory_region_init_io() (Intel e1000, RTL8139, virtio). However VGA uses MemoryRegionPortio which does not support endiannes but it still expects the convertion to be done. For this case only, this patch adds LITTLE_ENDIAN flag to portio_ops. Tests on PPC64 show that other devices are not affected by this change. x86 systems should not suffer either as having LITTLE_ENDIAN there has no effect. Signed-off-by: Alexey Kardashevskiy --- This removes bugs at least from SPAPR so any further fixes should be equal for all platforms and hopefully will break all platform altogether but not just PPC64-pSeries :) Did I miss anything here? --- hw/ppc/spapr_pci.c | 52 +++------------------------------------------------- ioport.c | 1 + 2 files changed, 4 insertions(+), 49 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index ca588aa..8d76290 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -440,43 +440,6 @@ static void pci_spapr_set_irq(void *opaque, int irq_num, int level) qemu_set_irq(spapr_phb_lsi_qirq(phb, irq_num), level); } -static uint64_t spapr_io_read(void *opaque, hwaddr addr, - unsigned size) -{ - switch (size) { - case 1: - return cpu_inb(addr); - case 2: - return cpu_inw(addr); - case 4: - return cpu_inl(addr); - } - g_assert_not_reached(); -} - -static void spapr_io_write(void *opaque, hwaddr addr, - uint64_t data, unsigned size) -{ - switch (size) { - case 1: - cpu_outb(addr, data); - return; - case 2: - cpu_outw(addr, data); - return; - case 4: - cpu_outl(addr, data); - return; - } - g_assert_not_reached(); -} - -static const MemoryRegionOps spapr_io_ops = { - .endianness = DEVICE_LITTLE_ENDIAN, - .read = spapr_io_read, - .write = spapr_io_write -}; - /* * MSI/MSIX memory region implementation. * The handler handles both MSI and MSIX. @@ -590,23 +553,14 @@ static int spapr_phb_init(SysBusDevice *s) memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr, &sphb->memwindow); - /* On ppc, we only have MMIO no specific IO space from the CPU - * perspective. In theory we ought to be able to embed the PCI IO - * memory region direction in the system memory space. However, - * if any of the IO BAR subregions use the old_portio mechanism, - * that won't be processed properly unless accessed from the - * system io address space. This hack to bounce things via - * system_io works around the problem until all the users of - * old_portion are updated */ + /* Initialize IO regions */ sprintf(namebuf, "%s.io", sphb->dtbusname); memory_region_init(&sphb->iospace, OBJECT(sphb), namebuf, SPAPR_PCI_IO_WIN_SIZE); - /* FIXME: fix to support multiple PHBs */ - memory_region_add_subregion(get_system_io(), 0, &sphb->iospace); sprintf(namebuf, "%s.io-alias", sphb->dtbusname); - memory_region_init_io(&sphb->iowindow, OBJECT(sphb), &spapr_io_ops, sphb, - namebuf, SPAPR_PCI_IO_WIN_SIZE); + memory_region_init_alias(&sphb->iowindow, OBJECT(sphb), + namebuf, &sphb->iospace, 0, SPAPR_PCI_IO_WIN_SIZE); memory_region_add_subregion(get_system_memory(), sphb->io_win_addr, &sphb->iowindow); diff --git a/ioport.c b/ioport.c index 89b17d6..79b7f1a 100644 --- a/ioport.c +++ b/ioport.c @@ -183,6 +183,7 @@ static void portio_write(void *opaque, hwaddr addr, uint64_t data, static const MemoryRegionOps portio_ops = { .read = portio_read, .write = portio_write, + .endianness = DEVICE_LITTLE_ENDIAN, .valid.unaligned = true, .impl.unaligned = true, };