Bug 266301 - graphics/drm-fbsd12.0-kmod: wrong dependency
Summary: graphics/drm-fbsd12.0-kmod: wrong dependency
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Felix Palmen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-08 16:20 UTC by Martin Birgmeier
Modified: 2022-09-15 07:13 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Birgmeier 2022-09-08 16:20:28 UTC
Scenario:
- FreeBSD 12.3 latest
- ports latest via git update
- updating ports using portmaster

Result:
- portmaster tries to install many additional ports:

===>>> drm-kmod-20220501 >> (83)

===>>> The following actions will be taken if you choose to proceed:
        Upgrade drm-kmod-20220501 to drm-kmod-20220907_1
        Install graphics/gpu-firmware-kmod
        Install graphics/gpu-firmware-amd-kmod@banks
        Install graphics/gpu-firmware-amd-kmod@bonaire
        Install graphics/gpu-firmware-amd-kmod@carrizo
        Install graphics/gpu-firmware-amd-kmod@fiji
        Install graphics/gpu-firmware-amd-kmod@hainan
        Install graphics/gpu-firmware-amd-kmod@hawaii
        Install graphics/gpu-firmware-amd-kmod@kabini
        Install graphics/gpu-firmware-amd-kmod@kaveri
        Install graphics/gpu-firmware-amd-kmod@mullins
        Install graphics/gpu-firmware-amd-kmod@navi10
        Install graphics/gpu-firmware-amd-kmod@navi12
        Install graphics/gpu-firmware-amd-kmod@navi14
        Install graphics/gpu-firmware-amd-kmod@oland
        Install graphics/gpu-firmware-amd-kmod@picasso
        Install graphics/gpu-firmware-amd-kmod@pitcairn
        Install graphics/gpu-firmware-amd-kmod@polaris10
        Install graphics/gpu-firmware-amd-kmod@polaris11
        Install graphics/gpu-firmware-amd-kmod@polaris12
        Install graphics/gpu-firmware-amd-kmod@raven
        Install graphics/gpu-firmware-amd-kmod@raven2
        Install graphics/gpu-firmware-amd-kmod@renoir
        Install graphics/gpu-firmware-amd-kmod@si58
        Install graphics/gpu-firmware-amd-kmod@stoney
        Install graphics/gpu-firmware-amd-kmod@tahiti
        Install graphics/gpu-firmware-amd-kmod@tonga
        Install graphics/gpu-firmware-amd-kmod@topaz
        Install graphics/gpu-firmware-amd-kmod@vega10
        Install graphics/gpu-firmware-amd-kmod@vega12
        Install graphics/gpu-firmware-amd-kmod@vega20
        Install graphics/gpu-firmware-amd-kmod@vegam
        Install graphics/gpu-firmware-amd-kmod@verde
        Install graphics/gpu-firmware-intel-kmod@broxton
        Install graphics/gpu-firmware-intel-kmod@coffeelake
        Install graphics/gpu-firmware-intel-kmod@elkhartlake
        Install graphics/gpu-firmware-intel-kmod@geminilake
        Install graphics/gpu-firmware-intel-kmod@icelake
        Install graphics/gpu-firmware-intel-kmod@kabylake
        Install graphics/gpu-firmware-intel-kmod@rocketlake
        Install graphics/gpu-firmware-intel-kmod@skylake
        Install graphics/gpu-firmware-intel-kmod@tigerlake
        Install graphics/gpu-firmware-radeon-kmod@aruba
        Install graphics/gpu-firmware-radeon-kmod@barts
        Install graphics/gpu-firmware-radeon-kmod@bonaire
        Install graphics/gpu-firmware-radeon-kmod@btc
        Install graphics/gpu-firmware-radeon-kmod@caicos
        Install graphics/gpu-firmware-radeon-kmod@cayman
        Install graphics/gpu-firmware-radeon-kmod@cedar
        Install graphics/gpu-firmware-radeon-kmod@cypress
        Install graphics/gpu-firmware-radeon-kmod@hainan
        Install graphics/gpu-firmware-radeon-kmod@hawaii
        Install graphics/gpu-firmware-radeon-kmod@juniper
        Install graphics/gpu-firmware-radeon-kmod@kabini
        Install graphics/gpu-firmware-radeon-kmod@kaveri
        Install graphics/gpu-firmware-radeon-kmod@mullins
        Install graphics/gpu-firmware-radeon-kmod@oland
        Install graphics/gpu-firmware-radeon-kmod@palm
        Install graphics/gpu-firmware-radeon-kmod@pitcairn
        Install graphics/gpu-firmware-radeon-kmod@r100
        Install graphics/gpu-firmware-radeon-kmod@r200
        Install graphics/gpu-firmware-radeon-kmod@r300
        Install graphics/gpu-firmware-radeon-kmod@r420
        Install graphics/gpu-firmware-radeon-kmod@r520
        Install graphics/gpu-firmware-radeon-kmod@r600
        Install graphics/gpu-firmware-radeon-kmod@r700
        Install graphics/gpu-firmware-radeon-kmod@redwood
        Install graphics/gpu-firmware-radeon-kmod@rs600
        Install graphics/gpu-firmware-radeon-kmod@rs690
        Install graphics/gpu-firmware-radeon-kmod@rs780
        Install graphics/gpu-firmware-radeon-kmod@rv610
        Install graphics/gpu-firmware-radeon-kmod@rv620
        Install graphics/gpu-firmware-radeon-kmod@rv630
        Install graphics/gpu-firmware-radeon-kmod@rv635
        Install graphics/gpu-firmware-radeon-kmod@rv670
        Install graphics/gpu-firmware-radeon-kmod@rv710
        Install graphics/gpu-firmware-radeon-kmod@rv730
        Install graphics/gpu-firmware-radeon-kmod@rv740
        Install graphics/gpu-firmware-radeon-kmod@rv770
        Install graphics/gpu-firmware-radeon-kmod@sumo
        Install graphics/gpu-firmware-radeon-kmod@sumo2
        Install graphics/gpu-firmware-radeon-kmod@tahiti
        Install graphics/gpu-firmware-radeon-kmod@turks
        Install graphics/gpu-firmware-radeon-kmod@verde

