From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::642; helo=mail-pl1-x642.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (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 C976A21168203 for ; Fri, 19 Oct 2018 03:48:32 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id 30-v6so15694453plb.10 for ; Fri, 19 Oct 2018 03:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=MeaxDJy/J8tGDkZCaptdy9nuVotfbiaDDMlKcexbLQ0=; b=YyUs+yJQ/5reQ4L+QiuBA58O7eRiMRTgohCbBDP1J2o/Ia769MZEMFaE3n2Dz88s1b pcX5boHNzz9hniDpvfYPaDe6JcpokK6nd9EmC91ImpSXpW2MXIrwGorHCYU20MRIxpfw sybGNGxFPVSWnScKZb6XodUqJBY1BscOAc4E0= 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; bh=MeaxDJy/J8tGDkZCaptdy9nuVotfbiaDDMlKcexbLQ0=; b=JQa9hbEIQXKmMKYuqyQuJi1mD3KjAUigg20mFNqpmL7AIfKpTC9YKjy5vay9jawnAI ObzbJW8Z5Ma42CrDW+0j6PKMuftna19C1BKVkct8WhB0y7J5VpgvU3UJRd0Isr/xPFBY 3jo8cePTTU5lrRmhzx8vu2+g90eEUgoUTTttLSzhgoAvvsnCHnBf1wWItycilFHcrtMq H5+2Q14QdzHIrr2iU6MNp2ZJow+dUlyeFRc48OzAA8OYSfk2ygHj833uPDIFNaTWUiZO TAvMFsZYTVQ61Mse0ZhsNXgocw07I7GMbuHjgSaT82MEsTLPGltR/Iuby3iZKmbLsSTZ Y2OQ== X-Gm-Message-State: ABuFfoii+1AanBvkzFjNlA74YpI+XJh1ndW5TRjkhP8U0E46oxBVnmzo gpLL6uoGkyESa/3cF1tR5o+76cjwJ7Q= X-Google-Smtp-Source: ACcGV617u13nlAczw3pGaH1wouv4/eB/2gCqcJWeeaUitd62Nu6tmf8z4Hl+UZdFYdogRYaqkwMq0g== X-Received: by 2002:a17:902:b692:: with SMTP id c18-v6mr28919884pls.191.1539946111773; Fri, 19 Oct 2018 03:48:31 -0700 (PDT) Received: from mba13.smb.com (59-115-111-251.dynamic-ip.hinet.net. [59.115.111.251]) by smtp.gmail.com with ESMTPSA id g17-v6sm35341404pfe.37.2018.10.19.03.48.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 03:48:30 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 19 Oct 2018 18:48:26 +0800 Message-Id: <20181019104826.23073-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Subject: [PATCH edk2-platforms] Silicon/SynQuacerPciCpuIo2Dxe: fix PCIe I/O translation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2018 10:48:33 -0000 Commit 9dd8190e4995 ("Silicon/SynQuacer: tweak PCI I/O windows for ACPI/Linux support") updated the min/max/offset definitions for the PCIe I/O resource windows on SynQuacer, and updated the read path of the platform's EfiCpuIo2 protocol implementation, but failed to update the write path as well, resulting in spurious errors if when attempting to write to PCIe I/O ports on PCIe RC #1, which uses translation for the I/O BAR window. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c index 736b20cd5129..e5cc3aef908d 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c @@ -518,12 +518,18 @@ CpuIoServiceWrite ( return Status; } - if ((Address >= SYNQUACER_PCI_SEG0_PORTIO_MIN) && - (Address <= SYNQUACER_PCI_SEG0_PORTIO_MAX)) { - Address += SYNQUACER_PCI_SEG0_PORTIO_MEMBASE; - } else if ((Address >= SYNQUACER_PCI_SEG1_PORTIO_MIN) && - (Address <= SYNQUACER_PCI_SEG1_PORTIO_MAX)) { - Address += SYNQUACER_PCI_SEG1_PORTIO_MEMBASE; + if ((Address >= (SYNQUACER_PCI_SEG0_PORTIO_MIN + + SYNQUACER_PCI_SEG0_PORTIO_OFFSET)) && + (Address <= (SYNQUACER_PCI_SEG0_PORTIO_MAX + + SYNQUACER_PCI_SEG0_PORTIO_OFFSET))) { + Address += SYNQUACER_PCI_SEG0_PORTIO_MEMBASE - + SYNQUACER_PCI_SEG0_PORTIO_OFFSET; + } else if ((Address >= (SYNQUACER_PCI_SEG1_PORTIO_MIN + + SYNQUACER_PCI_SEG1_PORTIO_OFFSET)) && + (Address <= (SYNQUACER_PCI_SEG1_PORTIO_MAX + + SYNQUACER_PCI_SEG1_PORTIO_OFFSET))) { + Address += SYNQUACER_PCI_SEG1_PORTIO_MEMBASE - + SYNQUACER_PCI_SEG1_PORTIO_OFFSET; } else { ASSERT (FALSE); -- 2.17.1