From patchwork Tue Nov 11 15:48:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 40591 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CD745241C9 for ; Tue, 11 Nov 2014 15:50:04 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c41sf7025499eek.0 for ; Tue, 11 Nov 2014 07:50:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=y9EwnXgHnr4ycnNg/avYa+fI/eBuuWehSEySchWgmHQ=; b=JOhq7TukcOLd4qroNbwcYPK6Hk+PnbxrpPPpRHMcQZesWDPOKxjOBHU56Q+JU9jv0R DwE9uyi7/gWI4nbtdOTwG1DQ2oB71J/RoUXsXmBBEvEQPbpY3/jEEupGw04P+C+pRUBM SIJ1NNkiFN5xPofCHwE+h3gLcU2Erg1ly4rrKOfTgESaLZuXb89YwzlLaVcS7YRAargH ivptvf9jtfQGBEkxMtfS+cCW2XcKlGk2sIuvhcdd74xPuzxb5s1yE5hGfmh+10YnVoKj w3JNL9Q5rldm7c5H3OA7ZHzRxcrLJvpNDCUbpU4whvOOtjzwxdWYvAbyDcjKdSKHKVUR iebg== X-Gm-Message-State: ALoCoQlYZ7y6YrrFTeEEYNyDlHWpbj72s+jOsGj7ICwvIgMMMCRB/JFjXOZpYuBCBN+uIfTw+7N3 X-Received: by 10.112.50.243 with SMTP id f19mr3220793lbo.1.1415721003986; Tue, 11 Nov 2014 07:50:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.200 with SMTP id n8ls455910lag.10.gmail; Tue, 11 Nov 2014 07:50:03 -0800 (PST) X-Received: by 10.112.219.3 with SMTP id pk3mr36926698lbc.18.1415721003454; Tue, 11 Nov 2014 07:50:03 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id rs4si31989196lbb.12.2014.11.11.07.50.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 07:50:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id s18so9763283lam.14 for ; Tue, 11 Nov 2014 07:50:03 -0800 (PST) X-Received: by 10.152.42.226 with SMTP id r2mr36881589lal.29.1415721003366; Tue, 11 Nov 2014 07:50:03 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp277392lbc; Tue, 11 Nov 2014 07:50:02 -0800 (PST) X-Received: by 10.70.14.4 with SMTP id l4mr41179605pdc.56.1415721001747; Tue, 11 Nov 2014 07:50:01 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si3247817pdd.34.2014.11.11.07.50.00 for ; Tue, 11 Nov 2014 07:50:01 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752036AbaKKPt7 (ORCPT + 25 others); Tue, 11 Nov 2014 10:49:59 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:56211 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbaKKPsl (ORCPT ); Tue, 11 Nov 2014 10:48:41 -0500 Received: from foss-smtp-na-1.foss.arm.com (unknown [10.80.61.8]) by foss-mx-na.foss.arm.com (Postfix) with ESMTP id 626024F3; Tue, 11 Nov 2014 09:48:32 -0600 (CST) Received: from collaborate-mta1.arm.com (highbank-bc01-b06.austin.arm.com [10.112.81.134]) by foss-smtp-na-1.foss.arm.com (Postfix) with ESMTP id 1D3CA5FAD7; Tue, 11 Nov 2014 09:48:30 -0600 (CST) Received: from e102391-lin.cambridge.arm.com (e102391-lin.cambridge.arm.com [10.1.209.143]) by collaborate-mta1.arm.com (Postfix) with ESMTP id C792913F78C; Tue, 11 Nov 2014 09:48:28 -0600 (CST) From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jiang Liu , Thomas Gleixner Cc: Bjorn Helgaas , Yingjoe Chen , Will Deacon , Catalin marinas , Mark Rutland Subject: [PATCH 10/15] irqchip: GICv3: ITS: device allocation and configuration Date: Tue, 11 Nov 2014 15:48:08 +0000 Message-Id: <1415720893-13371-11-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1415720893-13371-1-git-send-email-marc.zyngier@arm.com> References: <1415720893-13371-1-git-send-email-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: marc.zyngier@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The ITS has a notion of "device" that can write to it in order to generate an interrupt. Conversly, the driver maintains a per-ITS list of devices, together with their configuration information, and uses this to configure the HW. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 92e0f49..8d13012 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -981,3 +981,77 @@ static void its_cpu_init_collection(void) spin_unlock(&its_lock); } + +static struct its_device *its_find_device(struct its_node *its, u32 dev_id) +{ + struct its_device *its_dev = NULL, *tmp; + + raw_spin_lock(&its->lock); + + list_for_each_entry(tmp, &its->its_device_list, entry) { + if (tmp->device_id == dev_id) { + its_dev = tmp; + break; + } + } + + raw_spin_unlock(&its->lock); + + return its_dev; +} + +static struct its_device *its_create_device(struct its_node *its, u32 dev_id, + int nvecs) +{ + struct its_device *dev; + unsigned long *lpi_map; + void *itt; + int lpi_base; + int nr_lpis; + int cpu; + int sz; + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + sz = nvecs * its->ite_size; + sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; + itt = kmalloc(sz, GFP_KERNEL); + lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis); + + if (!dev || !itt || !lpi_map) { + kfree(dev); + kfree(itt); + kfree(lpi_map); + return NULL; + } + + dev->its = its; + dev->itt = itt; + dev->nr_ites = nvecs; + dev->lpi_map = lpi_map; + dev->lpi_base = lpi_base; + dev->nr_lpis = nr_lpis; + dev->device_id = dev_id; + INIT_LIST_HEAD(&dev->entry); + + raw_spin_lock(&its->lock); + list_add(&dev->entry, &its->its_device_list); + raw_spin_unlock(&its->lock); + + /* Bind the device to the first possible CPU */ + cpu = cpumask_first(cpu_online_mask); + dev->collection = &its->collections[cpu]; + + /* Map device to its ITT */ + its_send_mapd(dev, 1); + + return dev; +} + +static void its_free_device(struct its_device *its_dev) +{ + raw_spin_lock(&its_dev->its->lock); + list_del(&its_dev->entry); + raw_spin_unlock(&its_dev->its->lock); + kfree(its_dev->itt); + kfree(its_dev); +}