Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96710C433EF for ; Tue, 2 Nov 2021 10:45:07 +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 0450960F5A for ; Tue, 2 Nov 2021 10:45:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0450960F5A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6F262835D4; Tue, 2 Nov 2021 11:45:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1635849905; bh=CQ+GvgfBlrgM4K1eM8u1LdhIAKd0l/WKqw4do18qG60=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LZmujb4L5riLKz8gPkZ4qucZ8sTMk9u/C0S5cfvUkiGQRAyrE/xZoeUHC5tEwBJr6 k3y9ySKxTlxhiArWqwmXQIl+Tvhe7yH7NItnM9VkHIakuVgcp/KC2cORUU5FS9QfBr qmosf7ZMODn/e76XssYe4oUmmV+Zl+qDkywvfRotOx5cd6hGF2e1S5W4hoEB+LsNEm zj2ICmKOFZ/eOeGL+QJQNWNEQJ+AcRug1FTbBWNHe+2986F2pv5Sk9qHYdBjX6+m7K 3NoWx3+Xl1z25Az7wQfwMOtS0ljtlvWpOS21nQMv6DnrjKMq+oluqG468e/Lnh81JA 9VSW5KYKo7EDg== Received: by phobos.denx.de (Postfix, from userid 109) id CCEA382D78; Tue, 2 Nov 2021 11:45:01 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ADFBB815A8 for ; Tue, 2 Nov 2021 11:44:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4Hk63t4PhczQkDy; Tue, 2 Nov 2021 11:44:58 +0100 (CET) Subject: Re: [PATCH 1/8] pci: pci_mvebu: Fix write_config() with PCI_SIZE_8 or PCI_SIZE_16 To: =?UTF-8?Q?Pali_Roh=c3=a1r?= Cc: =?UTF-8?Q?Marek_Beh=c3=ban?= , u-boot@lists.denx.de References: <20211022142215.26484-1-pali@kernel.org> <20211022142215.26484-2-pali@kernel.org> From: Stefan Roese Message-ID: <33e81038-b1cc-fa3d-2f5e-437de9ba7516@denx.de> Date: Tue, 2 Nov 2021 11:44:55 +0100 MIME-Version: 1.0 In-Reply-To: <20211022142215.26484-2-pali@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8D6AD188C 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 22.10.21 16:22, Pali Rohár wrote: > Current implementation of write_config() is broken for PCI_SIZE_8 or > PCI_SIZE_16 as it always uses writel(), which means that write operation > is always 32-bit, so upper 24 bits for PCI_SIZE_8 and upper 16 bits for > PCI_SIZE_16 are cleared. > > Fix this by using writeb() and writew(), respectively. > > Signed-off-by: Pali Rohár > Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Thanks, Stefan > --- > drivers/pci/pci_mvebu.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c > index 0c1d7cd770f1..8175511514ab 100644 > --- a/drivers/pci/pci_mvebu.c > +++ b/drivers/pci/pci_mvebu.c > @@ -211,8 +211,19 @@ static int mvebu_pcie_write_config(struct udevice *bus, pci_dev_t bdf, > writel(PCIE_CONF_ADDR(bdf, offset), pcie->base + PCIE_CONF_ADDR_OFF); > > /* write data */ > - data = pci_conv_size_to_32(0, value, offset, size); > - writel(data, pcie->base + PCIE_CONF_DATA_OFF); > + switch (size) { > + case PCI_SIZE_8: > + writeb(value, pcie->base + PCIE_CONF_DATA_OFF + (offset & 3)); > + break; > + case PCI_SIZE_16: > + writew(value, pcie->base + PCIE_CONF_DATA_OFF + (offset & 2)); > + break; > + case PCI_SIZE_32: > + writel(value, pcie->base + PCIE_CONF_DATA_OFF); > + break; > + default: > + return -EINVAL; > + } > > return 0; > } > Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de