From patchwork Thu Oct 23 15:23:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 39374 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 090B020341 for ; Thu, 23 Oct 2014 15:23:36 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id p9sf729587lbv.4 for ; Thu, 23 Oct 2014 08:23:35 -0700 (PDT) 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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=8Ex/QPd/fCVyy98JSCWh1fJKEUQyQTQ7WFQBDS8mNK8=; b=QQLMF5ratdp0Zd83vUHPJKYWTTQDYjIJjLaVED10tJK8MdbZnSLVojPSBE4sdQWjSF gG9RqWvxGCbnwtGcl6zfrHPhCrtWpPjbvs1NF0DcGfUHrpU5Rbz3k3kqpKPBJ7x2LT9L v0fkTe/nlJrFKGMNsE1OLAhFzemQj+u7r5F2WqsamkKhUqGjBJfSUfTXa3CLMi3AW4iF 7O8wEKwvEERG2coxmzbMdaOLznzsxjWTGX5scsU0gu0KVvuPn1ilkHwOzBnwj+fmxXW5 6r3Rcjkg3IuWEXp/6+Z0Z24Vo2xW963LhaqEtOC0y0oFDPErOV1tbmC+OGHWK4v05kXA Dpgw== X-Gm-Message-State: ALoCoQmKFPVeLGjsk/CB4Nx5YLlto9uhk0EscJxwLVVNPF3cnC9O89M50wLtVz1Rp0K0Fficp+y9 X-Received: by 10.181.8.194 with SMTP id dm2mr1147153wid.2.1414077815483; Thu, 23 Oct 2014 08:23:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.72 with SMTP id q8ls279309laq.98.gmail; Thu, 23 Oct 2014 08:23:35 -0700 (PDT) X-Received: by 10.152.21.226 with SMTP id y2mr5944103lae.70.1414077815089; Thu, 23 Oct 2014 08:23:35 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id i5si3154959lbd.20.2014.10.23.08.23.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 08:23:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id mc6so1072813lab.16 for ; Thu, 23 Oct 2014 08:23:35 -0700 (PDT) X-Received: by 10.152.120.199 with SMTP id le7mr5711244lab.67.1414077814996; Thu, 23 Oct 2014 08:23:34 -0700 (PDT) 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.84.229 with SMTP id c5csp274265lbz; Thu, 23 Oct 2014 08:23:34 -0700 (PDT) X-Received: by 10.70.48.202 with SMTP id o10mr5648234pdn.63.1414077813385; Thu, 23 Oct 2014 08:23:33 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mm5si1786459pbc.212.2014.10.23.08.23.31 for ; Thu, 23 Oct 2014 08:23:33 -0700 (PDT) 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 S1755974AbaJWPX0 (ORCPT + 28 others); Thu, 23 Oct 2014 11:23:26 -0400 Received: from service87.mimecast.com ([91.220.42.44]:49456 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753575AbaJWPXY (ORCPT ); Thu, 23 Oct 2014 11:23:24 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 23 Oct 2014 16:23:21 +0100 Received: from red-moon.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 23 Oct 2014 16:23:21 +0100 From: Lorenzo Pieralisi To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: liviu.dudau@arm.com, Suravee.Suthikulpanit@amd.com, Lorenzo Pieralisi , Will Deacon Subject: [PATCH RFC 1/2] drivers: pci: fix window allocation order wrt bus_range filtering Date: Thu, 23 Oct 2014 16:23:06 +0100 Message-Id: <1414077787-20633-1-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.1.2 X-OriginalArrivalTime: 23 Oct 2014 15:23:21.0272 (UTC) FILETIME=[478A3B80:01CFEED5] X-MC-Unique: 114102316232119101 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: lorenzo.pieralisi@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.43 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 number of windows allocated for the host bridge depends on the bus resource. Instead of first allocating the windows and then limit the bus resource, this patch reshuffles the code so that if any limitation is applied to the bus resource it is taken into account in the windows allocation. Cc: Will Deacon Signed-off-by: Lorenzo Pieralisi Acked-by: Will Deacon --- drivers/pci/host/pci-host-generic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c index 3d2076f..1e1a80f 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c @@ -276,17 +276,17 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci) return err; } - pci->cfg.win = devm_kcalloc(dev, resource_size(&pci->cfg.bus_range), - sizeof(*pci->cfg.win), GFP_KERNEL); - if (!pci->cfg.win) - return -ENOMEM; - /* Limit the bus-range to fit within reg */ bus_max = pci->cfg.bus_range.start + (resource_size(&pci->cfg.res) >> pci->cfg.ops->bus_shift) - 1; pci->cfg.bus_range.end = min_t(resource_size_t, pci->cfg.bus_range.end, bus_max); + pci->cfg.win = devm_kcalloc(dev, resource_size(&pci->cfg.bus_range), + sizeof(*pci->cfg.win), GFP_KERNEL); + if (!pci->cfg.win) + return -ENOMEM; + /* Map our Configuration Space windows */ if (!devm_request_mem_region(dev, pci->cfg.res.start, resource_size(&pci->cfg.res),