Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE0DCC07E99 for ; Fri, 9 Jul 2021 07:11:20 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9AD526109D for ; Fri, 9 Jul 2021 07:11:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9AD526109D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8DDC181EBD; Fri, 9 Jul 2021 09:11:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625814677; bh=BgqHaYW0hZbWys0EZ6HfPtA5jCyQhgOIM4tYRcQEbEU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QigWe87uGj/zy4Hs0VhOZ89tAgB0qrDBjJG9rVQA/kGdQR4vlOyv7579TrydeYTh+ W7sK8L3C0jOKX8VwMUvP+F6vyEVQ5kZJZZqpgFw6u++iyUS8oukiGqsya6hXW2vU0a 7AkvNJdWcI55/5zagVqfhRvB887kYf0fs9OdGRjRJ3GwH1AHzx12PCaLJIuXQ40k2P vY4hLqK1IgxbPKtCPUhjUjNxsV/P9dlzLk2lFAJ64KKI4WU3KcGRP5lWkzcDKpsTsU TZrKMXXc34UDQZKyz60Fr3LZQj73z4MqtNSihgDaaIdQ0wT+fo1uwVtSj+z9yA6DiC XH2lmn4IYQWBg== Received: by phobos.denx.de (Postfix, from userid 109) id C5EB380C58; Fri, 9 Jul 2021 09:11:15 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A0ADC8320F for ; Fri, 9 Jul 2021 09:11:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4GLkpl2gdxzQjBF; Fri, 9 Jul 2021 09:11:11 +0200 (CEST) Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id Y8p-0c-UYg-4; Fri, 9 Jul 2021 09:11:06 +0200 (CEST) Subject: Re: [PATCH 1/6] dm: pci: add option to map virtual system memory base address To: Daniel Schwierzeck , u-boot@lists.denx.de Cc: Simon Glass , Tom Rini References: <20210706142222.497569-1-daniel.schwierzeck@gmail.com> <20210706142222.497569-2-daniel.schwierzeck@gmail.com> From: Stefan Roese Message-ID: Date: Fri, 9 Jul 2021 09:11:06 +0200 MIME-Version: 1.0 In-Reply-To: <20210706142222.497569-2-daniel.schwierzeck@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-MBO-SPAM-Probability: X-Rspamd-Score: -3.03 / 15.00 / 15.00 X-Rspamd-Queue-Id: 59D4C11FA X-Rspamd-UID: fad802 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 06.07.21 16:22, Daniel Schwierzeck wrote: > On MIPS the DRAM start address respectively CONFIG_SYS_SDRAM_BASE > is still used as a virtual, CPU-mapped address instead of being used > as physical address. Converting all MIPS boards and generic MIPS code > to fix that is not trivial. Due to the approaching deadline for > PCI DM conversion, this workaround is required for MIPS boards with > PCI support until the CONFIG_SYS_SDRAM_BASE issue could be solved. > > Add a compile-time option to let the PCI uclass core optionally map > the DRAM address to a physical address when adding the PCI region > of type PCI_REGION_SYS_MEMORY. > > Signed-off-by: Daniel Schwierzeck > --- > > drivers/pci/Kconfig | 13 +++++++++++++ > drivers/pci/pci-uclass.c | 9 ++++++--- > 2 files changed, 19 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig > index b2b7b253f8..02c34077e2 100644 > --- a/drivers/pci/Kconfig > +++ b/drivers/pci/Kconfig > @@ -54,6 +54,19 @@ config PCI_REGION_MULTI_ENTRY > region type. This helps to add support for SoC's like OcteonTX/TX2 > where every peripheral is on the PCI bus. > > +config PCI_MAP_SYSTEM_MEMORY > + bool "Map local system memory from a virtual base address" > + depends on PCI || DM_PCI > + depends on MIPS > + default n AFAIK, "default n" is not needed as it's the "default" setting. Apart from this: Reviewed-by: Stefan Roese Thanks, Stefan > + help > + Say Y if base address of system memory is being used as a virtual address > + instead of a physical address (e.g. on MIPS). The PCI core will then remap > + the virtual memory base address to a physical address when adding the PCI > + region of type PCI_REGION_SYS_MEMORY. > + This should only be required on MIPS where CONFIG_SYS_SDRAM_BASE is still > + being used as virtual address. > + > config PCI_SRIOV > bool "Enable Single Root I/O Virtualization support for PCI" > depends on PCI || DM_PCI > diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c > index 22a033e632..1e2ed5426e 100644 > --- a/drivers/pci/pci-uclass.c > +++ b/drivers/pci/pci-uclass.c > @@ -998,10 +998,13 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, > > for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { > if (bd->bi_dram[i].size) { > + phys_addr_t start = bd->bi_dram[i].start; > + > + if (IS_ENABLED(CONFIG_PCI_MAP_SYSTEM_MEMORY)) > + start = virt_to_phys((void *)(uintptr_t)bd->bi_dram[i].start); > + > pci_set_region(hose->regions + hose->region_count++, > - bd->bi_dram[i].start, > - bd->bi_dram[i].start, > - bd->bi_dram[i].size, > + start, start, bd->bi_dram[i].size, > PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); > } > } > Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de