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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 D1535C07E96 for ; Tue, 6 Jul 2021 14:22:57 +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 1E13961A46 for ; Tue, 6 Jul 2021 14:22:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E13961A46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 9169682CDA; Tue, 6 Jul 2021 16:22:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Pr5qT/mc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D387A82C81; Tue, 6 Jul 2021 16:22:32 +0200 (CEST) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C76AC82C1B for ; Tue, 6 Jul 2021 16:22:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=daniel.schwierzeck@gmail.com Received: by mail-wr1-x436.google.com with SMTP id i94so26315196wri.4 for ; Tue, 06 Jul 2021 07:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h5D+qocCZtihevslRhOh+tnJzDuBFLwvACgd1oW+MG0=; b=Pr5qT/mc35Gk96oDQwjuknVSwZHv16Uo9eZw5bjyH9JsuOc+bExwIRKdX9267JL1Sb Bnnf/nWbeu2h6NdIThJD3+AOCRSHONmEKXoeDP+vqjo1lewRaagXFc/uiQ5IyrIXGKpy CvZzSyquOeTXVMUpK1CTs06bCh8O9BWoX6G6r60vTn2jdz5gzZ+GxOSmT3uWUavXbKnf zfd6ZapbVDUrp1ueoQRxQqK7nydOx3w1LyxOZvUL8S0rvOIm91ykj5xUGscjuV9f/vi/ LEdTgkMOxZz5vDaJnkqeENr85zstJy0BsK/kRqdtr9ytGVww3fEstgn9gQIRKx4YOIQ2 Yf9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h5D+qocCZtihevslRhOh+tnJzDuBFLwvACgd1oW+MG0=; b=pC4SVXzJwrYW5fxfSLdt+zQuHTqvVSJVgVZkWZNVYuRexudbc7DEaqhfDCldlYP7m9 pQxiNaHadKrXzsZATIbjKLnwlGuLO2pIvV75xqM4Ujoj3SK1ZDuJqiuFqCM5kkHD8Ofp TFmoxuH3iDHs0zRt4/POqsBWc7zOH1nmvV2QwfOaEPq/ONnXCItNOJMqRGwSEvNlkRII ehEq/YzP1EbBbmLX3brJzAqfbT7pYPIaDH3Q5eNlSangEc0EZD0fhMH6M5cMqmQ0EEbv zuJqdo5Qk78/mLvFtngKK56jtUO4M/DG+xq0ePRbE/uBkw3CNTEEGc46olLeDqd/ancP /DqQ== X-Gm-Message-State: AOAM531txGOHlu22xkDjVYLUHgae9Xko1PYYSaImxaJ54A80/xd2ACo3 It2ZjxydRAqr23bkBbbnGQGr3a/znC8= X-Google-Smtp-Source: ABdhPJzR2XwRnDknmZm3DDdyTXehOCNqrPUk7CoRo2eS0Sixtz31ILp0w+5FXfmSJ4IfA1FBTpUfKA== X-Received: by 2002:adf:ce07:: with SMTP id p7mr23012675wrn.70.1625581347365; Tue, 06 Jul 2021 07:22:27 -0700 (PDT) Received: from workstation.lan.schwierd.dedyn.io (i5E860781.versanet.de. [94.134.7.129]) by smtp.gmail.com with ESMTPSA id t9sm16880571wrq.92.2021.07.06.07.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 07:22:26 -0700 (PDT) From: Daniel Schwierzeck To: u-boot@lists.denx.de Cc: Simon Glass , Stefan Roese , Tom Rini , Daniel Schwierzeck Subject: [PATCH 1/6] dm: pci: add option to map virtual system memory base address Date: Tue, 6 Jul 2021 16:22:17 +0200 Message-Id: <20210706142222.497569-2-daniel.schwierzeck@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210706142222.497569-1-daniel.schwierzeck@gmail.com> References: <20210706142222.497569-1-daniel.schwierzeck@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 + 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); } } -- 2.32.0