Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp319926rdd; Tue, 9 Jan 2024 05:22:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTYXFwpQOBjAgkGxJaUr24fceREDCVEssDMPYgH2gvPv7t1ziNt/qTUFXtNzW4GheI7mBs X-Received: by 2002:a2e:834c:0:b0:2cc:6cf6:4074 with SMTP id l12-20020a2e834c000000b002cc6cf64074mr2321960ljh.61.1704806538040; Tue, 09 Jan 2024 05:22:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704806538; cv=none; d=google.com; s=arc-20160816; b=cs/QQY3S4BdOKsS2ZRzKgSRyFDqPmOeFAoiiLKcjDxAIuo+g6ohHGIecoYlZN5jPyB a+y1KyXBciCRRL4os/C6TOzhGtI7YzMzEGjd8i1s0Paxh80VxjgpjjarsynMa7LvVEed trXZlNjaG83T841InFKgCagsBaUvtQqErbA7err40lQuUmnlPe0ncAnRXPQlg/hiQXcA YaDYnbDtCUrKtbAN6U8PxYEnfM9ATnC1LISZbiPHutMq5bO0WYNvPwIQLeUePtfis1hg XwEHiRR50NQfJPh4ZKONwHbE/k2Q/zJI8Mv0Uf3J+j55WV8jconB82NJYRIefBvoz9ag lUxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=X8nyMGssowFI2DlaMmQ3Tpss+UtDdR+faxTS8hNAvao=; fh=7IW+LjiXrwZQ401LNWKI3Ek/ZkLaz6bWOaU4zsmO8GM=; b=B6nJCilXjGoKCwF7wxnTS3CRgJfLnjQkA1f0kNw22B94SkgRGt+YN/2xFod6w6Vah0 bgTekwg/74W6fEmH+L3c8khbtsHhIPv3a/PzT551nnd4iZeAaBnBj3+NI1dWNLmIHsj2 YdBj3HXWMN42F6XHhnNYy9zI/toDrU4PJ+CfT6NhSk/+8HPJh+BZW2n/XyCL+fFMvlMx urUHuUxUzQqts4eDc6NhPI2l/fPVRB0dZvJUR3FNZcHHMrBrVEl45+7VO3duQh6tcrHx iiGKXZnPKAlI+rrLEAc3mknWKu54+er5At20fenY4hSQFpzebzqTW4lTuid0hkzsoDSi Voeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=CCveQLyS; spf=pass (google.com: domain of linux-kernel+bounces-20888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20888-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t24-20020a508d58000000b00557917bfe9asi758108edt.401.2024.01.09.05.22.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 05:22:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=CCveQLyS; spf=pass (google.com: domain of linux-kernel+bounces-20888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20888-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 930301F250F0 for ; Tue, 9 Jan 2024 13:22:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE4D738F95; Tue, 9 Jan 2024 13:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="CCveQLyS" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 587B6374D9 for ; Tue, 9 Jan 2024 13:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a2328f2b6e5so75282766b.0 for ; Tue, 09 Jan 2024 05:22:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1704806526; x=1705411326; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=X8nyMGssowFI2DlaMmQ3Tpss+UtDdR+faxTS8hNAvao=; b=CCveQLySshz7k2ru4M4ppbgS8kxsulNJEaNj7eXYbh4JktAwOMJfpXed+lNRPLObH9 caLkWyW+M7nBcgw5Wu3CDfoXki638jXuhp6FmI0RRzHSClvj+wNTbyGsX0NG0dLKKujZ xzIVzXHAs4sArvhQYY5fGdxXSSW8ZDt3sUvdE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704806526; x=1705411326; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X8nyMGssowFI2DlaMmQ3Tpss+UtDdR+faxTS8hNAvao=; b=J8+gTjQZ8uCdr0GJviMqfN0t1FblthUpuNYu/ZFyA0ijpXsE3F4YULamlo4utcEGez Prp5kgqVy4nuGKwl5fhXcAWB5ZQG3e7Opno3ZoXr6+WpPwv5tpoJiz/tlbMzCesUSMz2 yvkFiyyn9Nmy7Z0w9+002WSIaeXELSqIHLl4zILrXjwHy5XImeWD0a+GB/IlbPuuuCbZ nrtmCHbbai2mFJZiIUMzaSXN4ne6ozREYskHKMjRexGIauEfoVhuoQNLFlCwlah+fMxj Hqq08vGmnKBi7e7KHZoW0xQ+TXdQ5INuAkukRc6miNp7jGBXlgp1juoDY0r5TKp8UiOZ g5hw== X-Gm-Message-State: AOJu0YyQLAeTEU+SXs022m8ZeJWNiBo5Vbp7Z6Q/5M6cBHw14L0zjb/+ iNOBQMRCDEka9TlQzj62/zERsE4jHRPRmg== X-Received: by 2002:a17:907:9282:b0:a26:a4e8:5454 with SMTP id bw2-20020a170907928200b00a26a4e85454mr4655999ejc.0.1704806526503; Tue, 09 Jan 2024 05:22:06 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id s23-20020a170906455700b00a27a32e6502sm1026398ejq.117.2024.01.09.05.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 05:22:05 -0800 (PST) Date: Tue, 9 Jan 2024 14:22:02 +0100 From: Daniel Vetter To: Javier Martinez Canillas Cc: linux-kernel@vger.kernel.org, Maxime Ripard , Erico Nunes , =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= , Daniel Vetter , David Airlie , Donald Robson , Frank Binns , Maarten Lankhorst , Matt Coster , Sarah Walker , Thomas Zimmermann , dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm/imagination: Defer probe if requested firmware is not available Message-ID: Mail-Followup-To: Javier Martinez Canillas , linux-kernel@vger.kernel.org, Maxime Ripard , Erico Nunes , =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= , David Airlie , Donald Robson , Frank Binns , Maarten Lankhorst , Matt Coster , Sarah Walker , Thomas Zimmermann , dri-devel@lists.freedesktop.org References: <20240109120604.603700-1-javierm@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240109120604.603700-1-javierm@redhat.com> X-Operating-System: Linux phenom 6.5.0-4-amd64 On Tue, Jan 09, 2024 at 01:05:59PM +0100, Javier Martinez Canillas wrote: > The device is initialized in the driver's probe callback and as part of > that initialization, the required firmware is loaded. But this fails if > the driver is built-in and the firmware isn't present in the initramfs: > > $ dmesg | grep powervr > [ 2.969757] powervr fd00000.gpu: Direct firmware load for powervr/rogue_33.15.11.3_v1.fw failed with error -2 > [ 2.979727] powervr fd00000.gpu: [drm] *ERROR* failed to load firmware powervr/rogue_33.15.11.3_v1.fw (err=-2) > [ 2.989885] powervr: probe of fd00000.gpu failed with error -2 > > $ ls -lh /lib/firmware/powervr/rogue_33.15.11.3_v1.fw.xz > -rw-r--r-- 1 root root 51K Dec 12 19:00 /lib/firmware/powervr/rogue_33.15.11.3_v1.fw.xz > > To prevent the probe to fail for this case, let's defer the probe if the > firmware isn't available. That way, the driver core can retry it and get > the probe to eventually succeed once the root filesystem has been mounted. > > If the firmware is also not present in the root filesystem, then the probe > will never succeed and the reason listed in the debugfs devices_deferred: > > $ cat /sys/kernel/debug/devices_deferred > fd00000.gpu powervr: failed to load firmware powervr/rogue_33.15.11.3_v1.fw (err=-517) > > Fixes: f99f5f3ea7ef ("drm/imagination: Add GPU ID parsing and firmware loading") > Suggested-by: Maxime Ripard > Signed-off-by: Javier Martinez Canillas Uh that doesn't work. Probe is for "I'm missing a struct device" and _only_ that. You can't assume that probe deferral will defer enough until the initrd shows up. You need to fix this by fixing the initrd to include the required firmwares. This is what MODULE_FIRMWARE is for, and if your initrd fails to observe that it's just broken. Yes I know as long as you have enough stuff built as module so that there will be _any_ kind of device probe after the root fs is mounted, this works, because that triggers a re-probe of everything. But that's the most kind of fragile fix there is. If you want to change that then I think that needs an official blessing from Greg KH/device core folks. Cheers, Sima > --- > > drivers/gpu/drm/imagination/pvr_device.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/imagination/pvr_device.c > index 1704c0268589..6eda25366431 100644 > --- a/drivers/gpu/drm/imagination/pvr_device.c > +++ b/drivers/gpu/drm/imagination/pvr_device.c > @@ -295,8 +295,16 @@ pvr_request_firmware(struct pvr_device *pvr_dev) > */ > err = request_firmware(&fw, filename, pvr_dev->base.dev); > if (err) { > - drm_err(drm_dev, "failed to load firmware %s (err=%d)\n", > - filename, err); > + /* > + * Defer probe if the firmware is not available yet (e.g: the driver > + * is built-in and the firmware not present in the initramfs image). > + */ > + if (err == -ENOENT) > + err = -EPROBE_DEFER; > + > + dev_err_probe(drm_dev->dev, err, "failed to load firmware %s (err=%d)\n", > + filename, err); > + > goto err_free_filename; > } > > -- > 2.43.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch