From patchwork Thu Mar 31 11:28:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Education Directorate X-Patchwork-Id: 8711541 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 E2727C0553 for ; Thu, 31 Mar 2016 11:29:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2420E201FA for ; Thu, 31 Mar 2016 11:29:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FDC02026F for ; Thu, 31 Mar 2016 11:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756646AbcCaL26 (ORCPT ); Thu, 31 Mar 2016 07:28:58 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:36557 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756614AbcCaL2y (ORCPT ); Thu, 31 Mar 2016 07:28:54 -0400 Received: by mail-pa0-f44.google.com with SMTP id tt10so64574574pab.3 for ; Thu, 31 Mar 2016 04:28:53 -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=QPtRlCRQ3XJh54INTQ8JPazKXV4IFMMZpqTJ5rxbdRg=; b=ScgcDDp0mB3wxxiPV97xZpuJF3xtWYUwWYKH0ZN844Cyndsf7mA3I3sU6wpPkwighy Z+ImW3AFB7qHDNCOP3lf0/qRP3QoJ+5LYUFs3pzzcKdYGSyt7BoHbobxCCuKIUHnP/cp ilLY/WQfGbvHU61HIw6OryU0+niU7JkztrMpIJSJUgiyC4zk2xRI4bWBM5VwILDoEnNZ NVMP3ZMI9Dl9vC5Tqlzuc5C1izUtmeqjW2kKjS576LanQdt+pS0beOt8muti1lXMRwD8 2B9k/Wqg11uHWOmyV65Gwl+UckXDW0tolSC5ZBoFtMh/umI+ueYhhMiicDtmOS90Met2 +0/A== 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=QPtRlCRQ3XJh54INTQ8JPazKXV4IFMMZpqTJ5rxbdRg=; b=SvGqmXkpXvKVsd7ihg4jcYOLPR9Tcdu8OFmgtC1Bj3M+TDJ52boTrfuL4RdkPQfOOf 7lTz+bmtcM41rov9B89cu5yuwwOwkxRgVyEgaNfg9Bbg3pz9oN9i5fv70XarvjI3eWQ2 OokrZdKy2K/6iOWcfh2/0SIeZc3Uxjnljd1O5Sdm6ldL0QhfKAZMXCoDMrTcY4atax3m Cavj50XCF0EGYl1iCbJgSrwLtenXYGXCM+7fU+zEN0/7DqWgJwK8eMNJQCfiw9jahW/Z mJ0+PS3YQq5JCLMsZG+NW6zgyMVtwb7Y/SWa1pHV3J+picEgaFmrmTHitnvkH+hRv7Ak VZiA== X-Gm-Message-State: AD7BkJLqmkjkIeIwE37ObZLnjssx2KMC7pz+FOvioBreEyI6QLhufaFOfqxSoLDavst4UA== X-Received: by 10.66.66.234 with SMTP id i10mr21466649pat.114.1459423733374; Thu, 31 Mar 2016 04:28:53 -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 bu17sm12898249pac.25.2016.03.31.04.28.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Mar 2016 04:28:52 -0700 (PDT) Received: by cotter.ozlabs.ibm.com (Postfix, from userid 1000) id A2B35C003D; Thu, 31 Mar 2016 22:28:40 +1100 (AEDT) From: Balbir Singh To: will.deacon@arm.com, kvm@vger.kernel.org Cc: mpe@ellerman.id.au, mikey@neuling.org, Balbir Singh , Alexey Kardashevskiy Subject: [PATCH 5/5] Implement spapr pci for little endian systems. Date: Thu, 31 Mar 2016 22:28:27 +1100 Message-Id: <1459423707-8956-6-git-send-email-bsingharora@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459423707-8956-1-git-send-email-bsingharora@gmail.com> References: <1459423707-8956-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=unavailable 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 --- 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; }