From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 F39E1C7618F for ; Mon, 15 Jul 2019 15:10:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA3452054F for ; Mon, 15 Jul 2019 15:10:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TCiHF2/K"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="lHtyRcsc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA3452054F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FGNsKEcRXKaZMgV+KhxfJap52F20ng5oIEI2MwH5J+M=; b=TCiHF2/KRgyh8h CCUlHL0GvhfNc1bsGqaOl2PnW/pqWjJRrnNEiH3ODam08e6lUr9aG7No1OEHPcIolQXV6dXtHNzma e/oDTkWHTj1LFr6slUNXnUqMAHWLRiGgrcS/B4Zj/ufRMAPuiJrS3BzaT/QnBlVMUYZln3pGvxO5U j9ajZmKLdMHALtUqdECJNRFk6J/HsWem0WM1mK/weTxnI2Eoi4fGGYWOpkf3LbZA53DC+YKNdJv77 hro00GSrmMwIujnIM7XXGC4s1iItf0aT9xGF1W8eroukyrfzKcP0qbJJAUZgDLJArZKaY1+BGTqPw 0PPvoJjIHQh8bYSHWN2g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hn2ca-0005GV-6i; Mon, 15 Jul 2019 15:10:32 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hn2cW-0005FU-OT for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2019 15:10:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7d9E/+uS/LbEKMv/pk7fdGoaJqxaCi45qzlBCe6X+y4=; b=lHtyRcscbEO/YUttpfQ+8XJXr SgvcFo5dej0fLuJGCyAUQXfY8b7qYZk7MA6Ry/NOsaCVP3Seq9QZlTyxUxFNY2xCJisicRvGtqVrB i1H/ucs5/MDbD49uoiiQZJ/nYSi4yQ37Kq1Pp5EQLu9WpbxAsJ1FfywnHKzJQ+Qg5kWZay77jQM+l kwTdjJRNzEzwarQKzBLxMa/1Xocfi88NjsQEQXFGnvis2ZfUkrgKMB40yIxya+AmzwX2WgTo0S/4W bSRDMckeCH7L3Y7eAR0R0y/WKu90pE3bnZj935+9oie6ejVn80D1rLQOTUFamgZsdHw30JnP7sqag wKfX3hLwg==; Received: from shell.armlinux.org.uk ([2001:4d48:ad52:3201:5054:ff:fe00:4ec]:59426) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hn2cO-0005fa-A5; Mon, 15 Jul 2019 16:10:20 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.89) (envelope-from ) id 1hn2cK-0008SY-Ik; Mon, 15 Jul 2019 16:10:16 +0100 Date: Mon, 15 Jul 2019 16:10:16 +0100 From: Russell King - ARM Linux admin To: Thomas Petazzoni Subject: Re: [PATCH] PCI: aardvark: fix big endian support Message-ID: <20190715151016.6amymuikizmmmsph@shell.armlinux.org.uk> References: <1563200122-8323-1-git-send-email-jaz@semihalf.com> <20190715170840.326acd73@windsurf> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190715170840.326acd73@windsurf> User-Agent: NeoMutt/20170113 (1.7.2) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190715_081028_807231_DC375C8F X-CRM114-Status: GOOD ( 19.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, Grzegorz Jaszczyk , linux-pci@vger.kernel.org, bhelgaas@google.com, mw@semihalf.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jul 15, 2019 at 05:08:40PM +0200, Thomas Petazzoni wrote: > Hello Grzegorz, > > Thanks for this work. I indeed never tested this code on BE platforms, > and it is very possible that I overlooked endianness issues, so thanks > for having a look at this and proposing some patches. See some > questions/comments below. > > On Mon, 15 Jul 2019 16:15:22 +0200 > Grzegorz Jaszczyk wrote: > > > Initialise every not-byte wide fields of emulated pci bridge config > > space with proper cpu_to_le* macro. This is required since the structure > > describing config space of emulated bridge assumes little-endian > > convention. > > > > Signed-off-by: Grzegorz Jaszczyk > > --- > > drivers/pci/controller/pci-aardvark.c | 10 ++++++---- > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c > > index 134e030..06a12749 100644 > > --- a/drivers/pci/controller/pci-aardvark.c > > +++ b/drivers/pci/controller/pci-aardvark.c > > @@ -479,8 +479,10 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie) > > { > > struct pci_bridge_emul *bridge = &pcie->bridge; > > > > - bridge->conf.vendor = advk_readl(pcie, PCIE_CORE_DEV_ID_REG) & 0xffff; > > - bridge->conf.device = advk_readl(pcie, PCIE_CORE_DEV_ID_REG) >> 16; > > + bridge->conf.vendor = > > + cpu_to_le16(advk_readl(pcie, PCIE_CORE_DEV_ID_REG) & 0xffff); > > + bridge->conf.device = > > + cpu_to_le16(advk_readl(pcie, PCIE_CORE_DEV_ID_REG) >> 16); > > bridge->conf.class_revision = > > advk_readl(pcie, PCIE_CORE_DEV_REV_REG) & 0xff; > > So conf.vendor and conf.device and stored as little-endian in the > emulated config address space, but conf.class_revision is stored in the > CPU endianness ? > > > > > @@ -489,8 +491,8 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie) > > bridge->conf.iolimit = PCI_IO_RANGE_TYPE_32; > > > > > /* Support 64 bits memory pref */ > > - bridge->conf.pref_mem_base = PCI_PREF_RANGE_TYPE_64; > > - bridge->conf.pref_mem_limit = PCI_PREF_RANGE_TYPE_64; > > + bridge->conf.pref_mem_base = cpu_to_le16(PCI_PREF_RANGE_TYPE_64); > > + bridge->conf.pref_mem_limit = cpu_to_le16(PCI_PREF_RANGE_TYPE_64); > > Same here: why are conf.pref_mem_{base,limit} converted to LE, but not > conf.iolimit ? > > Also, the advk_pci_bridge_emul_pcie_conf_read() and > advk_pci_bridge_emul_pcie_conf_write() return values that are in the > CPU endianness. > > Am I missing something ? Getting the types correct and then using Sparse to validate the code will help to identify issues exactly like this. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel