From patchwork Tue Jan 9 12:05:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 186342 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp59970dyi; Tue, 9 Jan 2024 04:06:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHI1zCgIBdVMrjpXkHvNVPSC32jPxkl1KrFWaOOtTzP3h+XI0i1FWTP4n2G6FR7oFDHYDeu X-Received: by 2002:a17:907:9286:b0:a28:b7c1:b146 with SMTP id bw6-20020a170907928600b00a28b7c1b146mr274410ejc.58.1704801994419; Tue, 09 Jan 2024 04:06:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704801994; cv=none; d=google.com; s=arc-20160816; b=YvnrAkCKIyf+rVThZzGCZ5YGplMtFq1vZ145VW33+kQ19zXai9eBdW+qUpzTOH4QnW gx45E9ePUlL1LHeRqqMA9n00vK7hDeVfiauKGn6wg3xnvKWsA7ELRGe1SBLPlO6hqT5j lkxyH6Et9F5mQwvtRvTubNY5E8wem/KJwBSyg2Aq8oCCCGivkCRt/rGnT5QBh2nqREoR cOX+m+1V/s3REs0JpvSUZnBGW/HmU3CF70CuHBIk4jElRIzRQO+lT5vs6Lk4+5CJTxSf E7gPynDtYZzPBOgOn39qhedIaBV78k5pSo9DZj89PB4z+/QgRyZqLLVPT1CgeZGt52hG m04Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=8M7Gv5IVBBA2mbcRwXaGm3ftRkiaPEEV/XwtkM0luc0=; fh=Wk93wXGQ9naUS5lYx24CHg11kWDmgBSXxDJ3vUkTOL0=; b=NKugQZ4SB1xgHYj2GpMU3kTS38hjmyXVO5AHZjLKSJiTAR7s/Eb6LFsxh4EiqRMWNN oDqvq7iIeizKTMhwvWGihkC4GVnH62EEO0lcOt4aqtUowkLYM2AHm/8ulcwGHHjsJdOz zrl8tjgzVR/uUk05mGOq4SeBhMTRx9gErhgK1G8F7IlCyKFDheUrwXQixNUTpPXFccY9 a7ZZf/RF2aJBGO4a/L8c3NBRXStVuaVSLhHUN5QlRFIYryOlmQlY7G8uoi/oN+n2z21Q l4WrEFMkm6WEVuft8BBQ0pWvy0JR1o1G8DkfNLgG3CVZ5JkyL3c1+rst+J+PxY/qF/7F njsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gVeHUeHm; spf=pass (google.com: domain of linux-kernel+bounces-20825-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20825-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l18-20020a1709061c5200b00a26b02a74afsi709207ejg.66.2024.01.09.04.06.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 04:06:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20825-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gVeHUeHm; spf=pass (google.com: domain of linux-kernel+bounces-20825-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20825-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 0D7BC1F21244 for ; Tue, 9 Jan 2024 12:06:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 797B6381B1; Tue, 9 Jan 2024 12:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gVeHUeHm" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B950374C4 for ; Tue, 9 Jan 2024 12:06:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704801974; 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; bh=8M7Gv5IVBBA2mbcRwXaGm3ftRkiaPEEV/XwtkM0luc0=; b=gVeHUeHmD/X9OPza+F9FIi+6nL3lxqeAHTxnX9Y8psrKcfw1SEg7ap4e4hZXAEqwJhK6fD 5vm2DntaOHP/jw67m6z0QP5I8rkiRC+7RUAAevyTFkRkCq+IReHrcOjXWYzjkEYziGM7XQ iDmDll+odTWM/Os+BSxSJ2GL4Ekn7xo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-eJNqjcGbONKt1edTNc8k1A-1; Tue, 09 Jan 2024 07:06:13 -0500 X-MC-Unique: eJNqjcGbONKt1edTNc8k1A-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3368698f0caso1837457f8f.1 for ; Tue, 09 Jan 2024 04:06:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704801971; x=1705406771; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8M7Gv5IVBBA2mbcRwXaGm3ftRkiaPEEV/XwtkM0luc0=; b=LKY/Gq31pfINKXezIezLHilEE3VlpJPVPvyKBeOl4OCB+44MKh4PSrXWbXx6kq3pla e4k7szMY3jpb96AbllExzz2Ib/gNJhpSP0znlomcIr4H/KlMLsIWb7kAcc38Ry8cRJYx d+DAFZwtXVcYu1ZLAjgX21CFR8tBXcs4dY+TJJW/bliCt4g2fh/jNZhcuXnuK7+1IDd0 5ynpRCDd382A8Q472Y8UFPKDqzDcVQAbU9/QhuIvufnaIuAfHwA4W7txsYW2sJlCXU+3 eIfKBfIn66qJN1QwyJm7kuzK9V21ZFdkFYmiVfhYW0OJv7Vvm/1LzNce+XCjkPZ4s13Q PMlw== X-Gm-Message-State: AOJu0YwtJgP+20FGl53AtT9vIVlKTPJ0uVRnC2ppJIpAircFWNdIR129 teVDsHoXCNc7r1BHbv54pbxB4f/BhhE6iR9oTixi184+9ydtYyyFHkUDoMHDajqfNuTcYclCljA AQ/XuSd1u1rdamScwaTPkOs/mleF/QbHTpgPAzwPbiA3hjd9EQkqY15Sm9vjyxLd53aG0hsIS8/ 1WvLrBFlJwjt6P63o= X-Received: by 2002:adf:e4c4:0:b0:337:4a10:ea3 with SMTP id v4-20020adfe4c4000000b003374a100ea3mr317800wrm.186.1704801971238; Tue, 09 Jan 2024 04:06:11 -0800 (PST) X-Received: by 2002:adf:e4c4:0:b0:337:4a10:ea3 with SMTP id v4-20020adfe4c4000000b003374a100ea3mr317783wrm.186.1704801970911; Tue, 09 Jan 2024 04:06:10 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id h16-20020a05600004d000b003367ff4aadasm2250543wri.31.2024.01.09.04.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 04:06:10 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Maxime Ripard , Erico Nunes , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , Javier Martinez Canillas , Daniel Vetter , David Airlie , Donald Robson , Frank Binns , Maarten Lankhorst , Matt Coster , Sarah Walker , Thomas Zimmermann , dri-devel@lists.freedesktop.org Subject: [PATCH] drm/imagination: Defer probe if requested firmware is not available Date: Tue, 9 Jan 2024 13:05:59 +0100 Message-ID: <20240109120604.603700-1-javierm@redhat.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787614456150635060 X-GMAIL-MSGID: 1787614456150635060 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 Signed-off-by: Javier Martinez Canillas --- 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; }