From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753059AbcGDHhu (ORCPT ); Mon, 4 Jul 2016 03:37:50 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:27205 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750898AbcGDHhs (ORCPT ); Mon, 4 Jul 2016 03:37:48 -0400 Subject: Re: [PATCH] Exchange the Assignments of `MEMORYs' and `CFGs/IOs' in Designware PCIe Driver To: Pratyush Anand References: <1467100302-221983-1-git-send-email-zhaonenglong@hisilicon.com> CC: "jingoohan1@gmail.com" , "bhelgaas@google.com" , Linuxarm , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , Zhanweitao From: "dongbo (E)" Message-ID: Date: Mon, 4 Jul 2016 15:36:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.63.194.120] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.577A1245.00C5,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1c0d8d007fc7bc91a806edefba45ade7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/7/3 23:27, Pratyush Anand wrote: > On Tue, Jun 28, 2016 at 1:42 PM, dongbo (E) wrote: >> >> From: Dong Bo >> >> In designware PCIe driver, the iatu0 is used for both CFG and IO accesses. >> When sending CFGs to peripherals (e.g. lspci), iatu0 frequently switches >> between CFG and IO alternatively. >> >> A MEMORY probably be sent as an IOs by mistake. Considering the following >> configurations: >> MEMORY -> BASE_ADDR: 0xb4100000, LIMIT: 0xb4100FFF, TYPE=mem >> CFG -> BASE_ADDR: 0xb4000000, LIMIT: 0xb4000FFF, TYPE=cfg >> IO -> BASE_ADDR: 0xFFFFFFFF, LIMIT: 0xFFFFFFFE, TYPE=io >> >> Suppose PCIe has just completed a CFG access, to switch back to IO, it set >> the BASE_ADDR to 0xFFFFFFFF, LIMIT 0xFFFFFFFE and TYPE to io. When another >> CFG comes, the BASE_ADDR is set to 0xb4000000 to switch to CFG. At this >> moment, a MEMORY access shows up, since it matches with iatu0 >> (due to 0xb4000000 <= MEMORY BASE_ADDR <= MEMORY LIMIE <= 0xFFFFFFF), it >> is treated as an IO access by mistake, then sent to perpheral. >> >> This patch fixes the problem by exchanging the assignments of `MEMORYs' >> and `CFGs/IOs', which assigning MEMEORYs to iatu0, CFGs and IOs to iatu1. > > > Had a re-thought on it. While it will fix wrong memory access in your > case, it can still cause issues with IO access for some other > platform. > > Can you please test [1] and check it that works for you. You will need > to define num-viewport in your device tree file. > > ~Pratyush > > [1] https://github.com/pratyushanand/linux/commit/131b83ea7db0834d77ee5df65c6696bccbf8a1ce > > . > Checked, it works for us. I think it would be better to exchange the assignments of MEMORYs and CFGs/IOs when num_viewports <= 2, cause it fixes wrong memory access. As you mentioned, other corner point for failure is still there while there are only two viewports. It seems that there is not a perfect solution. Best Regards Dong Bo