From patchwork Fri Aug 31 19:20:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 145688 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1139703ljw; Fri, 31 Aug 2018 12:20:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ/NzA9ZJF/MgfASN2QgDE0r31SVGoefg5LbfcPP+HmfPcKe0fInQNEtS5kC+CzulpsM191 X-Received: by 2002:a62:6781:: with SMTP id t1-v6mr17456966pfj.200.1535743227706; Fri, 31 Aug 2018 12:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535743227; cv=none; d=google.com; s=arc-20160816; b=drBIybx3degSognCjVrNhBzGqdNIzG7GemynWK5PIxEiyNNHYtCwGWalXy+PBBAGbO PJjjiCtu4DLyr4eHfG+Fp86IYIQXwlhygT1/6wEVW//NedS0gGps4s8J8kHIo/VDNM9q CvwVUdRB1DA0USmrcfKX4cjwr2Q3A87E8uoUjzXyxsfE6yhn1nkyHEAhdul9S/A73o9d Gpi7u1P7b/Kizb1sgVk1BBKeqEzkEEQaqtEIpN4JYecn1nmiNZAWtSje9C6Zd8lL+/g0 oZNjL4TFFovOwatcxJo025K/oSAsOb+r2kQ4CZenIfG7xqSuBX9CTV9Ybk36vhCnHwv3 t0UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=gDdm0RdbADdHbMA3OWdOpYCbUyi2UQrHebekyGn7fEA=; b=m80wvfouC+xPTn7f9Lp08qZ5qslZuZArcEhJicrGZeMpXjrJ3MrzEMwHWEmFI53W1S W4quA6qLpfygsesmVUcD1/v5rU1nOz+h+E+1NGBOCvhvI2yDyhNxwBrhAZNgdPzDS+4I hrBsroSAUuiXNRbfKaQtDYFeM+ZXdYHjfeiFbSJxkLBQGjf+9LlsQYnQCQPIEw8GE3rM rqNHOLZb0aXMa6rcSdCK9GdUkE0OfNdLZNbBFBhr+tMZa8I/JVqGLqIkAcmy1gHAk/Hd mkPNStjDVp9/WNNKEo7D9YSCWf5nG9/GWbNox1WuKRRZMsBe1Lcdd4LaV0o2myQzwF7C quCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=H9wLNJSy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4-v6si10301941pgn.110.2018.08.31.12.20.27; Fri, 31 Aug 2018 12:20:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=H9wLNJSy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727561AbeHaX3S (ORCPT + 32 others); Fri, 31 Aug 2018 19:29:18 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:42688 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbeHaX3R (ORCPT ); Fri, 31 Aug 2018 19:29:17 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w7VJKDSr117964; Fri, 31 Aug 2018 14:20:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1535743213; bh=gDdm0RdbADdHbMA3OWdOpYCbUyi2UQrHebekyGn7fEA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=H9wLNJSysfnbgdKZbi1HCyr8JK2PHD0EhZy5yJuVkl1XyxxwuQPTqSfmtsMuCslPd XDGyMdB1ilgiBuoP1LzopMFlLRPf7QLFKm0XnM+1CGRP2r2X9kCgC+gs+wwSpKXwnt yHUn4yASW6RGsEKlCUGPH4P49CQzpFhEQf74vB5g= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJKDd8025648; Fri, 31 Aug 2018 14:20:13 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 31 Aug 2018 14:20:13 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 31 Aug 2018 14:20:13 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJKDSg015498; Fri, 31 Aug 2018 14:20:13 -0500 Received: from localhost (uda0226610.dhcp.ti.com [128.247.59.147]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w7VJKDx13941; Fri, 31 Aug 2018 14:20:13 -0500 (CDT) From: Grygorii Strashko To: , CC: Sekhar Nori , Steven Rostedt , LKML , Grygorii Strashko Subject: [4.14.66-rt TEST PATCH 1/3] irqchip/gic-v3-its: Make its_lock a raw_spin_lock_t Date: Fri, 31 Aug 2018 14:20:07 -0500 Message-ID: <20180831192009.17257-1-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.10.5 In-Reply-To: <20180830091456.mz73o26ohrc3rq2f@linutronix.de> References: <20180830091456.mz73o26ohrc3rq2f@linutronix.de> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Grygorii Strashko --- drivers/irqchip/irq-gic-v3-its.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.10.5 diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index c564443..0b691d1 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -154,7 +154,7 @@ static struct { } vpe_proxy; static LIST_HEAD(its_nodes); -static DEFINE_SPINLOCK(its_lock); +static DEFINE_RAW_SPINLOCK(its_lock); static struct rdists *gic_rdists; static struct irq_domain *its_parent; @@ -1854,7 +1854,7 @@ static void its_cpu_init_collection(void) struct its_node *its; int cpu; - spin_lock(&its_lock); + raw_spin_lock(&its_lock); cpu = smp_processor_id(); list_for_each_entry(its, &its_nodes, entry) { @@ -1896,7 +1896,7 @@ static void its_cpu_init_collection(void) its_send_invall(its, &its->collections[cpu]); } - spin_unlock(&its_lock); + raw_spin_unlock(&its_lock); } static struct its_device *its_find_device(struct its_node *its, u32 dev_id) @@ -3109,9 +3109,9 @@ static int __init its_probe_one(struct resource *res, if (err) goto out_free_tables; - spin_lock(&its_lock); + raw_spin_lock(&its_lock); list_add(&its->entry, &its_nodes); - spin_unlock(&its_lock); + raw_spin_unlock(&its_lock); return 0; From patchwork Fri Aug 31 19:20:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 145687 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1139638ljw; Fri, 31 Aug 2018 12:20:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbWYpWVKSoU4yRz9wjy2zDqv1+NZ28qhKlcA/0hsnjNkV9WuBLlk1YA5ITkxhSW3wdLhE0g X-Received: by 2002:a17:902:7c0a:: with SMTP id x10-v6mr16821642pll.77.1535743224622; Fri, 31 Aug 2018 12:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535743224; cv=none; d=google.com; s=arc-20160816; b=vKcCxs3MuJm/Zi2mTuUM8eO7D+lNdcLDbdU21JQJRAv03ObyUT/L+XPIiGhkRuZ6/A CUA+a00gxb9x1KDfU5aRZX1DWWodv9fP1sRc586oQ4sq+Qb9T+yWJq8i3eGTEck6Jf+5 8AkxqEAvYxif0+6vVQjJu/moGRbEw25pcUbnqRfbayHJQtUP/wo4NNGjZ1hYqCzvF9iO xT3ytrekhDnys/vRU/VTpI13qfaubExIzeW1fvPDbxNpxmtOg7C8t7EiJAglD3fhrKat aAzhO37FOVW6dnVmxtb0lwi9Q1P832n1ZC2TMr426otqVbbRp1gy1OVfLBHxAwtOuG13 LgYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Ph9uCGujt34SYSo8TnGJHtyq7N6jTSpj62WKS5kMEl0=; b=QakVlgmGxW+nHSxJGnNkPGkGi8X0aKKd6asTwpYKrfroowDA5IWhR5q5qJtxaOjYIr sW619akc/M3zCwBUigvpmuAfAhivCq2+MidxeCMyoPl37S0ojga+8oISfD9Py5KGNC61 sthhcY8bmJECOVdV2mdvk88+/gOvPEkoEWWPrmJE1egIFTe9VkT/+1aribkz6WnGnZ6j 3moH9ypmIRcra0M0LsRQIJs0K2ppjMcSqOTd6VtAvhxrv8EB0wCQrQBBe9xrfzdtRcJH T7ydIC8InzUdGJMNxAiTsXS9sqdgDQegFhDvQ/oiraPHh4HRYulf6RcXfXBph3XafWMC jK4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=vg6vk9X4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si9634539plr.58.2018.08.31.12.20.24; Fri, 31 Aug 2018 12:20:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=vg6vk9X4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727496AbeHaX3P (ORCPT + 32 others); Fri, 31 Aug 2018 19:29:15 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:55974 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbeHaX3P (ORCPT ); Fri, 31 Aug 2018 19:29:15 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id w7VJKDoG101644; Fri, 31 Aug 2018 14:20:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1535743213; bh=Ph9uCGujt34SYSo8TnGJHtyq7N6jTSpj62WKS5kMEl0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=vg6vk9X4+AvMz2ZHd5jeuDb249nxbgS3w7qhGkUxOmgEPj3SjiSIxEyp/pQfLMuDu unBc2UzF4f2v/FaER80UVezJv7uK0lemnjZ37iU8yGj1ku6E1n5eiR2aEP3ihBBCnp ZvNyRAbir3tphvabRH3daFJ0h+wtGWbWkcHWLBFY= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJKD3T002890; Fri, 31 Aug 2018 14:20:13 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 31 Aug 2018 14:20:13 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 31 Aug 2018 14:20:13 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJKDop030371; Fri, 31 Aug 2018 14:20:13 -0500 Received: from localhost (uda0226610.dhcp.ti.com [128.247.59.147]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w7VJKDx13945; Fri, 31 Aug 2018 14:20:13 -0500 (CDT) From: Grygorii Strashko To: , CC: Sekhar Nori , Steven Rostedt , LKML Subject: [4.14.66-rt TEST PATCH 2/3] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up hook Date: Fri, 31 Aug 2018 14:20:08 -0500 Message-ID: <20180831192009.17257-2-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.10.5 In-Reply-To: <20180831192009.17257-1-grygorii.strashko@ti.com> References: <20180830091456.mz73o26ohrc3rq2f@linutronix.de> <20180831192009.17257-1-grygorii.strashko@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior The AP-GIC-starting hook allocates memory for the ->pend_page while the CPU is started during boot-up. This callback is invoked on the target CPU with disabled interrupts. This does not work on -RT beacuse memory allocations are not possible with disabled interrupts. Move the memory allocation to an earlier hotplug step which invoked with enabled interrupts on the boot CPU. Signed-off-by: Sebastian Andrzej Siewior --- drivers/irqchip/irq-gic-v3-its.c | 60 +++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-) -- 2.10.5 diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 0b691d1..23c5818 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -171,6 +171,7 @@ static DEFINE_RAW_SPINLOCK(vmovp_lock); static DEFINE_IDA(its_vpeid_ida); #define gic_data_rdist() (raw_cpu_ptr(gic_rdists->rdist)) +#define gic_data_rdist_cpu(cpu) (per_cpu_ptr(gic_rdists->rdist, cpu)) #define gic_data_rdist_rd_base() (gic_data_rdist()->rd_base) #define gic_data_rdist_vlpi_base() (gic_data_rdist_rd_base() + SZ_128K) @@ -1738,15 +1739,17 @@ static int its_alloc_collections(struct its_node *its) return 0; } -static struct page *its_allocate_pending_table(gfp_t gfp_flags) +static struct page *its_allocate_pending_table(unsigned int cpu) { struct page *pend_page; + unsigned int order; /* * The pending pages have to be at least 64kB aligned, * hence the 'max(LPI_PENDBASE_SZ, SZ_64K)' below. */ - pend_page = alloc_pages(gfp_flags | __GFP_ZERO, - get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K))); + order = get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K)); + pend_page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL | __GFP_ZERO, + order); if (!pend_page) return NULL; @@ -1762,6 +1765,28 @@ static void its_free_pending_table(struct page *pt) get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K))); } +static int its_alloc_pend_page(unsigned int cpu) +{ + struct page *pend_page; + phys_addr_t paddr; + + pend_page = gic_data_rdist_cpu(cpu)->pend_page; + if (pend_page) + return 0; + + pend_page = its_allocate_pending_table(cpu); + if (!pend_page) { + pr_err("Failed to allocate PENDBASE for CPU%d\n", + smp_processor_id()); + return -ENOMEM; + } + + paddr = page_to_phys(pend_page); + pr_info("CPU%d: using LPI pending table @%pa\n", cpu, &paddr); + gic_data_rdist_cpu(cpu)->pend_page = pend_page; + return 0; +} + static void its_cpu_init_lpis(void) { void __iomem *rbase = gic_data_rdist_rd_base(); @@ -1770,21 +1795,8 @@ static void its_cpu_init_lpis(void) /* If we didn't allocate the pending table yet, do it now */ pend_page = gic_data_rdist()->pend_page; - if (!pend_page) { - phys_addr_t paddr; - - pend_page = its_allocate_pending_table(GFP_NOWAIT); - if (!pend_page) { - pr_err("Failed to allocate PENDBASE for CPU%d\n", - smp_processor_id()); - return; - } - - paddr = page_to_phys(pend_page); - pr_info("CPU%d: using LPI pending table @%pa\n", - smp_processor_id(), &paddr); - gic_data_rdist()->pend_page = pend_page; - } + if (!pend_page) + return; /* Disable LPIs */ val = readl_relaxed(rbase + GICR_CTLR); @@ -2603,7 +2615,7 @@ static int its_vpe_init(struct its_vpe *vpe) return vpe_id; /* Allocate VPT */ - vpt_page = its_allocate_pending_table(GFP_KERNEL); + vpt_page = its_allocate_pending_table(raw_smp_processor_id()); if (!vpt_page) { its_vpe_id_free(vpe_id); return -ENOMEM; @@ -3350,6 +3362,16 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, if (err) return err; + err = cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "irqchip/arm/gicv3:prepare", + its_alloc_pend_page, NULL); + if (err < 0) { + pr_warn("ITS: Can't register CPU-hoplug callback.\n"); + return err; + } + err = its_alloc_pend_page(smp_processor_id()); + if (err < 0) + return err; + list_for_each_entry(its, &its_nodes, entry) has_v4 |= its->is_v4; From patchwork Fri Aug 31 19:20:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 145689 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1139799ljw; Fri, 31 Aug 2018 12:20:33 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda04qRXL/MpzgUiriSuHPHMfMppR1x6khfF364iSRSxWQ3TD43vYUXqQfMOuwgZ7ddTYQ6N X-Received: by 2002:a63:28c7:: with SMTP id o190-v6mr15718027pgo.84.1535743233402; Fri, 31 Aug 2018 12:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535743233; cv=none; d=google.com; s=arc-20160816; b=TQP8HbPepz7D0D/+tB/e+qQjfdVJhPJ8cITYbEdhqGOFwMry3bJJpra2CiFxe5Wkpq iVb7yyfpbH9Xgn+zopI653aKRztqukVAHdkC1SY3/9oC1YfTMT7K9wADPD/ubmEsyE3d vMM0Z2kAx4tdPnsdffpGLBlRZzJdHMON7YsEA/WC4d7JbYgxL+q52yeGgKtSPl2N3wUL HVzP2cZNqdn7HGRpojH2wIKJCRD77VjbHKEGVp2NJxylm7VnAzyuTutHOMCONc6GZLMl FVN9yzsy9Axeu6b/jt3Nfyxox6TtkZPi/xxSgxCNHvcCKjXlStpXx4sPfqnkeXbmYd2G 8VyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=08n2LAUmPmCaDsmnTmEZoNwDbS6cNoEos6kiWKNQg/I=; b=ahYAMbRDOweZmUktsjVO6w1ahF7E5Gh3WDKUp3kLqwicHduq9lqjumyVyLC6goz+l8 7LaK4cuehCanN6V5w45sQndRY/Fxe8AD6Wt0pSLbBvsL0vQkmyGVGlORAv4v1ATAJa+b 0jqYLwSr/lPf6z9wD5hAsFuVY8UBUc4KhPFjUAzN9FXepJ9/EU2wVC/F3gkBVwTAfPKl zjOeg+klimKoL8/Lz6Nnr/uwS4dyQt+ota71Z1etbbQUrlLAfQ3fwrs5WUYROL9vIvqs E6xZx1qCF1QHxL5addz7hSL06+CokMxfwEMDK4rP1AAGl/IKBT0P96NpGQaZnr5zwceE 30nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=B4Gn8ltD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cc18-v6si11349986plb.82.2018.08.31.12.20.33; Fri, 31 Aug 2018 12:20:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=B4Gn8ltD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727589AbeHaX3Y (ORCPT + 32 others); Fri, 31 Aug 2018 19:29:24 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:36314 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbeHaX3X (ORCPT ); Fri, 31 Aug 2018 19:29:23 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w7VJKElr109044; Fri, 31 Aug 2018 14:20:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1535743214; bh=08n2LAUmPmCaDsmnTmEZoNwDbS6cNoEos6kiWKNQg/I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=B4Gn8ltDq2UsuCzgXI3qoW+48WHlXOcWeS7nL2I6Czw2f95z2y350EPF1GqmgGQEe mMdzGyilR19tnpmkSbR4Ehw6N4UqxsOUTozpjxlTPINyr0V7NYxJZzwoCyqSxkR1lr l+DzkVPcz6g+BHxiNBjhDpQ+l/FajvDllwyEK3Ic= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJKEkw025659; Fri, 31 Aug 2018 14:20:14 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 31 Aug 2018 14:20:13 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 31 Aug 2018 14:20:13 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJKDCB011481; Fri, 31 Aug 2018 14:20:13 -0500 Received: from localhost (uda0226610.dhcp.ti.com [128.247.59.147]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w7VJKDx13949; Fri, 31 Aug 2018 14:20:13 -0500 (CDT) From: Grygorii Strashko To: , CC: Sekhar Nori , Steven Rostedt , LKML , Marc Zyngier Subject: [4.14.66-rt TEST PATCH 3/3] irqchip/gic-v3-its: Move pending table allocation to init time Date: Fri, 31 Aug 2018 14:20:09 -0500 Message-ID: <20180831192009.17257-3-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.10.5 In-Reply-To: <20180831192009.17257-1-grygorii.strashko@ti.com> References: <20180830091456.mz73o26ohrc3rq2f@linutronix.de> <20180831192009.17257-1-grygorii.strashko@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier Signed-off-by: Marc Zyngier [bigeasy: backport commit effe377d415 ("irqchip/gic-v3-its: Move pending table allocation to init time")] Signed-off-by: Sebastian Andrzej Siewior --- drivers/irqchip/irq-gic-v3-its.c | 79 +++++++++++++++++--------------------- include/linux/irqchip/arm-gic-v3.h | 1 + 2 files changed, 36 insertions(+), 44 deletions(-) -- 2.10.5 diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 23c5818..1aaa757 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1446,7 +1446,7 @@ static void its_free_prop_table(struct page *prop_page) get_order(LPI_PROPBASE_SZ)); } -static int __init its_alloc_lpi_tables(void) +static int __init its_alloc_lpi_prop_table(void) { phys_addr_t paddr; @@ -1739,17 +1739,15 @@ static int its_alloc_collections(struct its_node *its) return 0; } -static struct page *its_allocate_pending_table(unsigned int cpu) +static struct page *its_allocate_pending_table(gfp_t gfp_flags) { struct page *pend_page; - unsigned int order; /* * The pending pages have to be at least 64kB aligned, * hence the 'max(LPI_PENDBASE_SZ, SZ_64K)' below. */ - order = get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K)); - pend_page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL | __GFP_ZERO, - order); + pend_page = alloc_pages(gfp_flags | __GFP_ZERO, + get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K))); if (!pend_page) return NULL; @@ -1765,25 +1763,31 @@ static void its_free_pending_table(struct page *pt) get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K))); } -static int its_alloc_pend_page(unsigned int cpu) +static int __init allocate_lpi_tables(void) { - struct page *pend_page; - phys_addr_t paddr; + int err, cpu; - pend_page = gic_data_rdist_cpu(cpu)->pend_page; - if (pend_page) - return 0; + err = its_alloc_lpi_prop_table(); + if (err) + return err; - pend_page = its_allocate_pending_table(cpu); - if (!pend_page) { - pr_err("Failed to allocate PENDBASE for CPU%d\n", - smp_processor_id()); - return -ENOMEM; + /* + * We allocate all the pending tables anyway, as we may have a + * mix of RDs that have had LPIs enabled, and some that + * don't. We'll free the unused ones as each CPU comes online. + */ + for_each_possible_cpu(cpu) { + struct page *pend_page; + + pend_page = its_allocate_pending_table(GFP_NOWAIT); + if (!pend_page) { + pr_err("Failed to allocate PENDBASE for CPU%d\n", cpu); + return -ENOMEM; + } + + gic_data_rdist_cpu(cpu)->pend_page = pend_page; } - paddr = page_to_phys(pend_page); - pr_info("CPU%d: using LPI pending table @%pa\n", cpu, &paddr); - gic_data_rdist_cpu(cpu)->pend_page = pend_page; return 0; } @@ -1791,22 +1795,14 @@ static void its_cpu_init_lpis(void) { void __iomem *rbase = gic_data_rdist_rd_base(); struct page *pend_page; + phys_addr_t paddr; u64 val, tmp; - /* If we didn't allocate the pending table yet, do it now */ - pend_page = gic_data_rdist()->pend_page; - if (!pend_page) + if (gic_data_rdist()->lpi_enabled) return; - /* Disable LPIs */ - val = readl_relaxed(rbase + GICR_CTLR); - val &= ~GICR_CTLR_ENABLE_LPIS; - writel_relaxed(val, rbase + GICR_CTLR); - - /* - * Make sure any change to the table is observable by the GIC. - */ - dsb(sy); + pend_page = gic_data_rdist()->pend_page; + paddr = page_to_phys(pend_page); /* set PROPBASE */ val = (page_to_phys(gic_rdists->prop_page) | @@ -1859,6 +1855,10 @@ static void its_cpu_init_lpis(void) /* Make sure the GIC has seen the above */ dsb(sy); + gic_data_rdist()->lpi_enabled = true; + pr_info("GICv3: CPU%d: using LPI pending table @%pa\n", + smp_processor_id(), + &paddr); } static void its_cpu_init_collection(void) @@ -2615,7 +2615,7 @@ static int its_vpe_init(struct its_vpe *vpe) return vpe_id; /* Allocate VPT */ - vpt_page = its_allocate_pending_table(raw_smp_processor_id()); + vpt_page = its_allocate_pending_table(GFP_KERNEL); if (!vpt_page) { its_vpe_id_free(vpe_id); return -ENOMEM; @@ -3358,18 +3358,9 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, } gic_rdists = rdists; - err = its_alloc_lpi_tables(); - if (err) - return err; - err = cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "irqchip/arm/gicv3:prepare", - its_alloc_pend_page, NULL); - if (err < 0) { - pr_warn("ITS: Can't register CPU-hoplug callback.\n"); - return err; - } - err = its_alloc_pend_page(smp_processor_id()); - if (err < 0) + err = allocate_lpi_tables(); + if (err) return err; list_for_each_entry(its, &its_nodes, entry) diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index bacb499..688f256 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -568,6 +568,7 @@ struct rdists { void __iomem *rd_base; struct page *pend_page; phys_addr_t phys_base; + bool lpi_enabled; } __percpu *rdist; struct page *prop_page; int id_bits;