Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp482579ybi; Wed, 19 Jun 2019 02:54:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCuEHJ6iQQ0Yz6yaCAnUobKWUpU5CZpWiHn1z0nIq0gXstmSnTNpjRnwEyoY+6aFLAE5AA X-Received: by 2002:a63:214a:: with SMTP id s10mr6945636pgm.13.1560938065233; Wed, 19 Jun 2019 02:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560938065; cv=none; d=google.com; s=arc-20160816; b=a/81A9n8uurxup2M7z2uJ+PS0rht0/7yK45L8Ns9fA0doH+47GHhcMPLXAdm6s8awy yKQIbd+C2GfbGrSwl5K9TyOrH7dr+kDw+v3oB33z1HXk2GCzPzHOfsTGLtI2NUEqif3g pQTiS6vYG9L+xxwlKhZQ0ph2rH33v4hPDKRTqZiESOVjKMwcd2ty9MVoBXo217XWGpus No73WfX+KhsKoja7ipkv5OgWzHUdHdzfa78G3Vn/K+SYPfAOP8tS2MchEz4wttnCon67 Im+FKZ24TUzgRhkEnJt/lTYHJau5d8YqKHsmB2n6qZ6AJVsty3R1EvUUNdz1DgBm4r7Q M3TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=9sg7O4CDkwcLpq9cKRWYNT62FiFk6KD/1kTrrD7ixUE=; b=HewqTE9leLftefFcbqae9UO114/OOLmjps6Rt/QaClSxrC3k+VPkTx8x9rA0JaZZUJ Pz9B+LlSo74qBkROC/bcspz0vSwmann1l/rMdFWmzzMWqvVIGCc10GUG3uHmSIfXCOX1 sSlhL7bZUVKgvGb63UOP1HgV6MrHNGcNCs9adVAK/FpYUli1zOxvshaOdYEspDoVtXwP 6qHnHCgi20YD73wQda4IsjB1fe/Zv+wxmaY1unhw2jkSS/fB6Q5YInIUGb2/ov6quMv9 zb8OjtWAWfIh4uJtp6LDw4j6f/3OQLIg4T8++4a1lLNnazTDx+bizgiEJ1k4lwaKBRd3 NqVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si941588pju.25.2019.06.19.02.54.08; Wed, 19 Jun 2019 02:54:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731565AbfFSJxk (ORCPT + 99 others); Wed, 19 Jun 2019 05:53:40 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:46688 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727068AbfFSJxj (ORCPT ); Wed, 19 Jun 2019 05:53:39 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 54310F0CF54E2EF2F43D; Wed, 19 Jun 2019 17:53:37 +0800 (CST) Received: from [127.0.0.1] (10.202.227.238) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Wed, 19 Jun 2019 17:53:28 +0800 Subject: PCI host bridge hotplug test question (was Re: [PATCH v2] bus: hisi_lpc: Don't use devm_kzalloc() to allocate logical PIO range) To: Bjorn Helgaas References: <1560507893-42553-1-git-send-email-john.garry@huawei.com> <82840955-6365-0b95-6d69-8a2f7c7880af@huawei.com> <9e8b6971-3189-9d4b-de9a-ff09f859f4f6@huawei.com> <539835d3-770c-285c-0c49-ae15ceaa3079@huawei.com> CC: , , , "Linux Kernel Mailing List" , Joe Perches , Linux PCI , "Rafael J. Wysocki" , Mika Westerberg From: John Garry Message-ID: <4b24fd36-e716-7c5e-31cc-13da727802e7@huawei.com> Date: Wed, 19 Jun 2019 10:53:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.238] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/06/2019 18:50, Bjorn Helgaas wrote: > [+cc Rafael, Mika, Jiang, linux-pci for ACPI host bridge hotplug test question] > Resend with bouncing addresses removed/fixed > On Tue, Jun 18, 2019 at 3:44 AM John Garry wrote: > >>>>> Could you just move the logic_pio_register_range() call farther down >>>>> in hisi_lpc_probe()? IIUC, once logic_pio_register_range() returns, >>>>> an inb() with the right port number will try to access that port, so >>>>> we should be prepared for that, i.e., maybe this in the wrong order to >>>>> begin with? >>>> >>>> No, unfortunately we can't. The reason is that we need the logical PIO >>>> base for that range before we enumerate the children of that host. We >>>> need that base address for "translating" the child bus addresses to >>>> logical PIO addresses. > >>> Ah, yeah, that makes sense. I think. We do assume that we know all >>> the MMIO and I/O port translations before enumerating devices. It's >>> *conceivable* that could be changed someday since we don't actually >>> need the translations until a driver claims the device, >> >> We actually need them before a driver claims the device. >> >> The reason is that when we create that child platform device we set the >> device's IORESOURCE_IO resources according to the translated logic PIO >> addresses, and not the host bus address. This is what makes the host >> transparent to the child device driver. > > I think you need it to set pdev->resource[], which is currently done > long before the driver claims the device (though one could imagine > delaying it even as far as pci_enable_device()-time). I don't think > the translation is actually *used* until the driver claims the device > because only the driver knows how to do any inb/outb to the device. > > But of course, that's all speculative and doesn't change what you need > to do now. The current code assumes we know the translations during > enumeration, so you need to do the logic_pio registration before > enumerating. > >>> and it would >>> gain some flexibility if we didn't have to program the host bridge >>> windows until we know how much space is required. But I don't see >>> that happening anytime soon. > >> My problem is that I need to ensure that the new logical PIO unregister >> function works ok for hot-pluggable host bridges. I need to get some way >> to test this. Advice? > Hi Bjorn, > Good question. The ACPI host bridge driver (drivers/acpi/pci_root.c) > should support hotplug, but I'm not sure if there's a manual way to > trigger it via sysfs or something similar. If there is, and you have > a machine with more than one host bridge, you might be able to remove > one that leads to non-essential devices. > For one of our earlier boards I don't think that it had any essential devices on the host bridge. But I need to find out about possibility of removal. Hmmm. > Bjorn > Further to the topic of supporting hotplug and unregistering IO port regions, we don't even release IO port regions in the error path of PCI host enumeration. We have pci_register_io_range(), but no unregister equivalent. Looking at the history here, pci_register_io_range() was originally in OF code. And in the OF code, calling pci_register_io_range() is a side-effect of parsing the device tree. As such, I can see why there was no unregister function. It would be worth noting this discussion, where the same was mentioned: https://lore.kernel.org/linux-pci/20180403140410.GE27789@ulmo/ The tegra PCI host probe can defer, but, since there is no tidy-up of pci_register_io_range() when deferring, we need to ensure that the port IO management code can handle re-attempts to register the same range. It looks like this can be cleaned up also. Thanks, John > . >