From patchwork Sun Apr 3 10:38:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Education Directorate X-Patchwork-Id: 8734011 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D501DC0553 for ; Sun, 3 Apr 2016 10:38:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F38D12021B for ; Sun, 3 Apr 2016 10:38:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D353D2015E for ; Sun, 3 Apr 2016 10:38:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753240AbcDCKiV (ORCPT ); Sun, 3 Apr 2016 06:38:21 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:34259 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752892AbcDCKiP (ORCPT ); Sun, 3 Apr 2016 06:38:15 -0400 Received: by mail-pa0-f52.google.com with SMTP id fe3so123573786pab.1 for ; Sun, 03 Apr 2016 03:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xr6tc8VIyn908YFBwc16ZOEc3wq85s2qwihff4mbd8Q=; b=Afbg/MIs8amiHQwmpsFwrZSSSN6U3LBt7GuiYbZu+lo6HCKO1jh93WZKQ8nlcUKssR hYp16TtVoM0PYC/1bNafGOgHZd4G4r9iNgd9l8I3hPw2GoJYh61txQY9z5u+Q9JnsY8t GQ/eIz3gx0LUI+JgbPUE1uscwQxMrXWPtXvm2mvJCU/m8ETcHjnO6JGyA7p3bIADz9ji G9hIvp9mbBeKrKHJVnOCqnl+mJM5P7XWIUDWlkZKiJSZmBFO3AjkQk9QOamixHzWwoOC R+GSZNPu+s7nUiUjAM9D90Ey/agZ06E4ca25myHgfcayGJmq97i++KY6xN0Qhb1Vg0HZ LAow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xr6tc8VIyn908YFBwc16ZOEc3wq85s2qwihff4mbd8Q=; b=RoECz38klSJV3e+hmk892B/qAZK/FlUfBgxlmYBFmO6dn4kMasgmly4ikvQpE/RXQq 0k+9recCiI48cVQ68mqlfY+xE1wS9b/O6iFgJ2AxIn2mbiWShmPPNxQTn2i7b1J0cudR VTbm1jkYbvWPGXbsvlj7g9Xv7lxsE93DCOU1zK5W5ifSR9mW8lwZ3h3HVDYVgE08VIB2 izdksgyG83xAaYpwqfUp75plP6Bde8+F30EJ2zr4Hq+Zmxrf0x2h/tkefKRl6jRi9F82 DHoppV+Q2a4Pe1kE3+0Jj9zOMEKGQC/hdnVoDdhtJygNHHlHGJAEsEIVHpP7c+W/dI2y /jXg== X-Gm-Message-State: AD7BkJKTZ5jZEcyxUetgUY4yiOsqprmcZ9nExhbfOnCY1QgtpUcptTrH3yCPl0VmFOipvQ== X-Received: by 10.66.183.230 with SMTP id ep6mr45181778pac.89.1459679894628; Sun, 03 Apr 2016 03:38:14 -0700 (PDT) Received: from cotter.ozlabs.ibm.com (14-202-194-140.static.tpgi.com.au. [14.202.194.140]) by smtp.gmail.com with ESMTPSA id fk10sm34030879pab.33.2016.04.03.03.38.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Apr 2016 03:38:14 -0700 (PDT) Received: by cotter.ozlabs.ibm.com (Postfix, from userid 1000) id EE728C0103; Sun, 3 Apr 2016 20:38:03 +1000 (AEST) From: Balbir Singh To: will.deacon@arm.com, kvm@vger.kernel.org Cc: mpe@ellerman.id.au, mikey@neuling.org, aik@ozlabs.ru, Balbir Singh Subject: [KVMTOOL][PATCH 5/5] Implement spapr pci for little endian systems. Date: Sun, 3 Apr 2016 20:38:02 +1000 Message-Id: <1459679882-30382-6-git-send-email-bsingharora@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459679882-30382-1-git-send-email-bsingharora@gmail.com> References: <1459679882-30382-1-git-send-email-bsingharora@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Port the spapr_pci implementation for ppc64le. Based on suggestions by Alexey Kardashevskiy We should have always used phys_hi and 64 bit addr and size. Cc: Alexey Kardashevskiy Signed-off-by: Balbir Singh Acked-by: Michael Ellerman --- powerpc/spapr_pci.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/powerpc/spapr_pci.c b/powerpc/spapr_pci.c index 768e3f2..a15f7d8 100644 --- a/powerpc/spapr_pci.c +++ b/powerpc/spapr_pci.c @@ -234,8 +234,11 @@ int spapr_populate_pci_devices(struct kvm *kvm, int bus_off, node_off = 0, devid, fn, i, n, devices; struct device_header *dev_hdr; char nodename[256]; - struct of_pci_unit_address reg[PCI_NUM_REGIONS + 1], - assigned_addresses[PCI_NUM_REGIONS]; + struct of_pci_unit64_address { + u32 phys_hi; + u64 addr; + u64 size; + } __attribute((packed)) reg[PCI_NUM_REGIONS + 1], assigned_addresses[PCI_NUM_REGIONS]; uint32_t bus_range[] = { cpu_to_be32(0), cpu_to_be32(0xff) }; struct of_pci_ranges_entry ranges[] = { { @@ -339,7 +342,7 @@ int spapr_populate_pci_devices(struct kvm *kvm, le16_to_cpu(hdr->subsys_vendor_id))); /* Config space region comes first */ - reg[0].hi = cpu_to_be32( + reg[0].phys_hi = cpu_to_be32( of_pci_b_n(0) | of_pci_b_p(0) | of_pci_b_t(0) | @@ -347,8 +350,8 @@ int spapr_populate_pci_devices(struct kvm *kvm, of_pci_b_bbbbbbbb(0) | of_pci_b_ddddd(devid) | of_pci_b_fff(fn)); - reg[0].mid = 0; - reg[0].lo = 0; + reg[0].addr = 0; + reg[0].size = 0; n = 0; /* Six BARs, no ROM supported, addresses are 32bit */ @@ -357,7 +360,7 @@ int spapr_populate_pci_devices(struct kvm *kvm, continue; } - reg[n+1].hi = cpu_to_be32( + reg[n+1].phys_hi = cpu_to_be32( of_pci_b_n(0) | of_pci_b_p(0) | of_pci_b_t(0) | @@ -366,10 +369,10 @@ int spapr_populate_pci_devices(struct kvm *kvm, of_pci_b_ddddd(devid) | of_pci_b_fff(fn) | of_pci_b_rrrrrrrr(bars[i])); - reg[n+1].mid = 0; - reg[n+1].lo = cpu_to_be64(hdr->bar_size[i]); + reg[n+1].size = cpu_to_be64(hdr->bar_size[i]); + reg[n+1].addr = 0; - assigned_addresses[n].hi = cpu_to_be32( + assigned_addresses[n].phys_hi = cpu_to_be32( of_pci_b_n(1) | of_pci_b_p(0) | of_pci_b_t(0) | @@ -383,8 +386,8 @@ int spapr_populate_pci_devices(struct kvm *kvm, * Writing zeroes to assigned_addresses causes the guest kernel to * reassign BARs */ - assigned_addresses[n].mid = cpu_to_be64(bar_to_addr(le32_to_cpu(hdr->bar[i]))); - assigned_addresses[n].lo = reg[n+1].lo; + assigned_addresses[n].addr = cpu_to_be64(bar_to_addr(le32_to_cpu(hdr->bar[i]))); + assigned_addresses[n].size = reg[n+1].size; ++n; }