From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933363AbcDEPpP (ORCPT ); Tue, 5 Apr 2016 11:45:15 -0400 Received: from p3plsmtps2ded02.prod.phx3.secureserver.net ([208.109.80.59]:33890 "EHLO p3plsmtps2ded02.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933302AbcDEPpM (ORCPT ); Tue, 5 Apr 2016 11:45:12 -0400 x-originating-ip: 72.167.245.219 From: "K. Y. Srinivasan" To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com Cc: Jake Oshins , "K. Y. Srinivasan" Subject: [PATCH 5/7] drivers:hv: Track allocations of children of hv_vmbus in private resource tree Date: Tue, 5 Apr 2016 10:22:54 -0700 Message-Id: <1459876976-15860-5-git-send-email-kys@microsoft.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1459876976-15860-1-git-send-email-kys@microsoft.com> References: <1459876777-15772-1-git-send-email-kys@microsoft.com> <1459876976-15860-1-git-send-email-kys@microsoft.com> X-CMAE-Envelope: MS4wfBwJiFyyI2TZeBW8II3/pCRU0d7DF4f7A9O7R3tvVNElzsNeIpn90hpvyS23SAvJRD9GPHMoxrTEz6TwtFdMdhaVlZyuAoUb7CyVa74Y1PmbQ9aLtgeD 6tJxYIHivt+esAMjBxDjH880tB9iPCfiUVgZkceS4NHEWxkPi93/RKR4SrKPDlSeo+tkVlN6Qy561pwU4KgDjK2X9aDT3F3YocKfaYQE9KrBpzJtC4ijIvzW 7q3jP5ADrPdcXrz7X6cANY7/sGba114HV1WvF6EIH4l9S6Wco60yeg18E1QnCDn4NzsS2zFVtX35jPX2QXAMCopCw0KYMk6xJY0MRloyL5hdt/+pkp/9OGdt 9rMLbAhjW+tDx5yfoOxA0EZpkYdZNSYsD9SjOmSKbb+ShKNJRR4VCE03AZkkSRWmc5lnhRVqwK4IXubHnKoJGqC6aus9CA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jake Oshins This patch changes vmbus_allocate_mmio() and vmbus_free_mmio() so that when child paravirtual devices allocate memory-mapped I/O space, they allocate it privately from a resource tree pointed at by hyperv_mmio and also by the public resource tree iomem_resource. This allows the region to be marked as "busy" in the private tree, but a "bridge window" in the public tree, guaranteeing that no two bridge windows will overlap each other but while also allowing the PCI device children of the bridge windows to overlap that window. One might conclude that this belongs in the pnp layer, rather than in this driver. Rafael Wysocki, the maintainter of the pnp layer, has previously asked that we not modify the pnp layer as it is considered deprecated. This patch is thus essentially a workaround. Signed-off-by: Jake Oshins Signed-off-by: K. Y. Srinivasan --- Greg, please apply this to the 4.6 tree. drivers/hv/vmbus_drv.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 1ce47d0..dfc6149 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1128,7 +1128,7 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj, resource_size_t size, resource_size_t align, bool fb_overlap_ok) { - struct resource *iter; + struct resource *iter, *shadow; resource_size_t range_min, range_max, start, local_min, local_max; const char *dev_n = dev_name(&device_obj->device); u32 fb_end = screen_info.lfb_base + (screen_info.lfb_size << 1); @@ -1170,12 +1170,22 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj, start = (local_min + align - 1) & ~(align - 1); for (; start + size - 1 <= local_max; start += align) { + shadow = __request_region(iter, start, + size, + NULL, + IORESOURCE_BUSY); + if (!shadow) + continue; + *new = request_mem_region_exclusive(start, size, dev_n); if (*new) { + shadow->name = (char *)*new; retval = 0; goto exit; } + + __release_region(iter, start, size); } } } @@ -1196,7 +1206,17 @@ EXPORT_SYMBOL_GPL(vmbus_allocate_mmio); */ void vmbus_free_mmio(resource_size_t start, resource_size_t size) { + struct resource *iter; + + down(&hyperv_mmio_lock); + for (iter = hyperv_mmio; iter; iter = iter->sibling) { + if ((iter->start >= start + size) || (iter->end <= start)) + continue; + + __release_region(iter, start, size); + } release_mem_region(start, size); + up(&hyperv_mmio_lock); } EXPORT_SYMBOL_GPL(vmbus_free_mmio); -- 1.7.4.1