diff mbox series

[bug#59003,v2,6/6] installer: Report known-unsupported PCI devices.

Message ID 20221109215637.22445-7-ludo@gnu.org
State New
Headers show
Series Warn about unsupported devices | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success
cbaines/issue success View issue

Commit Message

Ludovic Courtès Nov. 9, 2022, 9:56 p.m. UTC
* gnu/installer/hardware.scm: New file.
* gnu/local.mk (INSTALLER_MODULES): Add it.
* po/guix/POTFILES.in: Add it.
* gnu/installer.scm (installer-steps): Pass #:pci-database to the
'welcome' step procedure.
* gnu/installer/newt.scm (welcome-page): Add #:pci-database and pass it
to 'run-welcome-page'.
* gnu/installer/newt/welcome.scm (check-hardware-support): Add #:pci-database.
Enumerate unsupported PCI devices and run an error page when unsupported
devices are found.
(run-welcome-page): Add #:pci-database and pass it to
'check-hardware-support'.
* gnu/installer/record.scm (<installer>)[welcome-page]: Adjust comment.
---
 gnu/installer.scm              |  6 ++-
 gnu/installer/hardware.scm     | 90 ++++++++++++++++++++++++++++++++++
 gnu/installer/newt.scm         |  4 +-
 gnu/installer/newt/welcome.scm | 36 +++++++++++---
 gnu/installer/record.scm       |  2 +-
 gnu/local.mk                   |  1 +
 po/guix/POTFILES.in            |  1 +
 7 files changed, 130 insertions(+), 10 deletions(-)
 create mode 100644 gnu/installer/hardware.scm

Comments

pelzflorian (Florian Pelz) Nov. 11, 2022, 11:08 a.m. UTC | #1
Okay, the blame on the hardware manufacturer is fine as is.

I tested again by creating a dummy gpg key, locally adding it to
guix-authorizations and changing guix/channels.scm’s
%guix-channel-introduction.

Ludovic Courtès <ludo@gnu.org> writes:
> +(define %unsupported-linux-modules
> +  '([…]
> +    ;; Graphics.
> +    "amdgpu"
> +    "radeon"

Yes, this is fine, I think, even though AMD users will have also gotten
the uvesafb warning before and even though allegedly some AMD devices
work okay without firmware (except for 3d, according to h-node).

Also with the previous v1 patch revision (I had missed that), and now
testing on a PC with non-working AMD graphics, when I first select
shell-based install, I get the warning, then switch back to the
installer with Alt-F1 and select graphical installation, after first
seeing the uvesafb warning, the installer crashes.  installer-backtrace
is this:

In ice-9/boot-9.scm:
  1752:10 19 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In ice-9/eval.scm:
    619:8 18 (_ #(#(#(#<directory (guile-user) 7fb5fdc4dc80>)) #<variable 7fb5ebe9a9c0 value: #<undefined>>))
   626:19 17 (_ #(#(#(#<directory (guile-user) 7fb5fdc4dc80>)) #<variable 7fb5ebe9a9c0 value: #<undefined>>))
In gnu/installer/utils.scm:
   353:14 16 (call-with-server-socket _)
In ./gnu/installer/steps.scm:
   150:13 15 (run () #:todo-steps _ #:done-steps _)
   148:23 14 (run ((locale . "en_AG.utf8")) #:todo-steps _ #:done-steps _)
In ./gnu/installer/newt/welcome.scm:
   118:18 13 (run-menu-page "GNU Guix install" "Welcome to GNU Guix system installer!\n\nYou will be guided through a graphical installation program.\n\nIf you are familiar with GNU/Linux and you…" …)
   118:18 12 (run-menu-page "GNU Guix install" "Welcome to GNU Guix system installer!\n\nYou will be guided through a graphical installation program.\n\nIf you are familiar with GNU/Linux and you…" …)
   152:36 11 (check-hardware-support #f)
In ./gnu/installer/hardware.scm:
    80:19 10 (pci-device-description #f)
In gnu/build/linux-modules.scm:
   561:14  9 (load-pci-device-database _)
In unknown file:
           8 (open-file #f "r0")
In ice-9/boot-9.scm:
  1685:16  7 (raise-exception _ #:continuable? _)
  1780:13  6 (_ #<&compound-exception components: (#<&assertion-failure> #<&origin origin: #f> #<&message message: "Wrong type (expecting ~A): ~S"> #<&irritants irritants: ("string" #f)> #<&except…>)
In ice-9/eval.scm:
    619:8  5 (_ #(#(#(#<directory (guile-user) 7fb5fdc4dc80>) wrong-type-arg (#f "Wrong type (expecting ~A): ~S" ("string" #f) (#f))) #<variable 7fb5e7f01690 value: #<unspecified>> #<variable 7…> …))
   626:19  4 (_ #(#(#(#<directory (guile-user) 7fb5fdc4dc80>) wrong-type-arg (#f "Wrong type (expecting ~A): ~S" ("string" #f) (#f))) #<variable 7fb5e7f01690 value: #<unspecified>> #<variable 7…> …))
In ./gnu/installer/dump.scm:
     58:4  3 (prepare-dump wrong-type-arg (#f "Wrong type (expecting ~A): ~S" ("string" #f) (#f)) #:result _)
In ice-9/ports.scm:
   433:17  2 (call-with-output-file _ _ #:binary _ #:encoding _)
In ./gnu/installer/dump.scm:
    60:27  1 (_ #<output: installer-backtrace 20>)
In unknown file:
           0 (make-stack #t)
./gnu/installer/dump.scm:62:36: Wrong type (expecting string): #f


Regards,
Florian
Ludovic Courtès Nov. 15, 2022, 11:24 a.m. UTC | #2
Hi,

"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>> +(define %unsupported-linux-modules
>> +  '([…]
>> +    ;; Graphics.
>> +    "amdgpu"
>> +    "radeon"
>
> Yes, this is fine, I think, even though AMD users will have also gotten
> the uvesafb warning before and even though allegedly some AMD devices
> work okay without firmware (except for 3d, according to h-node).

Right, I think it’s only 3D that won’t work.  Maybe we should remove
them?  Dunno, we also want to warn about things that will not work to
its fullest.  Maybe we should reword the sentence?  Like:

  Unfortunately, it means those devices will not be usable.
  ->
  Unfortunately, it means those devices will not be usable or that some
  features will be unavailable.

WDYT?

> Also with the previous v1 patch revision (I had missed that), and now
> testing on a PC with non-working AMD graphics, when I first select
> shell-based install, I get the warning, then switch back to the
> installer with Alt-F1 and select graphical installation, after first
> seeing the uvesafb warning, the installer crashes.  installer-backtrace
> is this:

Oops, thanks; I fixed that recursive call in ‘run-welcome-page’.

I also added a sentence under “Hardware Considerations” mentioning this
warning and pushed the whole thing, in the hope we can call for testing
real soon.

  514fedbf39 * installer: Report known-unsupported PCI devices.
  6b39c3afcc * installer: Error page width is parameterized.
  938d6161cb * installer: Use 'current-guix' for extensions.
  afbd4d8470 * linux-modules: Add 'load-pci-device-database'.
  655fb8feac * linux-modules: Add support for listing PCI devices.
  4f7ffb97a4 * installer: Warn about hardware support after the welcome page.

Thanks,
Ludo’.
pelzflorian (Florian Pelz) Nov. 15, 2022, 6:28 p.m. UTC | #3
Ludovic Courtès <ludo@gnu.org> writes:
> "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis:
>> Ludovic Courtès <ludo@gnu.org> writes:
>>> +(define %unsupported-linux-modules
>>> +  '([…]
>>> +    ;; Graphics.
>>> +    "amdgpu"
>>> +    "radeon"
>> Yes, this is fine, I think, even though AMD users will have also gotten
>> the uvesafb warning before and even though allegedly some AMD devices
>> work okay without firmware (except for 3d, according to h-node).
> Right, I think it’s only 3D that won’t work.  Maybe we should remove
> them?

Allegedly for some people only 3d is broken, but my AMD PCs’ screens get
frozen, also Philip’s
<https://lists.gnu.org/archive/html/help-guix/2021-10/msg00047.html>.
was unusable.

> Dunno, we also want to warn about things that will not work to
> its fullest.  Maybe we should reword the sentence?  Like:
>
>   Unfortunately, it means those devices will not be usable.
>   ->
>   Unfortunately, it means those devices will not be usable or that some
>   features will be unavailable.
>
> WDYT?

It is closer to the truth, so yes, but is not important.  The uvesafb
message before will have told AMD users that there may be a false alarm.

> Oops, thanks; I fixed that recursive call in ‘run-welcome-page’.

Ahh.  It works.

Regards,
Florian
diff mbox series

Patch

diff --git a/gnu/installer.scm b/gnu/installer.scm
index df7625e05c..e1b040088b 100644
--- a/gnu/installer.scm
+++ b/gnu/installer.scm
@@ -46,6 +46,7 @@  (define-module (gnu installer)
   #:use-module (gnu packages nano)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages package-management)
+  #:use-module (gnu packages pciutils)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages xorg)
   #:use-module (gnu system locale)
@@ -226,7 +227,9 @@  (define (installer-steps)
           (id 'welcome)
           (compute (lambda _
                      ((installer-welcome-page current-installer)
-                      #$(local-file "installer/aux-files/logo.txt")))))
+                      #$(local-file "installer/aux-files/logo.txt")
+                      #:pci-database
+                      #$(file-append pciutils "/share/hwdata/pci.ids.gz")))))
 
          ;; Ask the user to select a timezone under glibc format.
          (installer-step
@@ -358,6 +361,7 @@  (define installer-builder
     (with-extensions (list guile-gcrypt guile-newt
                            guile-parted guile-bytestructures
                            guile-json-3 guile-git guile-webutils
+                           guile-zlib           ;for (gnu build linux-modules)
                            (current-guix) gnutls)
       (with-imported-modules `(,@(source-module-closure
                                   `(,@modules
diff --git a/gnu/installer/hardware.scm b/gnu/installer/hardware.scm
new file mode 100644
index 0000000000..cd1a1767d8
--- /dev/null
+++ b/gnu/installer/hardware.scm
@@ -0,0 +1,90 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu installer hardware)
+  #:use-module (gnu build linux-modules)
+  #:use-module (guix i18n)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-71)
+  #:export (unsupported-pci-device?
+            pci-device-description))
+
+(define %unsupported-linux-modules
+  ;; List of Linux modules that are useless without non-free firmware.
+  ;;
+  ;; Currently only drivers for PCI devices are listed.  USB devices such as
+  ;; "btintel" would require support to list USB devices and read the USB
+  ;; device ID database.  Punt for now as this is usually less critical.
+  ;;
+  ;; This list is currently manually maintained based on information on
+  ;; non-free firmware available from
+  ;; <https://packages.debian.org/search?keywords=firmware&searchon=names&suite=stable&section=all>.
+  '(;; WiFi.
+    "brcmfmac"
+    "ipw2100"
+    "ipw2200"
+    "iwlwifi"
+    "mwl8k"
+    "rtl8188ee"
+    "rtl818x_pci"
+    "rtl8192ce"
+    "rtl8192de"
+    "rtl8192ee"
+
+    ;; Ethernet.
+    "bnx2"
+    "bnx2x"
+    "liquidio"
+
+    ;; Graphics.
+    "amdgpu"
+    "radeon"
+
+    ;; Multimedia.
+    "ivtv"))
+
+(define unsupported-pci-device?
+  ;; Arrange to load the module alias database only once.
+  (let ((aliases (delay (known-module-aliases))))
+    (lambda (device)
+      "Return true if DEVICE is known to not be supported by free software."
+      (any (lambda (module)
+             (member module %unsupported-linux-modules))
+           (matching-modules (pci-device-module-alias device)
+                             (force aliases))))))
+
+(define (pci-device-description pci-database)
+  "Return a procedure that, given a PCI device, returns a string describing
+it."
+  (define (with-fallback lookup)
+    (lambda (vendor-id id)
+      (let ((vendor name (lookup vendor-id id)))
+        (values (or vendor (number->string vendor-id 16))
+                (or name (number->string id 16))))))
+
+  (define pci-lookup
+    (with-fallback (load-pci-device-database pci-database)))
+
+  (lambda (device)
+    (let ((vendor name (pci-lookup (pci-device-vendor device)
+                                   (pci-device-id device))))
+      (if (network-pci-device? device)
+          ;; TRANSLATORS: The two placeholders are the manufacturer
+          ;; and name of a PCI device.
+          (format #f (G_ "~a ~a (networking device)")
+                  vendor name)
+          (string-append vendor " " name)))))
diff --git a/gnu/installer/newt.scm b/gnu/installer/newt.scm
index 0bd0856219..60f9e75b81 100644
--- a/gnu/installer/newt.scm
+++ b/gnu/installer/newt.scm
@@ -176,8 +176,8 @@  (define* (locale-page #:key
 (define (timezone-page zonetab)
   (run-timezone-page zonetab))
 
-(define (welcome-page logo)
-  (run-welcome-page logo))
+(define* (welcome-page logo #:key pci-database)
+  (run-welcome-page logo #:pci-database pci-database))
 
 (define (menu-page steps)
   (run-menu-page steps))
diff --git a/gnu/installer/newt/welcome.scm b/gnu/installer/newt/welcome.scm
index 1c7372b3be..e8ac587e2e 100644
--- a/gnu/installer/newt/welcome.scm
+++ b/gnu/installer/newt/welcome.scm
@@ -19,8 +19,10 @@ 
 
 (define-module (gnu installer newt welcome)
   #:use-module ((gnu build linux-modules)
-                #:select (modules-loaded))
+                #:select (modules-loaded
+                          pci-devices))
   #:use-module (gnu installer dump)
+  #:use-module (gnu installer hardware)
   #:use-module (gnu installer steps)
   #:use-module (gnu installer utils)
   #:use-module (gnu installer newt page)
@@ -30,6 +32,8 @@  (define-module (gnu installer newt welcome)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-71)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:use-module (ice-9 receive)
   #:use-module (newt)
@@ -121,7 +125,7 @@  (define (choice->item str)
         (lambda ()
           (destroy-form-and-pop form))))))
 
-(define (check-hardware-support)
+(define (check-hardware-support pci-database)
   "Warn about unsupported devices."
   (when (member "uvesafb" (modules-loaded))
     (run-error-page (G_ "\
@@ -129,9 +133,28 @@  (define (check-hardware-support)
 work well with only free software.  Expect trouble.  If after installation,
 the system does not boot, perhaps you will need to add nomodeset to the
 kernel arguments and need to configure the uvesafb kernel module.")
-                    (G_ "Pre-install warning"))))
+                    (G_ "Pre-install warning")))
 
-(define (run-welcome-page logo)
+  (let ((devices (pci-devices)))
+    (match (filter unsupported-pci-device? devices)
+      (()                                         ;no unsupported device
+       #t)
+      (unsupported
+       (run-error-page (format #f (G_ "\
+Devices not supported by free software were found on your computer:
+
+~{  - ~a~%~}
+Unfortunately, it means those devices will not be usable.
+
+To address it, we recommend choosing hardware that respects your freedom as a \
+user--hardware for which free drivers and firmware exist.  See \"Hardware \
+Considerations\" in the manual for more information.")
+                               (map (pci-device-description pci-database)
+                                    unsupported))
+                       (G_ "Hardware support warning")
+                       #:width 76)))))
+
+(define* (run-welcome-page logo #:key pci-database)
   "Run a welcome page with the given textual LOGO displayed at the center of
 the page. Ask the user to choose between manual installation, graphical
 installation and reboot."
@@ -161,11 +184,12 @@  (define (run-welcome-page logo)
    #:listbox-items
    `((,(G_ "Graphical install using a terminal based interface")
       .
-      ,check-hardware-support)
+      ,(lambda ()
+         (check-hardware-support pci-database)))
      (,(G_ "Install using the shell based process")
       .
       ,(lambda ()
-         (check-hardware-support)
+         (check-hardware-support pci-database)
          ;; Switch to TTY3, where a root shell is available for shell based
          ;; install. The other root TTY's would have been ok too.
          (system* "chvt" "3")
diff --git a/gnu/installer/record.scm b/gnu/installer/record.scm
index 20519a26c3..5e0264682f 100644
--- a/gnu/installer/record.scm
+++ b/gnu/installer/record.scm
@@ -89,7 +89,7 @@  (define-record-type* <installer>
   (partition-page installer-partition-page)
   ;; procedure void -> void
   (services-page installer-services-page)
-  ;; procedure (logo) -> void
+  ;; procedure (logo #:pci-database) -> void
   (welcome-page installer-welcome-page)
   ;; procedure (menu-proc) -> void
   (parameters-menu installer-parameters-menu)
diff --git a/gnu/local.mk b/gnu/local.mk
index 27b31ea27f..2859be63cb 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -787,6 +787,7 @@  INSTALLER_MODULES =                             \
   %D%/installer/connman.scm			\
   %D%/installer/dump.scm			\
   %D%/installer/final.scm			\
+  %D%/installer/hardware.scm			\
   %D%/installer/hostname.scm			\
   %D%/installer/keymap.scm			\
   %D%/installer/locale.scm			\
diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in
index ed3fdb6be0..228ce04240 100644
--- a/po/guix/POTFILES.in
+++ b/po/guix/POTFILES.in
@@ -30,6 +30,7 @@  guix/import/pypi.scm
 guix/import/texlive.scm
 gnu/installer.scm
 gnu/installer/connman.scm
+gnu/installer/hardware.scm
 gnu/installer/hostname.scm
 gnu/installer/keymap.scm
 gnu/installer/locale.scm