From patchwork Thu Nov 24 11:05:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9445217 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 BC8A06075F for ; Thu, 24 Nov 2016 11:06:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA3942780C for ; Thu, 24 Nov 2016 11:06:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD80627CF5; Thu, 24 Nov 2016 11:06:18 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3006F2780C for ; Thu, 24 Nov 2016 11:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964936AbcKXLFp (ORCPT ); Thu, 24 Nov 2016 06:05:45 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:33334 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938829AbcKXLFn (ORCPT ); Thu, 24 Nov 2016 06:05:43 -0500 Received: by mail-lf0-f52.google.com with SMTP id c13so25850216lfg.0 for ; Thu, 24 Nov 2016 03:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pPHYmip/7BqoTvw1cFSv2aGDok9pamNPFRHaouiF8DE=; b=cuXks9QdUEYAWydMm7BFzpKaZLmmfvjXeKHIYyCERiNz3R0f1foJDU4Ysq4lI/TK4l tx5o5KlQC9cn930ufTwgmoLUyivPtWhKY1tXkqXK360PEOeQDdHd3x4GtV3pMztdWap+ 1LnsGgzx8ZBadRPIa9QK7ig0hJDI3MyPMAraujpRUIDZwRREpUjh170AcoIWEAv8sbzJ gCu0Gdy71u+hR2AiQrQz2fd9EtzEipCyXdb6m31wZkW3K8bct1+AEmHDe9TbHGXyOoAP QcdB7Zfo1Ng7A9aDdV6nI6cKeyuYld9OoIhESkEvL1fDesZ3pTR9VPT5icFQZeKlTiCn OAYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pPHYmip/7BqoTvw1cFSv2aGDok9pamNPFRHaouiF8DE=; b=ftmss+sWNHkNhIRbHbYSWiIEPpA9rhL85//Tzcf4MRR0xCt3u3w/te5TaMUp0VttBj kUGeZv7RRZQVOz1pS229o1GJ9XxhhODOapNkt72hW6x85BDomysUKiy+X0zUm2pAzfJ6 39JrguekImlTPp/rA0BO8tj22qbM0Ukodx6x3GjuGWcM86XW6z2FKSsCHz0NGdaCRgcM OtqlFTnqm/pSU/fhUyXIDP8OJJB3BjlBYliIH6TA17ERnYtN8L4vll9M2kRmUGStfVmj jgI87SbZF60diKB32CEpvdTagRojU4rm/SlCO7JDTm8Jbof1Yfz1AJjYoi1oRfM3/iRT AcGw== X-Gm-Message-State: AKaTC03H78hITCVvwYyBcDZ2oFDcxw0vh/k0fCOBQ0tJPBlfOUqnEEYWOy5xVaZN2hr1lQ== X-Received: by 10.25.165.3 with SMTP id o3mr824340lfe.80.1479985541888; Thu, 24 Nov 2016 03:05:41 -0800 (PST) Received: from tn-desktop.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id h129sm8094114lfh.7.2016.11.24.03.05.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Nov 2016 03:05:41 -0800 (PST) From: Tomasz Nowicki To: helgaas@kernel.org, will.deacon@arm.com, catalin.marinas@arm.com, rafael@kernel.org, Lorenzo.Pieralisi@arm.com Cc: arnd@arndb.de, hanjun.guo@linaro.org, okaya@codeaurora.org, cov@codeaurora.org, dhdang@apm.com, Liviu.Dudau@arm.com, msalter@redhat.com, wangyijing@huawei.com, jchandra@broadcom.com, ard.biesheuvel@linaro.org, robert.richter@caviumnetworks.com, mw@semihalf.com, ddaney@caviumnetworks.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-acpi@lists.linaro.org, andrea.gallo@linaro.org, jeremy.linton@arm.com, liudongdong3@huawei.com, gabriele.paoloni@huawei.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, jcm@redhat.com, jhugo@codeaurora.org, Tomasz Nowicki Subject: [PATCH V6 1/1] ARM64/PCI: Manage controller-specific information on the host controller basis Date: Thu, 24 Nov 2016 12:05:23 +0100 Message-Id: <1479985523-10006-1-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473449047-10499-1-git-send-email-tn@semihalf.com> References: <1473449047-10499-1-git-send-email-tn@semihalf.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently we use one shared global acpi_pci_root_ops structure to keep controller-specific ops. Then its pointer is passed to acpi_pci_root_create() and associated with host bridge instance for good. Such design implies serious drawback. Any potential manipulation on the single system-wide acpi_pci_root_ops leads to kernel crash. The structure content is not really changing even across multiple host bridges creation thus it was not the issue so far. In preparation for adding ECAM quirks mechanism (where controller-specific PCI ops may be different for each host bridge) allocate new acpi_pci_root_ops and fill in with data for each bridge. Now it is safe to have different controller-specific info. As a consequence free acpi_pci_root_ops when host bridge is released. No functional changes in this patch. Signed-off-by: Tomasz Nowicki --- arch/arm64/kernel/pci.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index fb439c7..5c08baf 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -152,33 +152,36 @@ static void pci_acpi_generic_release_info(struct acpi_pci_root_info *ci) ri = container_of(ci, struct acpi_pci_generic_root_info, common); pci_ecam_free(ri->cfg); + kfree(ci->ops); kfree(ri); } -static struct acpi_pci_root_ops acpi_pci_root_ops = { - .release_info = pci_acpi_generic_release_info, -}; - /* Interface called from ACPI code to setup PCI host controller */ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) { int node = acpi_get_node(root->device->handle); struct acpi_pci_generic_root_info *ri; struct pci_bus *bus, *child; + struct acpi_pci_root_ops *root_ops; ri = kzalloc_node(sizeof(*ri), GFP_KERNEL, node); if (!ri) return NULL; + root_ops = kzalloc_node(sizeof(*root_ops), GFP_KERNEL, node); + if (!root_ops) + return NULL; + ri->cfg = pci_acpi_setup_ecam_mapping(root); if (!ri->cfg) { kfree(ri); + kfree(root_ops); return NULL; } - acpi_pci_root_ops.pci_ops = &ri->cfg->ops->pci_ops; - bus = acpi_pci_root_create(root, &acpi_pci_root_ops, &ri->common, - ri->cfg); + root_ops->release_info = pci_acpi_generic_release_info; + root_ops->pci_ops = &ri->cfg->ops->pci_ops; + bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg); if (!bus) return NULL;