From patchwork Fri Oct 20 21:10:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 156327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1326388vqb; Fri, 20 Oct 2023 14:10:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwtjUVC9BuGMgW92VCjnu3OXHZUSfTEwi0WPYTk9dZBF9WMS26Rro84O9MsBf2gfHgZ54f X-Received: by 2002:a05:6a21:3e09:b0:16b:80f2:c234 with SMTP id bk9-20020a056a213e0900b0016b80f2c234mr2736174pzc.59.1697836252704; Fri, 20 Oct 2023 14:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697836252; cv=none; d=google.com; s=arc-20160816; b=q1cPwkTbwzmNNMb4oEyWZwJtJZo7VONQQQqRoW/xuTN9bt5nOHhH+w8xzUi28gA1xK 6gVGK1D6jF5L85apqUD7fVtnr0sJHzNXEwGSPMkYNUmmf+T1KzGoiauJ8faWvIjDArN9 g8nzoqTBJWD0AxsKrRVdtvfWFlBAGRGre5wAE11/VIQ34BgV7sZSfDFL0Hxk8zVgOcpw GsCzsjDYfZYWmfgenpS0hzuW3925lR8j6QHBhZpNIG4pqsaqLLEHSD3BFC8is6r1T/Ka jL2bv9FHggUASmJk/VkB0c4SiVs8QtqMC267jWp34E2bhOxFjefh2eJLLvcnSY1veVsH sorw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=S6/Fy0pNLDZh1Pz5HdACQ0UFHOE+/uRRB4pPQ1TD7LQ=; fh=mlGq6PayYEZsp/+lQoaQb08ZaGzsJscMQg2+wc8B3Uo=; b=z5ywrH7GAs5twqk+5lY2oFV0hHiLctlWNJasuw0g+O2aA8a0T2XHtA+dKOU0OpYhJ0 Fk4tW5LU4xcCEHh0xyhXXKohYQAuRVesTkqHESdMSidLCQhPQg35y4bBwKAEiJ3axXEc O0FdYqxpKE3Hsai1LFaZaQYsmrfVe9N6lGpIHJz1TcilZI1IVbZAYplSCr1Yn1VUx6WO nUAcgtF6c6JDLu6ie1n3mZXG1ULXlFjrk0WvuWjljEHgwhh0PvXV2lZgXy/Vuni2HHsz fbvs7IgqdqkmlvK62gyhns1//uhtX8rXnO4ot5SMD+2AP+Djq7ebO/7O07HfbLhLgKaO B0fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=l0h0XWVy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t12-20020a056a0021cc00b0068fee0e95c5si2620273pfj.89.2023.10.20.14.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 14:10:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=l0h0XWVy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B5B6881F45D9; Fri, 20 Oct 2023 14:10:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231205AbjJTVK3 (ORCPT + 26 others); Fri, 20 Oct 2023 17:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjJTVKX (ORCPT ); Fri, 20 Oct 2023 17:10:23 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3787D65; Fri, 20 Oct 2023 14:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1697836210; x=1698441010; i=w_armin@gmx.de; bh=uRnwDf6Of0uAPcllrrMhpGXZv2PanoNd1waM9WBipU8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=l0h0XWVyHecDfmmCe1/+9xVV/wYB2X7OngQFh1C034ncZlU6QrnuVP/jk6TPlMIl ZehJh4p0lu8TNL+00DNcqonvOIsFwDauq8fLKkGyoHE5KXTLVMjC+8Cwtdgplfr3K tjw84y+O84Iil1Bj4UHYfSCtdoQLe5jwHHZbRb5SLVu+5E4yoS2k2rGAP+iRbXd3K Li7CkSCt0L2JDFcGX5cGoMSVQjLlaUyAaHt3wXBwRIluoxJYcIJbjAyaO/9q205oD uk7LRqka7SU2SgfQheUyiSxiHX3IFNKoODUCbMfi/eCK9pVhfSYmfrbIgUM+Man1J 5knDwNEGZIzu7ZOF/w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N3KTo-1rb9fs2Lly-010OUt; Fri, 20 Oct 2023 23:10:10 +0200 From: Armin Wolf To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] platform/x86: wmi: Decouple probe deferring from wmi_block_list Date: Fri, 20 Oct 2023 23:10:01 +0200 Message-Id: <20231020211005.38216-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231020211005.38216-1-W_Armin@gmx.de> References: <20231020211005.38216-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:6dQMVSVphIRvnujeRXnlY4Qr5ASviy1sLJIfGWzzFdXw7JSRk9V 8pKbyk2iRglL6V4WT65igsqB8K5Dg2RXvW23LNZGa4om4JUqEswiTvbKrTZHEPi/9o5S+HV swtKEaJEoySLrWEjzmnZuVgEB/D3sazAU76kNP6gnWkF6/qDI0vWiBEouEVSY9vGvT6UA/t wrtMSMu4Qo4aRHfLGHeAw== UI-OutboundReport: notjunk:1;M01:P0:wyNBUrTn46c=;IzbI2lINEjrNfl4vkSy6TdZbmji vFMO9f17uSgWBQpFD+w0citaQ4cBQOuIbL+9lNB1/swnJzY+tKmXJMA0h9STBaEig1X2pMNVs wEHzuQy6qESDUVBq+UXTWR4NAEBS1gIEe3owKQsWGrn0AmOXyn59vZ6HXQLucilIPSPYV8K3K vGT7ibo76NhDn8WEHkmDz5r3o8vXfKlXNlBYHhCS5Xmfe1SWXoSHDmNbd+YwiHGTLCJn8Nnlj QNSl8ezU+oq0In7Q8nZkAH/nlRsXwSlgw61CfzRyYUDuyVA/UZ9vfzK3BbXI3iTlHcQtBCsWR 3ltaRQN3XUAxGc6SbOD5SvYVUk0dHGR0BwWIXuFn8aHtN/2pu1T5L7D5C3goGBHyhuY6nmUNe 4qVhmGpi4Z9dlPX48wDa0EbZO4J5QoO8RuHy0tXdQ4II3JhIJPPO3zNhzbqBXRYW83jU/vCW7 WTIrHwm7iW/Up5s6ogN7tLE5wPF6VzGpkarKxDqOepuKG/aM+Kf+y8E+ueX+5/f7MjKxS4A6L Lfud6UG4n3I0cS97di5r12XraRH/Y0P9RygQkrRXxr2wFekPOUoIZq9Lf5pQGoEYrAaOVOFf6 p9vMYId2LHdyx1j7VWZI5TF6R7po4tSsv222qFpsFDeSg4Z3qLLGYC1sy15Em4v4T/F6PFPtZ 0AUG+2j1K8prKdGavVFCV6t4YopNGn7DStrC4nZUbnvcQaUWUtgvJwp5MDDn5riLNUIJdDhfQ XBKjG1Nfu8QywlUXGduuINbKGoKI4khABB7WEhDSvIL4DarsVrGHC8IdS8jCRgxHpM9scb9PG vZ4PvWmFxCr20m8bDMPj8Xb953hMc0DWeiYJtsbhqUSy8z391/pHLbGRzNTzhmKuf2UG2vid+ NR2BR5e/NKu+IWcU6ZIG6hJ4mLGmJ6siXCKT3o1vWn2v0f8XNi26hvQUcK1Qvtuseip9DO9WD JNA7r8YtUDrGeJAO1AYOPjhF3Ug= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 14:10:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780310346738001177 X-GMAIL-MSGID: 1780310346738001177 Many aggregate WMI drivers do not use -EPROBE_DEFER when they cannot find a WMI device during probe, instead they require all WMI devices associated with an platform device to become available at once. This is currently achieved by adding those WMI devices to the wmi_block_list before they are registered, which is then used by the deprecated GUID-based functions to search for WMI devices. Replace this approach with a device link which defers probing of the WMI device until the associated platform device has finished probing (and has registered all WMI devices). New aggregate WMI drivers should not rely on this behaviour. Signed-off-by: Armin Wolf --- drivers/platform/x86/wmi.c | 39 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index a78ddd83cda0..1dbef16acdeb 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1221,6 +1221,26 @@ static int wmi_create_device(struct device *wmi_bus_dev, return 0; } +static int wmi_add_device(struct platform_device *pdev, struct wmi_device *wdev) +{ + struct device_link *link; + + /* + * Many aggregate WMI drivers do not use -EPROBE_DEFER when they + * are unable to find a WMI device during probe, instead they require + * all WMI devices associated with an platform device to become available + * at once. This device link thus prevents WMI drivers from probing until + * the associated platform device has finished probing (and has registered + * all discovered WMI devices). + */ + + link = device_link_add(&wdev->dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER); + if (!link) + return -EINVAL; + + return device_add(&wdev->dev); +} + static void wmi_free_devices(struct acpi_device *device) { struct wmi_block *wblock, *next; @@ -1263,11 +1283,12 @@ static bool guid_already_parsed_for_legacy(struct acpi_device *device, const gui /* * Parse the _WDG method for the GUID data blocks */ -static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) +static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) { + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; const struct guid_block *gblock; - struct wmi_block *wblock, *next; + struct wmi_block *wblock; union acpi_object *obj; acpi_status status; int retval = 0; @@ -1317,22 +1338,14 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) wblock->handler = wmi_notify_debug; wmi_method_enable(wblock, true); } - } - /* - * Now that all of the devices are created, add them to the - * device tree and probe subdrivers. - */ - list_for_each_entry_safe(wblock, next, &wmi_block_list, list) { - if (wblock->acpi_device != device) - continue; - - retval = device_add(&wblock->dev.dev); + retval = wmi_add_device(pdev, &wblock->dev); if (retval) { dev_err(wmi_bus_dev, "failed to register %pUL\n", &wblock->gblock.guid); if (debug_event) wmi_method_enable(wblock, false); + list_del(&wblock->list); put_device(&wblock->dev.dev); } @@ -1487,7 +1500,7 @@ static int acpi_wmi_probe(struct platform_device *device) } dev_set_drvdata(&device->dev, wmi_bus_dev); - error = parse_wdg(wmi_bus_dev, acpi_device); + error = parse_wdg(wmi_bus_dev, device); if (error) { pr_err("Failed to parse WDG method\n"); goto err_remove_busdev; From patchwork Fri Oct 20 21:10:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 156328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1326404vqb; Fri, 20 Oct 2023 14:10:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwCMejWsxwwaa/BHP8Sf7yqGi252f3Xk3tx7GYQ1NZs+tNKolPaO6bzjtHYH6+aYeOFK6c X-Received: by 2002:a05:6a20:daa0:b0:17b:8404:96d5 with SMTP id iy32-20020a056a20daa000b0017b840496d5mr4073862pzb.21.1697836254144; Fri, 20 Oct 2023 14:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697836254; cv=none; d=google.com; s=arc-20160816; b=qzt6YYJxwnByd8L2duAWpDAA6Rgk0fAPJt36KSpZBARQgo3tTFruyTAeAs+OsvyNFg zl46vU+up25CygUAwQ6o/U6V2YabDeiBc7cSwb5AeW96SR9mgrH7LaZcl+5/PYY/nrTb oXtCzYXmd+jbXBkwEgC2is0Z3QYEdCwMwO9uHvLUfPNB7ApV2kz8xGn3ptu8nPM6NeZw IXZ8Hz7i07cK09KWiWYR6B8l25lFedJfDaLPpK2WGxbT9N/g9ngZiQ0XRtWt4+zG9lxf KMG0SN0PVsi6awyuYT6foXQPRVsHaYqm3TTKVCZrq/99eSmGy20kigzc4VNavznJkGUl ui9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9Ook8IfyQoydJxFII3cfCezwFTXYvOl5pC/HrusLMZ0=; fh=mlGq6PayYEZsp/+lQoaQb08ZaGzsJscMQg2+wc8B3Uo=; b=wn7394t/5huk3JS6KV0zU0+lLfhYhbd5gbn4eDKRXV0M1bHqoEg7sI/MLkUq4/zW2y mJ+IHBPU36gzKDRufEcf4G8L1OpCZzgISO/I6cdx29MD6Pjq3a9GvratUYAskuWc0wPY 6ko9iJAFnQEJnChjBq0qgf42zjqevLFjmrO/YotNfkBCZW2fsWCeaBHPZ82Q/J2Viy9R JKpsjYWRXDBTtvZgSMfAMtZNg5hysM+I0lpf2VeynIEQUcJgAE3jvNHVaJxHtNfw+cq+ fmaSYqw5HUtiLbu9Z8G1oMOX93lIP5bK2BXUzL7UrFOypXF5ZlxAB3GneYlcVpQwMmNR rxuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="Eh/dJbbs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id x21-20020aa79575000000b006b4319c78efsi2602136pfq.389.2023.10.20.14.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 14:10:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="Eh/dJbbs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D89F6830D125; Fri, 20 Oct 2023 14:10:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232850AbjJTVKj (ORCPT + 26 others); Fri, 20 Oct 2023 17:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230318AbjJTVK1 (ORCPT ); Fri, 20 Oct 2023 17:10:27 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA4FD68; Fri, 20 Oct 2023 14:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1697836213; x=1698441013; i=w_armin@gmx.de; bh=mQwZ7HovL0XAV0BMMBNTr9Ft336d/JL1LOfzD0c2oJs=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Eh/dJbbsnRvIaOb/QLKYI3GmINne3a2xuiYHq0DnFEeiRyeVXFKSVIH5KFTL36NL YhCkhm4rb9bpQKtdF4VhUw1u4xfoJHS61lIpHA4LhdXdifi4zLhBBrx5GQAEZKZxJ 3i/TNQjYfYrfWgkOZLRIY9vPLNqhxL/zLKnwmui4TwgE8b6gamhjPjSR1NxEz1Az3 QNNpDYZVucwLuOk0RjHFPuhZ0I07uHPsh0ZK3k79EhOKgGFyY3K6hFok0xalXCbc9 Vd9xuzZsanyFIXCXmLSk25A07/CpbaFfgB2JzyXvOpP6wvKSNB46L54z3KHcC9G+O irYXG4blPWRoojIkoA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MCbEf-1qkqCl3eN9-009exu; Fri, 20 Oct 2023 23:10:12 +0200 From: Armin Wolf To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] platform/x86: wmi: Fix probe failure when failing to register WMI devices Date: Fri, 20 Oct 2023 23:10:03 +0200 Message-Id: <20231020211005.38216-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231020211005.38216-1-W_Armin@gmx.de> References: <20231020211005.38216-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:K8Pj/GqNVdzXRi5ZvkOjbKr+5ZLjUujG7t6fVgbkc3m717NSP6V Y18A7m5/H1ElSS70TACGg0s4+zszPRBQdNBmlSu0yntNwkakCl+vkswZ37THoqauK53Njnz /M7Bg9mj/7UtKKdoM4//HwY0UWMURUUPyaWGdbuu9iMyUxHJUCO01yvvfvMYKjwQN7loDml 8XDfdskdYda4YvnAV/BaQ== UI-OutboundReport: notjunk:1;M01:P0:drImnaOOQ28=;AA/Bxy6dHJnX38U588CRcqYdFvo /jRkmv+JeN8SLIm4kh3GrVJAbSRyVKOBXH5rZP1EUYIKjo9Ew9rtrrZ8Xq0dTNAClLUAcYPMc 15uDjz66NLlLeba6LnOkydhmnz0NpZoyuR9U65hNEs/Nv+lF6USmavIXk9X90W0T+4e29nKA+ pPwaQKJNnIhibLU/IG6zcIVZzIrGR9Zsa57t3G7o208+UeN/3+InO3gvi5OIsz8NwkI83XKZ6 iWSwyvB67f/MrAZC1Bu6jsk/ZB3O3K3PUWZhWEGruED4U2Cqm/v3U/2WeF1jsKg8mDi1r9eFN PNpt89hteaJMaB4UT5uG17PA3pOkykCp1V3xOBdO9+zNJ1odVYa+0ss3qyXgXkSvwQacWnHmd 0yXKxuh64CCjfwVvXMM1Y0TtNKkw8Bx3q0cY7YGTI10OqHdzvPtswozKz/0IsyQe+++uvTRvt 7iCR0xMLnFTO0THocJShK2apS9uNfCuip/ADLzuzN4ssllLIN2trWFNrQ1ljqvid94AnZHhvg 4QikppiZspfFHJgxfYKNsDgEAOP1xq+pfGx2mZWmax/0W9MOXMu893F/twuDiaOSDTYc9JOK7 slGnwqaaFCiFwxeREF8TFd7GaqwRF/7uY7dI5RM4NaOT04eOf/e3jonbtGY7em0DDREc+9wxs 0IPZHIobq9f255Ipt1tWX70EDB39we3NzzxTvDSpmVXowfwLl+3flcA4xt7W3cWdBQ9B7kaZS iHNtOjI3MAs/Vlhj2OjEQN+ZjcK/R915Fi9OyDaQuobHi/lPv8W03HKqmM2Lt4qUQnLXNHLZ0 t/WujHUiHtTuIaH5Wzv561NSywc8t59TMa6zGv7rho7ZpHVtBec7G3OD+jqq0KmZa9eX5NRuk rRqAAgBikONjg0qlaeM01CRubWhUDPUHjOk9BxoEkKauQ3bVROT4gFT56myYBegwMH5vPM6Ah jqLnp+HT3Zyh7/KvZmcsj469OOA= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 14:10:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780310347869238933 X-GMAIL-MSGID: 1780310347869238933 When a WMI device besides the first one somehow fails to register, retval is returned while still containing a negative error code. This causes the ACPI device failing to probe, leaving behind zombie WMI devices leading to various errors later. Fix this by handling the single error path separately and return 0 after trying to register all WMI devices. Also continue to register WMI devices even if some fail to allocate. Fixes: 6ee50aaa9a20 ("platform/x86: wmi: Instantiate all devices before adding them") Signed-off-by: Armin Wolf --- drivers/platform/x86/wmi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index e3984801883a..ab24ea9ffc9a 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1338,8 +1338,8 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) struct wmi_block *wblock; union acpi_object *obj; acpi_status status; - int retval = 0; u32 i, total; + int retval; status = acpi_evaluate_object(device->handle, "_WDG", NULL, &out); if (ACPI_FAILURE(status)) @@ -1350,8 +1350,8 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) return -ENXIO; if (obj->type != ACPI_TYPE_BUFFER) { - retval = -ENXIO; - goto out_free_pointer; + kfree(obj); + return -ENXIO; } gblock = (const struct guid_block *)obj->buffer.pointer; @@ -1366,8 +1366,8 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) wblock = kzalloc(sizeof(*wblock), GFP_KERNEL); if (!wblock) { - retval = -ENOMEM; - break; + dev_err(wmi_bus_dev, "Failed to allocate %pUL\n", &gblock[i].guid); + continue; } wblock->acpi_device = device; @@ -1398,9 +1398,9 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) } } -out_free_pointer: - kfree(out.pointer); - return retval; + kfree(obj); + + return 0; } /*