Message ID | 20230111154112.90575-2-daniel.vetter@ffwll.ch |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3391238wrt; Wed, 11 Jan 2023 07:42:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXup3fpPQv/FxGdlk5BgMYLj9GfH2Dsq7PLu8OCs97Vil5XN56N3vu1zbqXIQgkbhzT/bHrd X-Received: by 2002:a05:6a00:e8d:b0:580:c223:90e9 with SMTP id bo13-20020a056a000e8d00b00580c22390e9mr63287472pfb.6.1673451723649; Wed, 11 Jan 2023 07:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673451723; cv=none; d=google.com; s=arc-20160816; b=xGClk9aDobd+MaoGo6LpoHkWPxLxmOvRoNlYHBtDGCdvzjlPp2z/gmEUVeuP2fVfDN HjNW9HqBb1pssYvHog3T6eaf6XFWhghXd6efISv3a5miR3rtQ49UUEVp/h60t9L1ui46 7xj8kf0wtfyhlp32Ehtd0wHJvgP+6/goyJRL28rltYsnZpOSUAOR19lIAD3VxGpsEk1P kH9+OiHzuJDNvfRGSHJi+2pD9g+41tAUH6jnIMShMjcMaEPfmpFqntAWyx6TYwm51Dgr VuUefLSdcHWvuiRNIxauaV0LTPtpmoKViftprQNWEwJtkjwSgOKvQMi7fbj1JYT4Os/Y cknQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=94eajVQl3EIphKCpXXhL7CnxhOfjsXCJp+mdLyrDZk0=; b=WKRC5Fos0D4T02WhvwkldFxjwzWS8K7c5uXocYOn+nr+oNiVATsF2f2+/L2RNNadUp Po/6pcd+PNmcFf7tF10OvGTYkzLnwoDXNBpkSmlWaNBYH4LOgcyDqIh64lVQd+7YH3rx m7okPeflOUC6CrotKEg6v+iHSbsA8RVyM41ArNP9+zphnb7vqyW00DLdTZ2iUp+EUPL+ tQA3xoISZN8i60HfR16iNLsWwWyD1uTQPKk3i4SNU7cWp45n38JOVMSlL6vCgwxXjm4x mHJ3rsnhJFiTikbhsOAKBzr9uPongYJxct+hCtRcRihUhgt0RuGhimsUky4+hQiKhNfk fc0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=f7KHQ8uU; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t36-20020a056a0013a400b0056e4c95266bsi16632576pfg.77.2023.01.11.07.41.51; Wed, 11 Jan 2023 07:42:03 -0800 (PST) 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=@ffwll.ch header.s=google header.b=f7KHQ8uU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235623AbjAKPli (ORCPT <rfc822;syz17693488234@gmail.com> + 99 others); Wed, 11 Jan 2023 10:41:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233853AbjAKPlZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 11 Jan 2023 10:41:25 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 045F429C for <linux-kernel@vger.kernel.org>; Wed, 11 Jan 2023 07:41:24 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id l26so11383590wme.5 for <linux-kernel@vger.kernel.org>; Wed, 11 Jan 2023 07:41:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=94eajVQl3EIphKCpXXhL7CnxhOfjsXCJp+mdLyrDZk0=; b=f7KHQ8uU7yo7cC1q+hRAYyai9jdEOJCO8tU1UcHPeDOQzr3zT9mcNDiHKbkAh9YMdi PcqaMKKeizVMG9LtdqmhoiqGGOE/2lkXWI8gQheuKM7IeiU6H+0SevQsiVwVjpCuYqMs pIc2/KEnN2fQGSipr275BOLjvkdqRmvXH0z6A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=94eajVQl3EIphKCpXXhL7CnxhOfjsXCJp+mdLyrDZk0=; b=pWSYNCmnT2PI6rz+iStjSFdkcZD/nGkGqb7i0pEXX6tc7aZZkB3XTZyunEyCwg9e0Z TSAc0WU5W8ehj2Ubxf9/hLNMTlf/p25r3AB5a4XEmsyJFtndZUBD4/iaFo90tZlAXZgN VtTA2hte6ZOsWC2xjcRKh2wPxUhnResaoOfjL3g1G+5HjpJdtML9cGw3XtdIARFM57Qv GNi+U8Kq4hRfc+fwBpODFYCxL9qr9ZCqS+vj0T/k134uVu/IME2XuuWx4Xy42nJD85jU 1Nb4jM6i/np5Id3Ia4OeSGBsXDn1TH4sjwvtv8HMeNURlwW+yBr8dRytOe0+fYOE6Fj1 qJgw== X-Gm-Message-State: AFqh2krUZFqAbnOjbQ1BIv8eUa3JXaTnFs9iyC39HSdYUmf2pZnjNGdJ 9JfZrDqmPrpKzZhf58KW6Es9sA== X-Received: by 2002:a05:600c:4e4f:b0:3cf:9d32:db67 with SMTP id e15-20020a05600c4e4f00b003cf9d32db67mr52259243wmq.3.1673451682597; Wed, 11 Jan 2023 07:41:22 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id t9-20020a05600c198900b003d9e74dd9b2sm15936149wmq.9.2023.01.11.07.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 07:41:21 -0800 (PST) From: Daniel Vetter <daniel.vetter@ffwll.ch> To: DRI Development <dri-devel@lists.freedesktop.org> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>, LKML <linux-kernel@vger.kernel.org>, Daniel Vetter <daniel.vetter@ffwll.ch>, Daniel Vetter <daniel.vetter@intel.com> Subject: [PATCH 02/11] drm/gma500: Use drm_aperture_remove_conflicting_pci_framebuffers Date: Wed, 11 Jan 2023 16:41:03 +0100 Message-Id: <20230111154112.90575-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230111154112.90575-1-daniel.vetter@ffwll.ch> References: <20230111154112.90575-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754741314330059432?= X-GMAIL-MSGID: =?utf-8?q?1754741314330059432?= |
Series |
[01/11] drm/ast: Use drm_aperture_remove_conflicting_pci_framebuffers
|
|
Commit Message
Daniel Vetter
Jan. 11, 2023, 3:41 p.m. UTC
This one nukes all framebuffers, which is a bit much. In reality
gma500 is igpu and never shipped with anything discrete, so there should
not be any difference.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
drivers/gpu/drm/gma500/psb_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Am 11.01.23 um 16:41 schrieb Daniel Vetter: > This one nukes all framebuffers, which is a bit much. In reality > gma500 is igpu and never shipped with anything discrete, so there should > not be any difference. > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > --- > drivers/gpu/drm/gma500/psb_drv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c > index cd9c73f5a64a..9b0daf90dc50 100644 > --- a/drivers/gpu/drm/gma500/psb_drv.c > +++ b/drivers/gpu/drm/gma500/psb_drv.c > @@ -429,7 +429,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we > * might be able to read the framebuffer range from the device. > */ > - ret = drm_aperture_remove_framebuffers(true, &driver); > + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); This does not work. The comment just above the changed line explains why. The device uses shared memory similar to other integrated Intel chips. The console is somewhere in a 16 MiB range, which has been stolen by the BIOS from main memory. There's only a 1 MiB memory range on the device to program the device. Unless you want to refactor as described, this call has to cover the whole memory for now. Best regards Thomas > if (ret) > return ret; > -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
On Thu, Jan 12, 2023 at 10:04:48AM +0100, Thomas Zimmermann wrote: > Hi > > Am 11.01.23 um 16:41 schrieb Daniel Vetter: > > This one nukes all framebuffers, which is a bit much. In reality > > gma500 is igpu and never shipped with anything discrete, so there should > > not be any difference. > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > > --- > > drivers/gpu/drm/gma500/psb_drv.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c > > index cd9c73f5a64a..9b0daf90dc50 100644 > > --- a/drivers/gpu/drm/gma500/psb_drv.c > > +++ b/drivers/gpu/drm/gma500/psb_drv.c > > @@ -429,7 +429,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > > * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we > > * might be able to read the framebuffer range from the device. > > */ > > - ret = drm_aperture_remove_framebuffers(true, &driver); > > + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); > > This does not work. The comment just above the changed line explains why. > The device uses shared memory similar to other integrated Intel chips. The > console is somewhere in a 16 MiB range, which has been stolen by the BIOS > from main memory. There's only a 1 MiB memory range on the device to program > the device. Unless you want to refactor as described, this call has to cover > the whole memory for now. Uh. So it's maybe not so pretty, but what if I just call both functions? That way we get the vga handling through the pci one, and the "make sure there's no fb left" through the other one. Plus comment of course. Otherwise we'd need to somehow keep the vga stuff in the non-pci paths, and that just feels all kinds of wrong to me. -Daniel
Hi Am 12.01.23 um 10:59 schrieb Daniel Vetter: > On Thu, Jan 12, 2023 at 10:04:48AM +0100, Thomas Zimmermann wrote: >> Hi >> >> Am 11.01.23 um 16:41 schrieb Daniel Vetter: >>> This one nukes all framebuffers, which is a bit much. In reality >>> gma500 is igpu and never shipped with anything discrete, so there should >>> not be any difference. >>> >>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> >>> --- >>> drivers/gpu/drm/gma500/psb_drv.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c >>> index cd9c73f5a64a..9b0daf90dc50 100644 >>> --- a/drivers/gpu/drm/gma500/psb_drv.c >>> +++ b/drivers/gpu/drm/gma500/psb_drv.c >>> @@ -429,7 +429,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) >>> * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we >>> * might be able to read the framebuffer range from the device. >>> */ >>> - ret = drm_aperture_remove_framebuffers(true, &driver); >>> + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); >> >> This does not work. The comment just above the changed line explains why. >> The device uses shared memory similar to other integrated Intel chips. The >> console is somewhere in a 16 MiB range, which has been stolen by the BIOS >> from main memory. There's only a 1 MiB memory range on the device to program >> the device. Unless you want to refactor as described, this call has to cover >> the whole memory for now. > > Uh. So it's maybe not so pretty, but what if I just call both functions? That's ways more ugly IMHO. > That way we get the vga handling through the pci one, and the "make sure > there's no fb left" through the other one. Plus comment of course. > > Otherwise we'd need to somehow keep the vga stuff in the non-pci paths, > and that just feels all kinds of wrong to me. With your patch applied, aperture_detach_devices() does all the work of removing. I'd add the following internal functions: static void aperture_detach_head(bool is_primary) { /* * lengthy comment here */ if (is_primary) sysfb_disable() } static void aperture_detach_tail(bool remove_vga) { if (remove_vga) { aperture_detach_devices(VGA_PHYS_) vga_remove_vgacon() } } And call both of them at the beginning/end of aperture_remove_conflicting_devices() and aperture_remove_conflicting_pci_devices(). You'd still need to primary argument to aperture_remove_conflicting_devices(), but there will be no code duplication with the aperture helpers and the purpose of each code fragment will be clearer. Best regards Thomas > -Daniel -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
On Thu, Jan 12, 2023 at 11:24:13AM +0100, Thomas Zimmermann wrote: > Hi > > Am 12.01.23 um 10:59 schrieb Daniel Vetter: > > On Thu, Jan 12, 2023 at 10:04:48AM +0100, Thomas Zimmermann wrote: > > > Hi > > > > > > Am 11.01.23 um 16:41 schrieb Daniel Vetter: > > > > This one nukes all framebuffers, which is a bit much. In reality > > > > gma500 is igpu and never shipped with anything discrete, so there should > > > > not be any difference. > > > > > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > > > > --- > > > > drivers/gpu/drm/gma500/psb_drv.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c > > > > index cd9c73f5a64a..9b0daf90dc50 100644 > > > > --- a/drivers/gpu/drm/gma500/psb_drv.c > > > > +++ b/drivers/gpu/drm/gma500/psb_drv.c > > > > @@ -429,7 +429,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > > > > * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we > > > > * might be able to read the framebuffer range from the device. > > > > */ > > > > - ret = drm_aperture_remove_framebuffers(true, &driver); > > > > + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); > > > > > > This does not work. The comment just above the changed line explains why. > > > The device uses shared memory similar to other integrated Intel chips. The > > > console is somewhere in a 16 MiB range, which has been stolen by the BIOS > > > from main memory. There's only a 1 MiB memory range on the device to program > > > the device. Unless you want to refactor as described, this call has to cover > > > the whole memory for now. > > > > Uh. So it's maybe not so pretty, but what if I just call both functions? > > That's ways more ugly IMHO. > > > That way we get the vga handling through the pci one, and the "make sure > > there's no fb left" through the other one. Plus comment of course. > > > > Otherwise we'd need to somehow keep the vga stuff in the non-pci paths, > > and that just feels all kinds of wrong to me. > > With your patch applied, aperture_detach_devices() does all the work of > removing. I'd add the following internal functions: > > static void aperture_detach_head(bool is_primary) > { > /* > * lengthy comment here > */ > if (is_primary) > sysfb_disable() > } > > static void aperture_detach_tail(bool remove_vga) > { > if (remove_vga) { > aperture_detach_devices(VGA_PHYS_) > vga_remove_vgacon() > } > } > > And call both of them at the beginning/end of > aperture_remove_conflicting_devices() and > aperture_remove_conflicting_pci_devices(). > > You'd still need to primary argument to > aperture_remove_conflicting_devices(), but there will be no code duplication > with the aperture helpers and the purpose of each code fragment will be > clearer. Yeah I don't want the primary argument. Aside from this one case here it's not needed. Also by pushing this special case into the one driver that needs it we keep it contained, instead of spreading it all around. Inflicting a parameter on every (and in total we have a lot of callers of this stuff) just because of gma500 does not seem like a good idea to me. -Daniel
Hi Am 12.01.23 um 11:45 schrieb Daniel Vetter: > On Thu, Jan 12, 2023 at 11:24:13AM +0100, Thomas Zimmermann wrote: >> Hi >> >> Am 12.01.23 um 10:59 schrieb Daniel Vetter: >>> On Thu, Jan 12, 2023 at 10:04:48AM +0100, Thomas Zimmermann wrote: >>>> Hi >>>> >>>> Am 11.01.23 um 16:41 schrieb Daniel Vetter: >>>>> This one nukes all framebuffers, which is a bit much. In reality >>>>> gma500 is igpu and never shipped with anything discrete, so there should >>>>> not be any difference. >>>>> >>>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> >>>>> --- >>>>> drivers/gpu/drm/gma500/psb_drv.c | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c >>>>> index cd9c73f5a64a..9b0daf90dc50 100644 >>>>> --- a/drivers/gpu/drm/gma500/psb_drv.c >>>>> +++ b/drivers/gpu/drm/gma500/psb_drv.c >>>>> @@ -429,7 +429,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) >>>>> * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we >>>>> * might be able to read the framebuffer range from the device. >>>>> */ >>>>> - ret = drm_aperture_remove_framebuffers(true, &driver); >>>>> + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); >>>> >>>> This does not work. The comment just above the changed line explains why. >>>> The device uses shared memory similar to other integrated Intel chips. The >>>> console is somewhere in a 16 MiB range, which has been stolen by the BIOS >>>> from main memory. There's only a 1 MiB memory range on the device to program >>>> the device. Unless you want to refactor as described, this call has to cover >>>> the whole memory for now. >>> >>> Uh. So it's maybe not so pretty, but what if I just call both functions? >> >> That's ways more ugly IMHO. >> >>> That way we get the vga handling through the pci one, and the "make sure >>> there's no fb left" through the other one. Plus comment of course. >>> >>> Otherwise we'd need to somehow keep the vga stuff in the non-pci paths, >>> and that just feels all kinds of wrong to me. >> >> With your patch applied, aperture_detach_devices() does all the work of >> removing. I'd add the following internal functions: >> >> static void aperture_detach_head(bool is_primary) >> { >> /* >> * lengthy comment here >> */ >> if (is_primary) >> sysfb_disable() >> } >> >> static void aperture_detach_tail(bool remove_vga) >> { >> if (remove_vga) { >> aperture_detach_devices(VGA_PHYS_) >> vga_remove_vgacon() >> } >> } >> >> And call both of them at the beginning/end of >> aperture_remove_conflicting_devices() and >> aperture_remove_conflicting_pci_devices(). >> >> You'd still need to primary argument to >> aperture_remove_conflicting_devices(), but there will be no code duplication >> with the aperture helpers and the purpose of each code fragment will be >> clearer. > > Yeah I don't want the primary argument. Aside from this one case here it's > not needed. Also by pushing this special case into the one driver that > needs it we keep it contained, instead of spreading it all around. > Inflicting a parameter on every (and in total we have a lot of callers of > this stuff) just because of gma500 does not seem like a good idea to me. Unfortunately, vgacon and vgaarb require a PCI device. I don't like the proposal, but maybe it's the best for now. So go ahead if you like. I do expect that this needs additional work in future, however. Just some more thoughts. Grep for drm_aperture_remove_framebuffers(). Within DRM there are really just 10 drivers calling this function (vs. 12 callers of drm_aperture_remove_conflicting_pci_framebuffers()). In fbdev, there are many callers of the PCI helper (~40) and apparently only 3 for the non-PCI one. The other drivers are panels, USB, MIPI, etc and don't interact with the system framebuffer. Compared to the overall number of drivers, we have surprisingly few 'traditional graphics cards' in DRM. Another thing is that gma500 and the other 9 drivers simply don't bother to get the framebuffer range. They should be reworked to fetch the configured framebuffer from the device and release that region only. The practical impact is close to zero, so it hasn't happened. Best regards Thomas > -Daniel -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
On Thu, 12 Jan 2023 at 13:15, Thomas Zimmermann <tzimmermann@suse.de> wrote: > > Hi > > Am 12.01.23 um 11:45 schrieb Daniel Vetter: > > On Thu, Jan 12, 2023 at 11:24:13AM +0100, Thomas Zimmermann wrote: > >> Hi > >> > >> Am 12.01.23 um 10:59 schrieb Daniel Vetter: > >>> On Thu, Jan 12, 2023 at 10:04:48AM +0100, Thomas Zimmermann wrote: > >>>> Hi > >>>> > >>>> Am 11.01.23 um 16:41 schrieb Daniel Vetter: > >>>>> This one nukes all framebuffers, which is a bit much. In reality > >>>>> gma500 is igpu and never shipped with anything discrete, so there should > >>>>> not be any difference. > >>>>> > >>>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > >>>>> --- > >>>>> drivers/gpu/drm/gma500/psb_drv.c | 2 +- > >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>>>> > >>>>> diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c > >>>>> index cd9c73f5a64a..9b0daf90dc50 100644 > >>>>> --- a/drivers/gpu/drm/gma500/psb_drv.c > >>>>> +++ b/drivers/gpu/drm/gma500/psb_drv.c > >>>>> @@ -429,7 +429,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > >>>>> * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we > >>>>> * might be able to read the framebuffer range from the device. > >>>>> */ > >>>>> - ret = drm_aperture_remove_framebuffers(true, &driver); > >>>>> + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); > >>>> > >>>> This does not work. The comment just above the changed line explains why. > >>>> The device uses shared memory similar to other integrated Intel chips. The > >>>> console is somewhere in a 16 MiB range, which has been stolen by the BIOS > >>>> from main memory. There's only a 1 MiB memory range on the device to program > >>>> the device. Unless you want to refactor as described, this call has to cover > >>>> the whole memory for now. > >>> > >>> Uh. So it's maybe not so pretty, but what if I just call both functions? > >> > >> That's ways more ugly IMHO. > >> > >>> That way we get the vga handling through the pci one, and the "make sure > >>> there's no fb left" through the other one. Plus comment of course. > >>> > >>> Otherwise we'd need to somehow keep the vga stuff in the non-pci paths, > >>> and that just feels all kinds of wrong to me. > >> > >> With your patch applied, aperture_detach_devices() does all the work of > >> removing. I'd add the following internal functions: > >> > >> static void aperture_detach_head(bool is_primary) > >> { > >> /* > >> * lengthy comment here > >> */ > >> if (is_primary) > >> sysfb_disable() > >> } > >> > >> static void aperture_detach_tail(bool remove_vga) > >> { > >> if (remove_vga) { > >> aperture_detach_devices(VGA_PHYS_) > >> vga_remove_vgacon() > >> } > >> } > >> > >> And call both of them at the beginning/end of > >> aperture_remove_conflicting_devices() and > >> aperture_remove_conflicting_pci_devices(). > >> > >> You'd still need to primary argument to > >> aperture_remove_conflicting_devices(), but there will be no code duplication > >> with the aperture helpers and the purpose of each code fragment will be > >> clearer. > > > > Yeah I don't want the primary argument. Aside from this one case here it's > > not needed. Also by pushing this special case into the one driver that > > needs it we keep it contained, instead of spreading it all around. > > Inflicting a parameter on every (and in total we have a lot of callers of > > this stuff) just because of gma500 does not seem like a good idea to me. > > Unfortunately, vgacon and vgaarb require a PCI device. I don't like the > proposal, but maybe it's the best for now. So go ahead if you like. I do > expect that this needs additional work in future, however. > > Just some more thoughts. > > Grep for drm_aperture_remove_framebuffers(). Within DRM there are really > just 10 drivers calling this function (vs. 12 callers of > drm_aperture_remove_conflicting_pci_framebuffers()). In fbdev, there are > many callers of the PCI helper (~40) and apparently only 3 for the > non-PCI one. The other drivers are panels, USB, MIPI, etc and don't > interact with the system framebuffer. Compared to the overall number of > drivers, we have surprisingly few 'traditional graphics cards' in DRM. This is largely historical. fbdev is from the 90s, when we had the huge explosion in largely pci graphics cards, because that was the place where all the growth and hence drivers were. 80% of these companies/chipe all died within a short few years. kms otoh had the huge growth in the 2010s, where there was the tail end of the SoC mobile explosion, so that's where we have tons of drivers. If you look at staging there's a pile more fbdev drivers for SoC, but many of these never got beyond the "vendor hacked some stuff together and shipped it" stage. So that's probably why they lack polish like fw -> driver handover (most of these just booted directly to the driver in real products). > Another thing is that gma500 and the other 9 drivers simply don't bother > to get the framebuffer range. They should be reworked to fetch the > configured framebuffer from the device and release that region only. The > practical impact is close to zero, so it hasn't happened. I think that's ok, because trying to figure out the real fb means you need fairly complete hw state readout (otherwise there's no motivation), and i915 is the only driver that ever really did that. Just for fw driver removal "nuke everything" gets the job done. -Daniel > Best regards > Thomas > > > > -Daniel > > -- > Thomas Zimmermann > Graphics Driver Developer > SUSE Software Solutions Germany GmbH > Maxfeldstr. 5, 90409 Nürnberg, Germany > (HRB 36809, AG Nürnberg) > Geschäftsführer: Ivo Totev
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c index cd9c73f5a64a..9b0daf90dc50 100644 --- a/drivers/gpu/drm/gma500/psb_drv.c +++ b/drivers/gpu/drm/gma500/psb_drv.c @@ -429,7 +429,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we * might be able to read the framebuffer range from the device. */ - ret = drm_aperture_remove_framebuffers(true, &driver); + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); if (ret) return ret;