From patchwork Thu May 11 17:53:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9722625 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C3886031B for ; Thu, 11 May 2017 17:53:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B703286D0 for ; Thu, 11 May 2017 17:53:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80397286E5; Thu, 11 May 2017 17:53:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2802B286D0 for ; Thu, 11 May 2017 17:53:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8sFg-0000cr-Lt; Thu, 11 May 2017 17:51:48 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8sFg-0000b6-2W for xen-devel@lists.xenproject.org; Thu, 11 May 2017 17:51:48 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 2A/9C-02192-3B4A4195; Thu, 11 May 2017 17:51:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTXfTEpF Ig4sfVSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox7y06yFRySrfjxewprA+NukS5GLg4hgc2M EnM7JrNDOMsZJXbuXcvaxcjJwSagK7Hj5mtmEFtEIFTi6YLvzCBFzAJrGCXOLfrJBpIQFvCUO P1+GpDNwcEioCpxtM0dJMwrYC3x5fcCdhBbQkBOouH8fbA5nEDxJdNnsYDYQgJWErt2n2adwM i9gJFhFaNGcWpRWWqRrqGJXlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGoIcZgGA H44rtnocYJTmYlER5GSeKRArxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4I1cDJQTLEpNT61Iy8wB hhpMWoKDR0mEdwlImre4IDG3ODMdInWKUVFKnJcHJCEAksgozYNrg4X3JUZZKWFeRqBDhHgKU otyM0tQ5V8xinMwKgnz7gSZwpOZVwI3/RXQYiagxf1/hEEWlyQipKQaGOc0ei9W55CMuDEhd3 KE345J1496u705d2yZT8GK5oVc0tlhQS8iEp6/+if2yn/nhnu76xZ+FGXP1X3a9TBx//KEqy5 eNyJErCXbGV7pVxZyZ2f19jtO3DO3u06mglOYPSQoPmN52hf2D5uvmmVqKutJe8+6u/K/XsC6 795aUdN5f4lnxXj/UWIpzkg01GIuKk4EABrRYERqAgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1494525105!61472570!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64058 invoked from network); 11 May 2017 17:51:46 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-31.messagelabs.com with SMTP; 11 May 2017 17:51:46 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E03F19E8; Thu, 11 May 2017 10:51:45 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 777843F4FF; Thu, 11 May 2017 10:51:44 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Thu, 11 May 2017 18:53:27 +0100 Message-Id: <20170511175340.8448-16-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170511175340.8448-1-andre.przywara@arm.com> References: <20170511175340.8448-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni Subject: [Xen-devel] [PATCH v9 15/28] ARM: vITS: provide access to struct pending_irq X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP For each device we allocate one struct pending_irq for each virtual event (MSI). Provide a helper function which returns the pointer to the appropriate struct, to be able to find the right struct when given a virtual deviceID/eventID pair. Signed-off-by: Andre Przywara --- xen/arch/arm/gic-v3-its.c | 69 ++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/gic_v3_its.h | 4 +++ 2 files changed, 73 insertions(+) diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c index aebc257..fd6a394 100644 --- a/xen/arch/arm/gic-v3-its.c +++ b/xen/arch/arm/gic-v3-its.c @@ -800,6 +800,75 @@ out: return ret; } +/* Must be called with the its_device_lock held. */ +static struct its_device *get_its_device(struct domain *d, paddr_t vdoorbell, + uint32_t vdevid) +{ + struct rb_node *node = d->arch.vgic.its_devices.rb_node; + struct its_device *dev; + + ASSERT(spin_is_locked(&d->arch.vgic.its_devices_lock)); + + while (node) + { + int cmp; + + dev = rb_entry(node, struct its_device, rbnode); + cmp = compare_its_guest_devices(dev, vdoorbell, vdevid); + + if ( !cmp ) + return dev; + + if ( cmp > 0 ) + node = node->rb_left; + else + node = node->rb_right; + } + + return NULL; +} + +static uint32_t get_host_lpi(struct its_device *dev, uint32_t eventid) +{ + uint32_t host_lpi = INVALID_LPI; + + if ( dev && (eventid < dev->eventids) ) + host_lpi = dev->host_lpi_blocks[eventid / LPI_BLOCK] + + (eventid % LPI_BLOCK); + + return host_lpi; +} + +static struct pending_irq *get_event_pending_irq(struct domain *d, + paddr_t vdoorbell_address, + uint32_t vdevid, + uint32_t veventid, + uint32_t *host_lpi) +{ + struct its_device *dev; + struct pending_irq *pirq = NULL; + + spin_lock(&d->arch.vgic.its_devices_lock); + dev = get_its_device(d, vdoorbell_address, vdevid); + if ( dev && veventid <= dev->eventids ) + { + pirq = &dev->pend_irqs[veventid]; + if ( host_lpi ) + *host_lpi = get_host_lpi(dev, veventid); + } + spin_unlock(&d->arch.vgic.its_devices_lock); + + return pirq; +} + +struct pending_irq *gicv3_its_get_event_pending_irq(struct domain *d, + paddr_t vdoorbell_address, + uint32_t vdevid, + uint32_t veventid) +{ + return get_event_pending_irq(d, vdoorbell_address, vdevid, veventid, NULL); +} + /* Scan the DT for any ITS nodes and create a list of host ITSes out of it. */ void gicv3_its_dt_init(const struct dt_device_node *node) { diff --git a/xen/include/asm-arm/gic_v3_its.h b/xen/include/asm-arm/gic_v3_its.h index 40f4ef5..d162e89 100644 --- a/xen/include/asm-arm/gic_v3_its.h +++ b/xen/include/asm-arm/gic_v3_its.h @@ -169,6 +169,10 @@ int gicv3_its_map_guest_device(struct domain *d, int gicv3_allocate_host_lpi_block(struct domain *d, uint32_t *first_lpi); void gicv3_free_host_lpi_block(uint32_t first_lpi); +struct pending_irq *gicv3_its_get_event_pending_irq(struct domain *d, + paddr_t vdoorbell_address, + uint32_t vdevid, + uint32_t veventid); #else static inline void gicv3_its_dt_init(const struct dt_device_node *node)