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::144; helo=mail-it1-x144.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x144.google.com (mail-it1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 710FF21191F46 for ; Mon, 19 Nov 2018 10:22:28 -0800 (PST) Received: by mail-it1-x144.google.com with SMTP id h65so5633048ith.3 for ; Mon, 19 Nov 2018 10:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=shipfckPqGX9T2gWHr9s6tfSHASQxJ5lPi8071zWg7A=; b=Z8Wrz+24TRmlypF4e34yRM8CrI/qUs1CRHju2j7ktjJAzNVVss87zLo9+/rQkuoR1c qLUBMvJuNQyhrl2ZHobKs1qFpCUfQutfjQBU67M+c3+xitN0tydQgJnkv1ph2hB+8LKg Omd5aKviGQsB5SYYiMkbN4lepC/Azdx8reHjE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=shipfckPqGX9T2gWHr9s6tfSHASQxJ5lPi8071zWg7A=; b=s5JoFNRBsIPRUWbzFVCvUhv/DEJ/SOyRFOLGt/5OUCuSPPYex9cWKFLb2sOBwh0bgH UyZVosJgxTYC8UM3bjPL1HOLDatmnRhT/4jNhNIk76nnIOI0Ne1Utu+WrVfTdUX8u86o gFbdje9CJ5kmIzXQ2fJQJcmPsgRJqxHIjQorYWJqRX9Ez+h1pRBmQGmVLVUzImMNOK8r iPaECl9Vrv0kDAqU19kB+FcLMLlRattDsOJnkiQlkuxqyZiunRsC6+FjMfoE3Kt0V6Hf yWNmsZ4KNnECj//iq0IevCMzgDSiUYIKAhZH5dm7qRQ6ksxYqc4rZVQJlRfl8ghlrl8M +MUA== X-Gm-Message-State: AGRZ1gKnrcdCNrKYw5lFRZ3qEOKSSywpXDYqywag7S/o1a82VKitt/Tm +2E4/DTKlDvN8hJcN5ekgp+68vDENtIiS8TNpTf4SQ== X-Google-Smtp-Source: AJdET5fJJaiXvVpgio+FdWBal3EFadaW/B8OvLKNI9ysS5FXHk2feMdp9HnG2LQLmbAsZjFn2M0ht2/aWLjZsJZwu5E= X-Received: by 2002:a02:914c:: with SMTP id b12-v6mr19310152jag.2.1542651747693; Mon, 19 Nov 2018 10:22:27 -0800 (PST) MIME-Version: 1.0 References: <20181109075848.12029-1-ard.biesheuvel@linaro.org> <20181109133415.z75x5qg2dgd4egw3@bivouac.eciton.net> In-Reply-To: <20181109133415.z75x5qg2dgd4egw3@bivouac.eciton.net> From: Ard Biesheuvel Date: Mon, 19 Nov 2018 10:22:16 -0800 Message-ID: To: Leif Lindholm Cc: "edk2-devel@lists.01.org" Subject: Re: [PATCH v2 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: Mon, 19 Nov 2018 18:22:28 -0000 Content-Type: text/plain; charset="UTF-8" On Fri, 9 Nov 2018 at 05:34, Leif Lindholm wrote: > > > On Fri, Nov 09, 2018 at 08:58:48AM +0100, Ard Biesheuvel wrote: > > 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 > > Much neater, thank you. > Reviewed-by: Leif Lindholm > Thanks. Pushed as 91b0299223a619cfec05a638f2c4197266d3cf1e > > --- > > v2: use helper function and temp vars > > > > Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c | 62 ++++++++++++-------- > > 1 file changed, 37 insertions(+), 26 deletions(-) > > > > diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c > > index 736b20cd5129..049657231cab 100644 > > --- a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c > > +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerPciCpuIo2Dxe/SynQuacerPciCpuIo2Dxe.c > > @@ -354,6 +354,37 @@ CpuMemoryServiceWrite ( > > return EFI_SUCCESS; > > } > > > > +STATIC > > +EFI_STATUS > > +TranslateIoAddress ( > > + IN OUT UINT64 *Address > > + ) > > +{ > > + UINT64 Start; > > + UINT64 End; > > + UINT64 Shift; > > + > > + Start = SYNQUACER_PCI_SEG0_PORTIO_MIN + SYNQUACER_PCI_SEG0_PORTIO_OFFSET; > > + End = SYNQUACER_PCI_SEG0_PORTIO_MAX + SYNQUACER_PCI_SEG0_PORTIO_OFFSET; > > + Shift = SYNQUACER_PCI_SEG0_PORTIO_MEMBASE - SYNQUACER_PCI_SEG0_PORTIO_OFFSET; > > + > > + if (*Address >= Start && *Address <= End) { > > + *Address += Shift; > > + return EFI_SUCCESS; > > + } > > + > > + Start = SYNQUACER_PCI_SEG1_PORTIO_MIN + SYNQUACER_PCI_SEG1_PORTIO_OFFSET; > > + End = SYNQUACER_PCI_SEG1_PORTIO_MAX + SYNQUACER_PCI_SEG1_PORTIO_OFFSET; > > + Shift = SYNQUACER_PCI_SEG1_PORTIO_MEMBASE - SYNQUACER_PCI_SEG1_PORTIO_OFFSET; > > + > > + if (*Address >= Start && *Address <= End) { > > + *Address += Shift; > > + return EFI_SUCCESS; > > + } > > + ASSERT (FALSE); > > + return EFI_INVALID_PARAMETER; > > +} > > + > > /** > > Reads I/O registers. > > > > @@ -415,22 +445,9 @@ CpuIoServiceRead ( > > return Status; > > } > > > > - 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); > > - return EFI_INVALID_PARAMETER; > > + Status = TranslateIoAddress (&Address); > > + if (EFI_ERROR (Status)) { > > + return Status; > > } > > > > // > > @@ -518,16 +535,9 @@ 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; > > - > > - } else { > > - ASSERT (FALSE); > > - return EFI_INVALID_PARAMETER; > > + Status = TranslateIoAddress (&Address); > > + if (EFI_ERROR (Status)) { > > + return Status; > > } > > > > // > > -- > > 2.19.1 > >