From patchwork Fri Aug 3 14:38:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 953247 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41hqRl0Pwjz9s4Z for ; Sat, 4 Aug 2018 00:38:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732388AbeHCQfc (ORCPT ); Fri, 3 Aug 2018 12:35:32 -0400 Received: from mail.bootlin.com ([62.4.15.54]:50355 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732374AbeHCQfc (ORCPT ); Fri, 3 Aug 2018 12:35:32 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 1C5CC20875; Fri, 3 Aug 2018 16:38:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (AAubervilliers-681-1-99-143.w90-88.abo.wanadoo.fr [90.88.4.143]) by mail.bootlin.com (Postfix) with ESMTPSA id DD80520712; Fri, 3 Aug 2018 16:38:51 +0200 (CEST) From: Thomas Petazzoni To: Bjorn Helgaas , Lorenzo Pieralisi , linux-pci@vger.kernel.org Cc: Nadav Haklai , Gregory Clement , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Maxime Chevallier , Antoine Tenart , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni Subject: [PATCH v2 4/6] PCI: mvebu: use resource_size() to remap I/O space Date: Fri, 3 Aug 2018 16:38:46 +0200 Message-Id: <20180803143848.21551-5-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180803143848.21551-1-thomas.petazzoni@bootlin.com> References: <20180803143848.21551-1-thomas.petazzoni@bootlin.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Instead of hardcoding the remapping of IO_SPACE_LIMIT - SZ_64K, use resource_size(), as suggested by Lorenzo Pieralisi. However, we cannot use just IO_SPACE_LIMIT, because pci_ioremap_io() has a bug (which will be fixed separately) and doesn't allow remapping the last 64 KB before IO_SPACE_LIMIT, so we ensure that we do not exceed this limit. A separate patch will be sent to fix the pci_ioremap_io() issue, and once it is merged, we will be able to drop this work-around. Note that this workaround already existed, since we were mapping only up to IO_SPACE_LIMIT - SZ_64K. Suggested-by: Lorenzo Pieralisi Signed-off-by: Thomas Petazzoni --- drivers/pci/controller/pci-mvebu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index 9aa224f2f009..05f863435e5e 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -1218,10 +1218,10 @@ static int mvebu_pcie_probe(struct platform_device *pdev) pcie->realio.flags = pcie->io.flags; pcie->realio.start = PCIBIOS_MIN_IO; pcie->realio.end = min_t(resource_size_t, - IO_SPACE_LIMIT, + IO_SPACE_LIMIT - SZ_64K, resource_size(&pcie->io) - 1); - for (i = 0; i < (IO_SPACE_LIMIT - SZ_64K); i += SZ_64K) + for (i = 0; i < resource_size(&pcie->realio); i += SZ_64K) pci_ioremap_io(i, pcie->io.start + i); } else pcie->realio = pcie->io;