From patchwork Tue Nov 18 18:53:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 41071 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7CE1A241C9 for ; Tue, 18 Nov 2014 18:53:50 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gd6sf611909lab.8 for ; Tue, 18 Nov 2014 10:53:49 -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=sJaaJ3+F2afRkdRpH9MpZcvG5ywTyXFRG6w2s7/UuwM=; b=koL2y6DvWiZ8Pxyo9+zuPYx1eAV2gxMHlpXQZwtQKaDGZ7nkIc5JtylKWzEGKQhMqR 9de5UHgaQEzfDDbdr7W8X1H2ADAlZ5z3Un7/QUtiQPKYqDVOFWtc3+YoU+e5TQP9a3aX Lt9jsuiX6oEh7VV39ncCeKpX65Fq2rgLa2PvdG5tX7jSI+oGhbrAbpPTKV8QgcOXBouO EX9nuVFi7M8cU3fl5GJbj4KHUZbVku3HbscBVbJtzhCYqFpkRj1QH74W0Fs4ZiLJF3BR 4hPSn1akf8BhhkrnW4u3j3I9E+7pX5XQbAYZaU0ei6OyRO7q+QlM+pIpzHODfR+/JSu1 LkGQ== X-Gm-Message-State: ALoCoQkMaqV5d9gPhi8x2omnSRcCCRwIrOSNqzGLC2Is9jQnQcosp6pMerdi4kW+tsAzzWtk75M3 X-Received: by 10.180.182.164 with SMTP id ef4mr6191091wic.0.1416336829480; Tue, 18 Nov 2014 10:53:49 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.168 with SMTP id 8ls224335lav.47.gmail; Tue, 18 Nov 2014 10:53:49 -0800 (PST) X-Received: by 10.112.150.7 with SMTP id ue7mr31389022lbb.0.1416336829295; Tue, 18 Nov 2014 10:53:49 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id ac4si56893799lbc.5.2014.11.18.10.53.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Nov 2014 10:53:49 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so652698lab.34 for ; Tue, 18 Nov 2014 10:53:49 -0800 (PST) X-Received: by 10.152.42.226 with SMTP id r2mr753086lal.29.1416336828953; Tue, 18 Nov 2014 10:53:48 -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 ew9csp1383321lbc; Tue, 18 Nov 2014 10:53:48 -0800 (PST) X-Received: by 10.66.100.136 with SMTP id ey8mr38801716pab.93.1416336824184; Tue, 18 Nov 2014 10:53:44 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zp1si22746470pbc.28.2014.11.18.10.53.43 for ; Tue, 18 Nov 2014 10:53:44 -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 S932127AbaKRSxg (ORCPT + 26 others); Tue, 18 Nov 2014 13:53:36 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:60679 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755050AbaKRSxd (ORCPT ); Tue, 18 Nov 2014 13:53:33 -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 BF83F4ED; Tue, 18 Nov 2014 12:53: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 77B695FAD7; Tue, 18 Nov 2014 12:53:30 -0600 (CST) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.209.28]) by collaborate-mta1.arm.com (Postfix) with ESMTP id 54D8B13F6FA; Tue, 18 Nov 2014 12:53:28 -0600 (CST) From: Marc Zyngier To: Thomas Gleixner , Jason Cooper Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jiang Liu , Bjorn Helgaas , Yingjoe Chen , Will Deacon , Catalin marinas , Mark Rutland , Suravee Suthikulpanit , Robert Richter , "Yun Wu (Abel)" Subject: [PATCH v2 08/13] irqchip: GICv3: ITS: device allocation and configuration Date: Tue, 18 Nov 2014 18:53:03 +0000 Message-Id: <1416336788-22634-9-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1416336788-22634-1-git-send-email-marc.zyngier@arm.com> References: <1416336788-22634-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.47 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 03f9831..d687fd4 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); +}