From patchwork Wed Feb 28 19:24:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 130044 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp121291lja; Wed, 28 Feb 2018 11:24:43 -0800 (PST) X-Google-Smtp-Source: AH8x2253GPfepWjQL5aIlzx0rUG85NB04F7JrZwMRbNg+zDWrBgJTamyI3YYbuwUzJG/uhOqmYN3 X-Received: by 2002:a17:902:9a98:: with SMTP id w24-v6mr18597389plp.188.1519845883090; Wed, 28 Feb 2018 11:24:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519845883; cv=none; d=google.com; s=arc-20160816; b=rKlYrwlWANNoouHUnzT4p5OGGysNcX9rYXMNLz24nhFZ2qznxgJkPOPZh7iY4GwhUq CZJksxTNDhaKNDK5qLds3d9JXZczxBaXCcBmih1RRrfoYC2kf92rsImO3u7hDwQF9S/s N052GG3kUvC8HGnnHMavUOPdrm2xTpED/8MMjkP1UWuVBAnhM1+m0XMcUhthur4O8pFd v5hQMnwgJQxrqHOC/b0w7AtSViL4uD40AAoR0XLCk2GEykqVxxBBIK9ctzXegAnk4Imf INdhwNLDCJ9U70F0Z+zcQzpeEUpzCkBhBpIkf+BazHgaVR96rA/DYIQ5YoEuXhdZ0/35 puHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=Fo/eTxmS+HMi/uG9HiapVgHELCrv+3QNGu1ThGaQebQ=; b=WQNf6VKImXVKYCmItaWRPo0NAvx0b4EfzPlaxrv3KW9unDnhpcF0GNY0rGReabHXLB vljO6lkJOs2Cw/jrGOAv1i3GOGK17L8WXQJo6YRpz5QvW99QF8PAogykNGt3uStDQ8Ur WSB07PcZS37iSPnm9aIFinXBLzdWf4zgQ0BtbRHS+sbI+VUQfEo+SuCTwEjYbmQv/P4F xw65uMAUI08n9/kCb0H3gVTTf57fQp4kd2O6Myex4RIDDPKJnEgwd3E4VMYI4F871qcD fE4JUNemEFPST0AQquqcJgC37Oetvhh4oVtZVtxDadQKdd70qgPooQpSRQVTavxA7yTa x6VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Gfn8s467; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id u8-v6si1713642plm.389.2018.02.28.11.24.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 11:24:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Gfn8s467; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EB72E22352296; Wed, 28 Feb 2018 11:18:34 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7D77E21F6A6FC for ; Wed, 28 Feb 2018 11:18:33 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id k9so3611191wre.9 for ; Wed, 28 Feb 2018 11:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qJ9DfMipfGVCXlezkU0W//NSkZQ+2+pmoIBb0s86zzE=; b=Gfn8s467ZXCjwMKQNAM/25zkCodQhlwWfJxpF/C0cT5unCZ2tXQYylbHxpHC7Qknaj B/HaEnTHDJcIux9S7Q4Fwqqm7ptgFIfqk6EZgKSndbuLaozId+cp7EXt8TeGKA6jRwkM Yq6SBMyJ/RNOa8Wo5+OCv7Kf50zYEc6ZIqtUk= 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; bh=qJ9DfMipfGVCXlezkU0W//NSkZQ+2+pmoIBb0s86zzE=; b=b+svOW4G4Pjp3ztC2wSZ+CSDncu9t2D9iiwNukgUPUQgaAUIpVYYOtbpuNe9t44Mmf KSSVdviKtA9UaCV34W3pDzEI7Wp6ScvkL6aLWK/DJyoEhW/wld1O7fPo0IvQXcw/WHqx O5aT+fJ9qEJjWj1IoDF8sxNFtQzk2iyQxPgwD3jpLCnmiVE9JhnqiUDCT1VlLp8PYTaw gkJFHD/8tOMyPGMp2sab2Gq+BH5OyzTvBHj3tx3L8GKcLSIWrIIIUZt/yB8OFEBEpH6a scFfCxqQ72mXy+2hPGoX6HHRfd9cOTaszofJ7G5MV4lnlpAQV5qzEyErgB+id9nsq6Zx CwLg== X-Gm-Message-State: APf1xPAg5ImtP5cOQWSWZ5WT+nV8p2+mGSQKLFzE0qS/lwZi47+teS+p EzlPdzAPmNdCkEfxyFfJS1NjpIUO4jU= X-Received: by 10.223.177.138 with SMTP id q10mr15765137wra.132.1519845879182; Wed, 28 Feb 2018 11:24:39 -0800 (PST) Received: from localhost.localdomain ([160.163.57.8]) by smtp.gmail.com with ESMTPSA id 47sm2152312wrb.48.2018.02.28.11.24.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 11:24:38 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 28 Feb 2018 19:24:16 +0000 Message-Id: <20180228192421.17684-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180228192421.17684-1-ard.biesheuvel@linaro.org> References: <20180228192421.17684-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v2 2/7] Silicon/SynQuacer: tweak PCI I/O windows for ACPI/Linux support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The ACPI/Linux code does not cope very well with I/O BAR windows that involve type translation and address translation. In particular, the secondary I/O window we implement on SynQuacer: I/O 0x10000 ... 0x1ffff -> 0x77f00000 is misinterpreted by Linux, and results in the MMIO range starting at 0x77f10000 to be mapped for I/O port access to this range. This can be mitigated by using the same bus range for I/O port access on both RCs., i.e., [0x0 ... 0xffff]. This configuration can be represented using both DT and ACPI, and will work as expected in Linux. However, there is a downside: UEFI does not cope with I/O address translation in the generic PCI host bridge driver, and so it does not allow two regions [0x0 ... 0xffff] to be configured. Since we have plenty of I/O space, and given that nobody cares about port I/O anymore in the first place, let's shrink the UEFI view of the I/O windows until they no longer overlap. In our case, with two such windows, this means we divide the size by 2, and we end up with a window [0x0 ... 0x7fff] and one at [0x8000 ... 0xffff]. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi | 2 +- Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h | 18 +++++++++++------- Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi index 05d1673a5c2b..6eb5fd9430cb 100644 --- a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi @@ -483,7 +483,7 @@ bus-range = <0x0 0x7e>; #address-cells = <3>; #size-cells = <2>; - ranges = <0x1000000 0x00 0x00010000 0x00 0x77f00000 0x0 0x00010000>, + ranges = <0x1000000 0x00 0x00000000 0x00 0x77f00000 0x0 0x00010000>, <0x2000000 0x00 0x78000000 0x00 0x78000000 0x0 0x08000000>, <0x3000000 0x3f 0x00000000 0x3f 0x00000000 0x1 0x00000000>; diff --git a/Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h b/Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h index 2d3d5cd91be0..fea01c29088c 100644 --- a/Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h +++ b/Silicon/Socionext/SynQuacer/Include/Platform/Pcie.h @@ -23,12 +23,12 @@ #define SYNQUACER_PCI_SEG0_BUSNUM_MIN 0x0 #define SYNQUACER_PCI_SEG0_BUSNUM_MAX 0x7e +#define SYNQUACER_PCI_SEG0_BUSNUM_RANGE 0x7f #define SYNQUACER_PCI_SEG0_PORTIO_MIN 0x0 -#define SYNQUACER_PCI_SEG0_PORTIO_MAX 0xffff -#define SYNQUACER_PCI_SEG0_PORTIO_SIZE 0x10000 +#define SYNQUACER_PCI_SEG0_PORTIO_MAX 0x7fff #define SYNQUACER_PCI_SEG0_PORTIO_MEMBASE 0x67f00000 -#define SYNQUACER_PCI_SEG0_PORTIO_MEMSIZE SYNQUACER_PCI_SEG0_PORTIO_SIZE +#define SYNQUACER_PCI_SEG0_PORTIO_MEMSIZE 0x10000 #define SYNQUACER_PCI_SEG0_MMIO32_MIN 0x68000000 #define SYNQUACER_PCI_SEG0_MMIO32_MAX 0x6fffffff @@ -45,12 +45,12 @@ #define SYNQUACER_PCI_SEG1_BUSNUM_MIN 0x0 #define SYNQUACER_PCI_SEG1_BUSNUM_MAX 0x7e +#define SYNQUACER_PCI_SEG1_BUSNUM_RANGE 0x7f -#define SYNQUACER_PCI_SEG1_PORTIO_MIN 0x10000 -#define SYNQUACER_PCI_SEG1_PORTIO_MAX 0x1ffff -#define SYNQUACER_PCI_SEG1_PORTIO_SIZE 0x10000 +#define SYNQUACER_PCI_SEG1_PORTIO_MIN 0x8000 +#define SYNQUACER_PCI_SEG1_PORTIO_MAX 0xffff #define SYNQUACER_PCI_SEG1_PORTIO_MEMBASE 0x77f00000 -#define SYNQUACER_PCI_SEG1_PORTIO_MEMSIZE SYNQUACER_PCI_SEG1_PORTIO_SIZE +#define SYNQUACER_PCI_SEG1_PORTIO_MEMSIZE 0x10000 #define SYNQUACER_PCI_SEG1_MMIO32_MIN 0x78000000 #define SYNQUACER_PCI_SEG1_MMIO32_MAX 0x7fffffff @@ -65,4 +65,8 @@ #define SYNQUACER_PCI_SLOT1_LOCATION SYNQUACER_PCI_LOCATION(0, 1, 3) #define SYNQUACER_PCI_SLOT2_LOCATION SYNQUACER_PCI_LOCATION(0, 1, 7) +#define SYNQUACER_PCI_OS_IO_BASE SYNQUACER_PCI_SEG0_PORTIO_MIN +#define SYNQUACER_PCI_OS_IO_LIMIT SYNQUACER_PCI_SEG1_PORTIO_MAX +#define SYNQUACER_PCI_OS_IO_RANGE SYNQUACER_PCI_SEG1_PORTIO_MEMSIZE + #endif diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c index e4679543cc66..6a3b32f6ca55 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c @@ -348,8 +348,8 @@ PciInitControllerPost ( // Region 3: port I/O range ConfigureWindow (DbiBase, 3, IoMemBase, - RootBridge->Io.Base, - RootBridge->Io.Limit - RootBridge->Io.Base + 1, + SYNQUACER_PCI_OS_IO_BASE, + SYNQUACER_PCI_OS_IO_RANGE, IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_IO, 0);