From patchwork Wed Nov 28 14:43:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 10702801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 125C513BB for ; Wed, 28 Nov 2018 14:46:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3B3C2C1F6 for ; Wed, 28 Nov 2018 14:46:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E76B72D596; Wed, 28 Nov 2018 14:46:09 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5CF8B2C1F6 for ; Wed, 28 Nov 2018 14:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uhNYcT6LRqZTTMrDkiLUHLxUzj4mA5/Po/gDpCWAFR8=; b=NfpuxvNnRWgkEn 7LYrpnbYCV04nWs29bPkSpZB3G2PA0VXYDcA+VP+tNlpudO9b1uhkb88lKb1tL9H+Tvom3IsMCa4c hM3uFWQRG00+RRzuCY4VfJy6oJTKUgpF5VgnRfY/9MHiuo/PwaPbF9TT78kaLIToUrIwFw2DKWGvH iN1w7pT4myjgCmuGrEy/SiGjGk4A77II9UBEuNklGASiq6PgErAL+qBgfXClssXxiSEcVxj1Zc4I+ dRxXhlJ2xHGm8Pv/ETtSQ+GTSDYa/aF2/wcmQOmsXe20FuvlH9iCV2UXeVvrg7wMvsr56doBNbpvd HgnoigVUCkAc+/YcZAqw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS16N-0006Qh-0e; Wed, 28 Nov 2018 14:46:07 +0000 Received: from mail-co1nam04on060b.outbound.protection.outlook.com ([2a01:111:f400:fe4d::60b] helo=NAM04-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS14A-0003BM-24 for linux-arm-kernel@lists.infradead.org; Wed, 28 Nov 2018 14:44:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IXb+GAEoraiyNOmdqnTOtP3SeGPlwUy8jnhcvWxXRDg=; b=jFkBPMzymW7FSl41SXdTMEyvNWldl3qLT3yFLGFJChV4dBy5Tiupw/9WjTeCM5NUmjrOtG8Hn3uy04UZiEzUeJMMI3WwRvHJV/f3vITYWyWh9u9drbpdIF1kLGOnIzYX5dqR0kxwn8qOHsEEJ/Z+x/jWuRUVtMmW4/4iNSBZUhY= Received: from SN6PR07MB5326.namprd07.prod.outlook.com (52.135.105.33) by SN6PR07MB4399.namprd07.prod.outlook.com (52.135.91.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.18; Wed, 28 Nov 2018 14:43:31 +0000 Received: from SN6PR07MB5326.namprd07.prod.outlook.com ([fe80::ccc7:d111:7f3d:667d]) by SN6PR07MB5326.namprd07.prod.outlook.com ([fe80::ccc7:d111:7f3d:667d%4]) with mapi id 15.20.1361.018; Wed, 28 Nov 2018 14:43:30 +0000 From: Robert Richter To: Marc Zyngier , Thomas Gleixner , Jason Cooper Subject: [PATCH v2 08/10] irqchip/gic-v3-its: Decouple its initialization from gic Thread-Topic: [PATCH v2 08/10] irqchip/gic-v3-its: Decouple its initialization from gic Thread-Index: AQHUhyi7J6nxU0I0fUOV/EFE/c3JsQ== Date: Wed, 28 Nov 2018 14:43:30 +0000 Message-ID: <20181128144240.28727-9-rrichter@cavium.com> References: <20181128144240.28727-1-rrichter@cavium.com> In-Reply-To: <20181128144240.28727-1-rrichter@cavium.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6P194CA0042.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::19) To SN6PR07MB5326.namprd07.prod.outlook.com (2603:10b6:805:73::33) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Robert.Richter@cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [77.14.124.106] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN6PR07MB4399; 6:OQz25jywiKo5KK1r2TJQVOtyNjeanLJWwghon2vCLKC3D7qi2T30Cy79wL+JTERdjWRTWT+TDMXHpytfTBWA8NPvCs4ClMp+wJq0GjIz54f71rx4/6kwO1Dtxo6SRBtD5upmOG4g9smX91wCtg56WqzG5PHej9kRYMmWxeDulo8cGvnhcDTdr87b89vPLOodnyxFdkt0WYVB3C/ieX4u6fBT1LyvRqG7fa4chn6+E3bUqREJsZiT+NM5Sau3dpfjkBBAEyahYSqUoEjxa8QlBmrQcrDbnC6G4MJCFgFCyPPFRZvbftHwUdkv+LOZqJM88YMKwR8CqGsqILrhI1d3j4YLDdeZOopYGzualFrYp2hCirr5H8eNT+lnAAJPR1M6mdjBuUL1sUYtHu1ov22dHHWMzAM0Jo+oYIulLxPSGTlGoUdyvA2jjeEMXyN6o3NSwzoiM+OPi3rXMvcg3rlM4Q==; 5:+l66DSIfY1fbp3lKbkXxJzujbBSHNzpkEvcCsqdZVfIGvOmOm0qNIGoXpXJ1kFsDfnlXS65ywzTnbYeQdKoXL6US1aOxZ4nNWJbqbD0zZ4YLaJyEcnP6wBJ7wjivupS2J+sKux4BLN/NFLp0iFyBXCvJCZinnIsUyT+YYjPe64c=; 7:LAsYVfGJol+XoHidK6Vgn/dNL8/ott3wqLsvs/cXlouGb0Tz3K+rJuqhMph4DLLrwUufshPtBEw5GHoFgqjOb/O79Fh29kittoK3NdI6I/Ph5A38lysVPHDGCajK3h3MPkrHYN0YliS+ebvxqYGPJA== x-ms-office365-filtering-correlation-id: e0fa4443-9a0d-4911-d27a-08d6553fdd3f x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB4399; x-ms-traffictypediagnostic: SN6PR07MB4399: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231443)(999002)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:SN6PR07MB4399; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB4399; x-forefront-prvs: 0870212862 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(366004)(39860400002)(136003)(199004)(189003)(97736004)(14444005)(256004)(105586002)(4326008)(106356001)(81156014)(8936002)(66066001)(2906002)(54906003)(110136005)(71190400001)(81166006)(6486002)(316002)(14454004)(8676002)(39060400002)(36756003)(76176011)(52116002)(68736007)(186003)(6116002)(7416002)(25786009)(71200400001)(53936002)(478600001)(99286004)(6512007)(446003)(11346002)(6436002)(26005)(305945005)(486006)(575784001)(7736002)(102836004)(72206003)(3846002)(2616005)(6506007)(5660300001)(386003)(476003)(1076002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB4399; H:SN6PR07MB5326.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: SrHnSxULl5bUGAITusbpMBdLQsDRWRyRWS1J7JMtJ9dOuQN2hFrDFB505A3lfQRmSJetrr0e/4fKlQkrAARf1a/RsA18AJAz621dmnB/qD4PoPWtz11cF1J6Ue2kjURCUdj2yzuVxeaB0HK2vIdsHnLLvdimOfiDuhQ7xqNM8RjCAg3VW3+r89clrKQxUT9zNgKDGck475iFWbLSPYNVa+HCF4IS2SLttV2akXeTzBBVlMqGcjmndIZZjDTZz8l3HfPVKFh1OA9s3Kg6VcBnBlvrsEqC2lSLEa89BRJ6Sg2MSRFhLUrxeiBbGcB1YJ4AVthiB1mVmkU72n02TYp+CAFrdU1MdBK5Nx470X+1hwI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0fa4443-9a0d-4911-d27a-08d6553fdd3f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2018 14:43:30.8533 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4399 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181128_064350_931453_FE334681 X-CRM114-Status: GOOD ( 17.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Stuart Yoder , Julien Thierry , Will Deacon , "linux-kernel@vger.kernel.org" , "Richter, Robert" , Matthias Brugger , "linux-arm-kernel@lists.infradead.org" , Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch separates its initialization from the gic. Probing and initialization of its nodes is separate now. There is an own cpu notifier for its now. Signed-off-by: Robert Richter --- drivers/irqchip/irq-gic-v3-its.c | 58 +++++++++++++++++++++++++------------- drivers/irqchip/irq-gic-v3.c | 14 ++++----- include/linux/cpuhotplug.h | 1 + include/linux/irqchip/arm-gic-v3.h | 2 +- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index c28f4158ff70..fd8561fcfdf3 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -167,6 +167,7 @@ static struct { } vpe_proxy; static LIST_HEAD(its_nodes); +static LIST_HEAD(its_probed); static DEFINE_RAW_SPINLOCK(its_lock); static struct rdists *gic_rdists; static struct irq_domain *its_parent; @@ -3482,20 +3483,13 @@ static int __init its_compute_its_list_map(struct its_node *its) static void its_free(struct its_node *its) { - raw_spin_lock(&its_lock); - list_del(&its->entry); - raw_spin_unlock(&its_lock); - kfree(its); } -static int __init its_init_one(struct its_node *its); - static int __init its_probe_one(struct resource *res, struct fwnode_handle *handle, int numa_node) { struct its_node *its; - int err; its = kzalloc(sizeof(*its), GFP_KERNEL); if (!its) @@ -3510,16 +3504,12 @@ static int __init its_probe_one(struct resource *res, its->numa_node = numa_node; raw_spin_lock(&its_lock); - list_add_tail(&its->entry, &its_nodes); + list_add_tail(&its->entry, &its_probed); raw_spin_unlock(&its_lock); pr_info("ITS %pR\n", res); - err = its_init_one(its); - if (err) - its_free(its); - - return err; + return 0; } static int __init its_init_one(struct its_node *its) @@ -3717,7 +3707,7 @@ static int redist_disable_lpis(void) return 0; } -int its_cpu_init(void) +static int its_cpu_init(unsigned int cpu) { if (!list_empty(&its_nodes)) { int ret; @@ -3913,8 +3903,6 @@ static void __init its_acpi_probe(void) static void __init its_acpi_probe(void) { } #endif -static int __init its_init(void); - int __init its_probe(struct fwnode_handle *handle, struct rdists *rdists, struct irq_domain *parent_domain) { @@ -3929,23 +3917,51 @@ int __init its_probe(struct fwnode_handle *handle, struct rdists *rdists, gic_rdists = rdists; - return its_init(); + return 0; } -static int __init its_init(void) +int __init its_init(void) { struct its_node *its; bool has_v4 = false; int err; + if (list_empty(&its_probed)) + return 0; + + raw_spin_lock(&its_lock); +redo: + list_for_each_entry(its, &its_probed, entry) { + list_del_init(&its->entry); + + raw_spin_unlock(&its_lock); + + /* Needs to be called in non-atomic context */ + err = its_init_one(its); + if (err) + its_free(its); + + raw_spin_lock(&its_lock); + + if (!err) + list_add_tail(&its->entry, &its_nodes); + + goto redo; + } + + raw_spin_unlock(&its_lock); + if (list_empty(&its_nodes)) { pr_warn("ITS: No ITS available, not enabling LPIs\n"); return -ENXIO; } err = allocate_lpi_tables(); - if (err) + if (err) { + pr_warn("ITS: Failed to initialize (%d), not enabling LPIs\n", + err); return err; + } list_for_each_entry(its, &its_nodes, entry) has_v4 |= its->is_v4; @@ -3960,5 +3976,9 @@ static int __init its_init(void) register_syscore_ops(&its_syscore_ops); + cpuhp_setup_state(CPUHP_AP_IRQ_GIC_ITS_STARTING, + "irqchip/arm/gicv3-its:starting", + its_cpu_init, NULL); + return 0; } diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index e04108b7c6b7..d2942efdb6d5 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -685,9 +685,6 @@ static int gic_starting_cpu(unsigned int cpu) { gic_cpu_init(); - if (gic_dist_supports_lpis()) - its_cpu_init(); - return 0; } @@ -815,7 +812,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, #else #define gic_set_affinity NULL #define gic_smp_init() do { } while(0) -#endif +#endif /* CONFIG_SMP */ #ifdef CONFIG_CPU_PM /* Check whether it's single security state view */ @@ -1131,10 +1128,8 @@ static int __init gic_init_bases(void __iomem *dist_base, gic_cpu_init(); gic_cpu_pm_init(); - if (gic_dist_supports_lpis()) { + if (gic_dist_supports_lpis()) its_probe(handle, &gic_data.rdists, gic_data.domain); - its_cpu_init(); - } return 0; @@ -1327,6 +1322,9 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare if (static_branch_likely(&supports_deactivate_key)) gic_of_setup_kvm_info(node); + + its_init(); + return 0; out_unmap_rdist: @@ -1630,6 +1628,8 @@ gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end) if (static_branch_likely(&supports_deactivate_key)) gic_acpi_setup_kvm_info(); + its_init(); + return 0; out_fwhandle_free: diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index e0cd2baa8380..584f73585142 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -96,6 +96,7 @@ enum cpuhp_state { CPUHP_AP_SCHED_STARTING, CPUHP_AP_RCUTREE_DYING, CPUHP_AP_IRQ_GIC_STARTING, + CPUHP_AP_IRQ_GIC_ITS_STARTING, CPUHP_AP_IRQ_HIP04_STARTING, CPUHP_AP_IRQ_ARMADA_XP_STARTING, CPUHP_AP_IRQ_BCM2836_STARTING, diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index a6fdb2910f73..f4348fa4260a 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -602,9 +602,9 @@ struct rdists { struct irq_domain; struct fwnode_handle; -int its_cpu_init(void); int its_probe(struct fwnode_handle *handle, struct rdists *rdists, struct irq_domain *domain); +int its_init(void); int mbi_init(struct fwnode_handle *fwnode, struct irq_domain *parent); static inline bool gic_enable_sre(void)