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,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 E7175C636C8 for ; Thu, 15 Jul 2021 18:54:38 +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 6CA00613D4 for ; Thu, 15 Jul 2021 18:54:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CA00613D4 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 7A9CA829EF; Thu, 15 Jul 2021 20:54: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="EUxvLvgB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E25682DFE; Thu, 15 Jul 2021 20:54:19 +0200 (CEST) Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (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 CF86882BC7 for ; Thu, 15 Jul 2021 20:54:12 +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-ed1-x52f.google.com with SMTP id w14so9564123edc.8 for ; Thu, 15 Jul 2021 11:54:12 -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=mU5nrMJUcdBgg7urSanDBiC3erPWRLTNvV05ryWEl48=; b=EUxvLvgB2QphD1kzDr020jRAiCDxAhFCxgkMW/fj9W4ToHi14I2phcqQ39KiVkewkG LznzvhvvfBF1U3KaLfbTcooM91eNZa31rls1dkN+0uEW2ijzIvIaHi8cQRPPaS3gDHdl DQiMrAiXrvQqLiUh+NDt/cX3zuB7TjFiUpfiHoJ6OVl3krADn919dZcrS/MtxSEpLiqJ 7C/ctDflx6r/lHTsH+dJNlEHnrGqgbayv4GfwXdP5W3MY5gyss+w/ifv2pj9dE25FhC6 Mtalf8/oZQR3N+EtfoiQGQo40Tm9KT3+H8mQouIs1UpHKrfj7L6MDwo845+48XF4efIr TfXw== 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=mU5nrMJUcdBgg7urSanDBiC3erPWRLTNvV05ryWEl48=; b=lOaM6NGvvnbD8erPq9ZhuO2C/pxgcAZTZG11UeJVyVaNIlIlRXSVLKAaZyO8z/U+4u vru/usSTLvz4GRofInoRszVP5eCqxlvF5/XLsW2KEOsLepneuRBxBFH5jo5CR4uXgnY4 B31t/ZFmUEcnceGtSuz3wOerXKRHpx9dNtVEFlQ/5B4nORPTw4KmJxmTHtaPJWcxA7Kq pAApCbox9BzPwX+kacjUmqeVSWmZofx3RyjN0FKQ+G+EBbM6UzYAeqNelC3a5gmnExGu e1nmNkpdkuXT9zNP6dml3FBKUrI5m3En8Z9caAqoNREEycHSJ0eQizFYAGbafadLf9yB 8kMA== X-Gm-Message-State: AOAM532YLkM2f4iqceL+74Oh2hqiAmIutMZjyngRUcDzvHR6D30sjPQH PF60/02liiBW84alegoiz590qXy0la8= X-Google-Smtp-Source: ABdhPJwziYH7gM61TfqSBh4pNfLgdMNl6xd6SwwXx/pgFz7jclBowKIwUr4dG1dBIv3BIXzV8phhFw== X-Received: by 2002:a05:6402:18de:: with SMTP id x30mr9218410edy.351.1626375252528; Thu, 15 Jul 2021 11:54:12 -0700 (PDT) Received: from workstation.lan.schwierd.dedyn.io (i5E860616.versanet.de. [94.134.6.22]) by smtp.gmail.com with ESMTPSA id t17sm2803486edv.75.2021.07.15.11.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 11:54:11 -0700 (PDT) From: Daniel Schwierzeck To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Stefan Roese , Daniel Schwierzeck Subject: [PATCH v2 1/6] dm: pci: add option to map virtual system memory base address Date: Thu, 15 Jul 2021 20:53:56 +0200 Message-Id: <20210715185401.301211-2-daniel.schwierzeck@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715185401.301211-1-daniel.schwierzeck@gmail.com> References: <20210706142222.497569-1-daniel.schwierzeck@gmail.com> <20210715185401.301211-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 Reviewed-by: Stefan Roese --- (no changes since v1) 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 517cf956ea..c49cb6eac9 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 cb9aa81835..110a12b94b 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1003,10 +1003,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