===>>> Proceed? y/n [y] 

Expected result:
- No new ports should be installed.

Note:
- On FreeBSD 13.1, this error does not occur.
Comment 1 Martin Birgmeier 2022-09-09 14:32:03 UTC
This is actually not a bug, at least not with how an unmodified ports tree works.

Since I do not need any of the firmwares I commented out the line

RUN_DEPENDS=   gpu-firmware-kmod>=g20180319:graphics/gpu-firmware-kmod

from graphics/drm-fbsd12.0-kmod. But after commit 307502b652770970002161d98461d023ecae6df9, graphics/drm-kmod now contains a direct RUN_DEPENDS on on gpu-firmware-kmod, thereby again pulling it in.

So for an unmodified ports tree commit 307502b652770970002161d98461d023ecae6df9 does not change anything except adding a dependency (which is superfluous).

Given that drm-kmod transfers to drm-fbsd12.0-kmod for the FreeBSD 12 case, this direct dependency should arguably not be put in.

This would mean that the logic behind commit 307502b652770970002161d98461d023ecae6df9 is actually wrong, and the overwriting of the RUN_DEPENDS was intentional.

So backing out 307502b652770970002161d98461d023ecae6df9 should be considered.

-- Martin
Comment 2 Martin Birgmeier 2022-09-09 14:36:01 UTC
n.b. Pulling in all variations of firmware in gpu-firmware-kmod seems to me like quite an overshoot. Zero or one such firmwares are needed on most systems, all the others waste a lot of disk (and backup) space.

I think it would be better to let people decide themselves which gpu firmware packages to install. This would mean getting rid of the RUN_DEPENDS on gpu-firmware in all these ports.

-- Martin
Comment 3 Martin Birgmeier 2022-09-09 15:14:17 UTC
I think graphics/drm-kmod/Makefile should be changed to this (untested):

