Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp749781iof; Mon, 6 Jun 2022 11:47:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyce40NsKwfnmoeThFjzJKU2q7ADAjHu4uRkXyx+PtN1XocR0+xOi3ngMdeqkjgJhzIoyQb X-Received: by 2002:a17:903:18d:b0:167:47f3:49 with SMTP id z13-20020a170903018d00b0016747f30049mr19369151plg.95.1654541276843; Mon, 06 Jun 2022 11:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654541276; cv=none; d=google.com; s=arc-20160816; b=YsYm3zZ04duc16o5zRXysb43S34XXRYYJt4GecSdeYIsSSJp3AohIG/V7+ue50Amn8 OpcXSRrPInM/n4a/TJJz4pD75eQOk+a7ZYhLfjJ5zTT+Xm4vDdSA5u7dATEylaUWqrGf 3wBU/vQPVEEseKEi362rxAvjp3HsbPFzZfIJz4SKiglM+oVQoctDgy+DM7eFau3I6tXw hIuzjX41ujgMk4RZ0WDmjrcWWLjkPiyvHK+TLDszSr7bY2uh0YaBcXRGYHguE+BPkf+v b2WtIrwPGnY4vzio5m+RasPEQsriv9mbaqa86ivpIVeuACAZ9RfhkbU481XwI1L8B5xj tmfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=IfD1tbvBdtS906lBuWttr7mz/0+ljzq4D8mcZKfR97o=; b=tV7hdDGGHTvjpkSUS2BMrRe6emck3NKZ99VoZdccXtU/k7vvpVj8hVtn1SB9ep/d/H ZB8RECNpHiTPpX3RE3reHGazvBjdOp8yQveZ6aojAJrTUC1E7yEtF8CrJDPRatNoX8zs pGZ/uHkK6kk7rNlAz3RsC18y7LJtc2XZcbvpx5IE60ncNm274mCE0vNxk5T1FZLkpT+v WgbzBLV4Q3zauX/QwM3s/4SmztI89DlompW2Z+fy4z70vmjNiXqNgAE6/fdR4wB54k0p SLox5EfZq84ACzdtBz/OFUOFmwpp5jzv5oKeBc0MVTkSxuBzm9l3GVGchBFF5U9lHoln xAQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YYEevPwk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r23-20020a63ec57000000b003fc52ba77desi18664082pgj.408.2022.06.06.11.47.43; Mon, 06 Jun 2022 11:47:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YYEevPwk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbiFFRxf (ORCPT + 99 others); Mon, 6 Jun 2022 13:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbiFFRxb (ORCPT ); Mon, 6 Jun 2022 13:53:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E889214558B for ; Mon, 6 Jun 2022 10:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654538009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IfD1tbvBdtS906lBuWttr7mz/0+ljzq4D8mcZKfR97o=; b=YYEevPwkaD13aUumTxQTKzojEpnjIRb+6UrDbbI4dKFYuwUx8Rv7t6Ie5XcToBYe+gLf68 11y9h8XlXuDm/4A3JnAV4x44eJFlnk5WLVKJtCsWIg45gmalq745rtbgoAeddHvN2bG+A2 9/uJXirFUwnDKjsoScWehR2eNhqgpAI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-583-qFqYIho4N0G1S-XqmJmQmA-1; Mon, 06 Jun 2022 13:53:24 -0400 X-MC-Unique: qFqYIho4N0G1S-XqmJmQmA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3A72801E6B; Mon, 6 Jun 2022 17:53:23 +0000 (UTC) Received: from [172.30.41.16] (unknown [10.22.35.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0A411121314; Mon, 6 Jun 2022 17:53:22 +0000 (UTC) Subject: [PATCH 1/2] drm/aperture: Split conflicting platform driver removal From: Alex Williamson To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch Cc: Laszlo Ersek , Laszlo Ersek , Gerd Hoffmann , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Date: Mon, 06 Jun 2022 11:53:22 -0600 Message-ID: <165453800256.3592816.10844562232615146019.stgit@omen> In-Reply-To: <165453797543.3592816.6381793341352595461.stgit@omen> References: <165453797543.3592816.6381793341352595461.stgit@omen> User-Agent: StGit/1.5.dev2+g9ce680a52bd9 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split the removal of platform drivers conflicting with PCI resources from drm_aperture_remove_conflicting_pci_framebuffers() to support both non-DRM callers and better modularity. This is intended to support the vfio-pci driver, which can acquire ownership of PCI graphics devices, but is not itself a DRM or FB driver, and therefore has no Kconfig dependencies. The remaining actions of drm_aperture_remove_conflicting_pci_framebuffers() are already exported from their respective subsystems, therefore this allows vfio-pci to separate each set of conflicts independently based on the configured features. Reported-by: Laszlo Ersek Tested-by: Laszlo Ersek Suggested-by: Gerd Hoffmann Signed-off-by: Alex Williamson --- drivers/gpu/drm/drm_aperture.c | 33 ++++++++++++++++++++++++--------- include/drm/drm_aperture.h | 2 ++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_aperture.c b/drivers/gpu/drm/drm_aperture.c index 74bd4a76b253..5b2500f7fb8b 100644 --- a/drivers/gpu/drm/drm_aperture.c +++ b/drivers/gpu/drm/drm_aperture.c @@ -313,6 +313,28 @@ int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_ } EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers); +/** + * drm_aperture_detach_platform_drivers - detach platform drivers conflicting with PCI device + * @pdev: PCI device + * + * This function detaches platform drivers with resource conflicts to the memory + * bars of the provided @pdev. + */ +void drm_aperture_detach_platform_drivers(struct pci_dev *pdev) +{ + resource_size_t base, size; + int bar; + + for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { + if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) + continue; + base = pci_resource_start(pdev, bar); + size = pci_resource_len(pdev, bar); + drm_aperture_detach_drivers(base, size); + } +} +EXPORT_SYMBOL(drm_aperture_detach_platform_drivers); + /** * drm_aperture_remove_conflicting_pci_framebuffers - remove existing framebuffers for PCI devices * @pdev: PCI device @@ -328,16 +350,9 @@ EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers); int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const struct drm_driver *req_driver) { - resource_size_t base, size; - int bar, ret = 0; + int ret = 0; - for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) - continue; - base = pci_resource_start(pdev, bar); - size = pci_resource_len(pdev, bar); - drm_aperture_detach_drivers(base, size); - } + drm_aperture_detach_platform_drivers(pdev); /* * WARNING: Apparently we must kick fbdev drivers before vgacon, diff --git a/include/drm/drm_aperture.h b/include/drm/drm_aperture.h index 7096703c3949..53fd36fa258e 100644 --- a/include/drm/drm_aperture.h +++ b/include/drm/drm_aperture.h @@ -15,6 +15,8 @@ int devm_aperture_acquire_from_firmware(struct drm_device *dev, resource_size_t int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_size_t size, bool primary, const struct drm_driver *req_driver); +void drm_aperture_detach_platform_drivers(struct pci_dev *pdev); + int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const struct drm_driver *req_driver);