From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755298AbcCWM1B (ORCPT ); Wed, 23 Mar 2016 08:27:01 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:53276 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754993AbcCWM0v (ORCPT ); Wed, 23 Mar 2016 08:26:51 -0400 From: Arnd Bergmann To: Catalin Marinas Cc: Kefeng Wang , linux-pci@vger.kernel.org, linux-arm-kernel , Lorenzo.Pieralisi@arm.com, Gabriele Paoloni , Linuxarm , linux-kernel@vger.kernel.org, Zhou Wang Subject: Re: Question about PCI I/O space in ARM64 Date: Wed, 23 Mar 2016 13:26:09 +0100 Message-ID: <8793380.nuVa09lFue@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20160323101840.GA21390@e104818-lin.cambridge.arm.com> References: <56F209A9.4040304@huawei.com> <20160323101840.GA21390@e104818-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:7ydEGEfzMAVjcYHdXUOZKYPNK0IZt0aPUHjPDLBOR/hDMbrJicV 7axjs6XwkQLqMfIZ3CDf+9j4i1lhVdb8elvO8Nqzk0wrAW6cJrD/HoJ6LqQHRPMMyEOMPj9 OG4mCG016MKSro7ZDRouf75WXj848P2P2tcziHuWcC9Xn4GLO9DRcIJ5e5S2tQdJazPVVmD XWqdBM8f5WhK7B6NKUqLA== X-UI-Out-Filterresults: notjunk:1;V01:K0:0nm71ceBGx8=:czfT6LXyBQspUXzsEd8SO2 MFKrIq6mIsvCIQweRaAoBw/PgEFncD3bExO9/f8BzUHe+oBdUI9FlxboLk2BEiMlQuVOhx/Hl aXtgQH7qSTReokKVnVFy04vTIQ0jksw27Vn1ynyr4W3VfKEsbzv15b/PTgD9DpgzTSia4bt9h fUr2pIvP1iqRbHehyIoRl0g2funz+hcYx8j262Zqj2CbZ/PGdJw6HfUEGhgg+HtVNtES/bhol LMmcmcqmp9PkVBpEQ2D+5onzsWPMMLbpgkIMFJ5I/q/sm+JAD2o1HdBj7bOSj64IxOAVTYj4U zS0hrw2xU2jMnh5bcxNnlgCE480Y2fRTlHuaXFGIqzmHUr35Vxqxo0lJMioQv6BGntTS15C8h kyb7KdmoiY8R7Hk/jERuHFwEmcuHkYoz+H18ejSb/ZPcHesmvOwmqpphk9y+fDA8De+/zT4M2 Oogi8OyzcO67p+Bpdq9+JY98GfG/HvOa6XUoN3ngG282F7aTVUEQQtrpbBgLjqZTEyMDtIgwY v6jU1bBqUlpRl8bFZKg8fVwg/X548Z66ZkMu2/7RB041as80ZL+rhJj4A6IWzHs5UAcdd+ugF PkxTlsPycVaJysr6IZZJybm9rY3vFAeP4HZQOslwBoPvAbjtcHLjGPTAVEVlQUBi4plQMQl6B YB5Vq8EZgUYNiWbdtVtDI1ZvVv51+Q2JiYZqjjiGoARfpSszd4F79RgTjkIBSfZPJmKKwWFvr 3iZdblftDrWLPY2A Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 23 March 2016 10:18:40 Catalin Marinas wrote: > On Wed, Mar 23, 2016 at 11:12:41AM +0800, Kefeng Wang wrote: > > If no pci, the PCI I/O space(16M) is mapped into an irrelevant mem space(right ?), > > No. It is not mapped at all. > > > not a right IO space, > > that is, no one call pci_remap_iospace() to remap the memory mapped I/O space, once driver > > like f71805f loaded, write value to IO space(see f71805f_init->f71805f_find->superio_enter->outb), > > we met following oops, > > ------------------------ > > Unable to handle kernel paging request at virtual address ffffffbffee0002e > > pgd = ffffffc1d68d4000 > > [ffffffbffee0002e] *pgd=0000000000000000, *pud=0000000000000000 > > Internal error: Oops: 94000046 [#1] PREEMPT SMP > > Modules linked in: f71805f(+) hwmon > > CPU: 3 PID: 1659 Comm: insmod Not tainted 4.5.0+ #88 > > Hardware name: linux,dummy-virt (DT) > > task: ffffffc1f6665400 ti: ffffffc1d6418000 task.ti: ffffffc1d6418000 > > PC is at f71805f_find+0x6c/0x358 [f71805f] > > ------------------------ > > That's caused by not having a mapped PCI I/O space. > > > I am not clear about PCI I/O, but if this is indeed a bug, how to solve this issue, > > any advice will be appreciated. > > You need a PCI host controller driver (e.g. > drivers/pci/host/pci-host-generic.c) and corresponding bindings in DT or > ACPI. I think getting an Oops is not the best behavior though, it would be nice if that could be improved in some way. Ideally, each driver that accesses PCI I/O space would call request_region() before doing so, and it would be good if that call could be made to return an error when asked about an address that has not been mapped. I see that ioport_resource gets initialized to the {0, IO_SPACE_LIMIT} range. If we could change it so that pci_remap_iospace() hooks up to ioport_resource and extends it whenever something gets mapped there up to IO_SPACE_LIMIT, we can change the default range to {0,0}, which would fail for any request_region call before the first pci_remap_iospace. This won't help for the specific f71805f driver example, because that does not call request_region(), but we can treat that as a driver bug and fix it. Arnd