PORTNAME=       drm-kmod
PORTVERSION=    20220907
PORTREVISION=   1
CATEGORIES=     graphics

MAINTAINER=     x11@FreeBSD.org
COMMENT=        Metaport of DRM modules for the linuxkpi-based KMS components
WWW=            https://github.com/freebsd/drm-kmod

USES=           metaport

.include <bsd.port.options.mk>

.if ${OPSYS} != FreeBSD
IGNORE=         not supported on anything but FreeBSD (missing linuxkpi functionality)
.elif ${OSVERSION} < 1300000
RUN_DEPENDS+=   ${KMODDIR}/drm.ko:graphics/drm-fbsd12.0-kmod
_DRM_ARCHS=     amd64 i386
.elif ${OSVERSION} >= 1301000
RUN_DEPENDS+=   ${KMODDIR}/drm.ko:graphics/drm-510-kmod
_DRM_ARCHS=     aarch64 amd64 i386 powerpc64 powerpc64le
.else
IGNORE=         not supported on this FreeBSD version
.endif

.if ! defined(IGNORE) && ! ${_DRM_ARCHS:M${ARCH}}
IGNORE=         not supported for this machine architecture
.endif

.include <bsd.port.mk>

The whole _DRM_ARCHS stuff could also be omitted as it should be handled in the depended-on ports.

-- Martin
Comment 4 Martin Birgmeier 2022-09-09 15:17:38 UTC
Of course, the RUN_DEPENDS+= should be changed back to RUN_DEPENDS=

-- Martin
Comment 5 Felix Palmen freebsd_committer freebsd_triage 2022-09-11 14:29:40 UTC
No, this is actually the result of fixing a long-standing bug.

drm-kmod was always meant to install everything that *could* be needed, which includes all of the firmwares. The firmwares once were all in a single package, and back then, this worked as intended. After splitting them into individual packages though, the dependency was first forgotten, and later erroneously overridden for missing the +=.

If you only want to install individual firmware packages, the way to go is to install either drm-510-kmod (13.x) or drm-fbsd12.0-kmod (12.x) instead of drm-kmod.
Comment 6 Martin Birgmeier 2022-09-11 15:40:51 UTC
I do not quite believe this logic, because initially there was just drm-kmod, which later got split for the various FreeBSD main releases. But even if it is now as you say, drm-fbsd12.0-kmod should then not contain the dependency on graphics/gpu-firmware-kmod.

-- Martin
Comment 7 Felix Palmen freebsd_committer freebsd_triage 2022-09-11 15:56:36 UTC
(In reply to Martin Birgmeier from comment #6)
> I do not quite believe this logic, because initially there was just drm-kmod,
> which later got split for the various FreeBSD main releases.
I don't see how that's related, before the split of the firmware package, each individual drm-*-kmod package just depended on it, but ...

> But even if it is now as you say, drm-fbsd12.0-kmod should then not contain
> the dependency on graphics/gpu-firmware-kmod.
... this is indeed wrong! I just fixed the bug in the drm-kmod metaport and didn't notice that as I'm on 13.1. So, it's yet another bug.

The *intent* of splitting the firmware package was to give users the freedom to only install what they need, but the metaport drm-kmod should still pull in everything so it "just works" for any scenario.
Comment 8 Graham Perrin freebsd_committer freebsd_triage 2022-09-11 16:16:47 UTC
(In reply to Martin Birgmeier from comment #6)

> ... drm-fbsd12.0-kmod should then not contain the dependency on 
> graphics/gpu-firmware-kmod.

% pkg rquery %c graphics/gpu-firmware-kmod
Firmware modules for the drm-kmod drivers
% 

To the best of my knowledge: 

* the driver is simply non-effective in the absence of a firmware module, 
  and so, there is (or should be) a dependency

* with the change of graphics/gpu-firmware-kmod to a metaport 
  <https://github.com/freebsd/freebsd-ports/commit/cfb6fe4117a49b3c3bef886564bbaf38a4627fad>, 
  there was not added automation to detect which flavours 
  might suit an installation. 

True: the mass of what's gained, compared to what preceded the change, is sometimes eyebrow-raising. 

If the alternative will be a non-effective driver: that will be doubly eyebrow-raising. Consider, for example, the various places that: 

* document installation of a driver

* without also documenting the relevance of firmware modules

At least: <https://wiki.freebsd.org/Graphics#drm-kmod>. 

HTH
Comment 9 Felix Palmen freebsd_committer freebsd_triage 2022-09-11 16:23:04 UTC
(In reply to Graham Perrin from comment #8)
> * the driver is simply non-effective in the absence of a firmware module, 
>   and so, there is (or should be) a dependency
Not necessarily true, some GPUs don't need loadable firmware at all.

Anyways, we have a real bug here, it was just erroneously attributed to the graphics/drm-kmod metaport, while it's actually in the graphics/drm-fbsd12.0-kmod port. After splitting the firmware package, this dependency should have been dropped. Note, drm-fbsd13-kmod and drm-510-kmod had it correct, without that dependency.

As for documentation, the recommended way is to install the drm-kmod metaport, this will just install all firmwares, so it will work for everyone (as long as the GPU is supported at all).

Installing individual firmwares only is for "advanced" users, then they can't use the metaport.

I'm just waiting for maintainer feedback to fix this issue here.
Comment 10 Martin Birgmeier 2022-09-11 16:25:38 UTC
(In reply to Graham Perrin from comment #8)

The machine in this case has a "Chipset: "ATI Radeon HD 4290" (ChipID = 0x9714)" installed (from Xorg.0.log). If I remember correctly X would not load without drm.ko being available (it seems to be automatically loaded by X).

On the other hand, none of the firmwares seem to be needed for this card. That led me to remove the dependency on gpu-firmware-kmod.

-- Martin
Comment 11 Graham Perrin freebsd_committer freebsd_triage 2022-09-11 16:36:30 UTC
(In reply to Felix Palmen from comment #9)

> ...  the recommended way is to install the drm-kmod metaport, this will 
> just install all firmwares, ...

OK, that fits: <https://wiki.freebsd.org/Graphics?action=diff&rev1=64&rev2=65#line-73>

> graphics/drm-kmod indirectly provides a range of kernel modules for use 
> with Intel Integrated Graphics and AMD graphics hardware.
Comment 12 Felix Palmen freebsd_committer freebsd_triage 2022-09-11 16:45:34 UTC
(In reply to Martin Birgmeier from comment #10)
> On the other hand, none of the firmwares seem to be needed for this card.
> That led me to remove the dependency on gpu-firmware-kmod.
And that's the correct thing to do. Just not in the drm-kmod metaport, this one is meant to "just work" in any scenario, and most GPUs actually need *some* firmware to work.

@grahamperrin, this doesn't affect *many* people, only those who chose not to use the metaport and only install the firmware they actually need.
Comment 13 commit-hook freebsd_committer freebsd_triage 2022-09-15 07:12:15 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=569a270ee22ed4a77a066271fe77177a0e6c9971

commit 569a270ee22ed4a77a066271fe77177a0e6c9971
Author:     Felix Palmen <zirias@FreeBSD.org>
AuthorDate: 2022-09-11 15:59:11 +0000
Commit:     Felix Palmen <zirias@FreeBSD.org>
CommitDate: 2022-09-15 07:10:32 +0000

    graphics/drm-fbsd12.0-kmod: Remove firmware dep

    drm-*-kmod ports should not depend on firmware, so users are free to
    only install the firmware packages they actually need. Pulling in all
    firmwares should only happen in graphics/drm-kmod metaport.

    PR:                     266301
    Approved by:            x11 (manu), tcberner (mentor)
    Differential Revision:  https://reviews.freebsd.org/D36526

 graphics/drm-fbsd12.0-kmod/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Comment 14 Felix Palmen freebsd_committer freebsd_triage 2022-09-15 07:13:25 UTC
The extra dependency in drm-fbsd12.0-kmod was removed, thanks.