From patchwork Mon Feb 19 11:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 203027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1234226dyc; Mon, 19 Feb 2024 04:02:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhcMFTcGqQ6A8NbHE6FBqqsi8iTQDkQNvMx+4Kts77Z70wxfMXZa7BZxI11wxAnRSAZn3MftZhvYmkm+xHK4T9wmBx1g== X-Google-Smtp-Source: AGHT+IEqGa8RKfiAEq49sa9N+uBKdQM8zPS7pnLd+ey7Gna2CNf0pTdcSz6jbaNdZAikEtXDH+LT X-Received: by 2002:ac8:5d92:0:b0:42d:a884:7dfb with SMTP id d18-20020ac85d92000000b0042da8847dfbmr15044900qtx.2.1708344143600; Mon, 19 Feb 2024 04:02:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708344143; cv=pass; d=google.com; s=arc-20160816; b=qesbqOD1VHGwRpnQBNbD1/CQbS5bGqOt9Ib0v1XsCmmqKT0ZpLJlKH7H6HWPLwDJmG Ggy1FGO9ngyKxtDAJP+V/YwArhIGUzoOJ4xLspA8pAgOzeZ3pBTuY7wukeZL8Ln/UjKQ /zoGESyhDrrNb/t9Ktf4Nl43+6w2wFUf5EPNNlqw0iMuEXNve7ff4UMkh1ynpIV+ldn4 3Ls8TKUiIh/1+P7FM5MjOY5+jaVvWdWEgXdFLePmIUJ8WiwemGggle6GhXpnbhHiA0d9 rczyTAIz9ipU86YbnC05+tVSBJmrOCJIkMuggl3dvYHJxABq6CPtvy6y3R1SIcOPyz+6 o//g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=sDqMXbzWpbge87uDu7Ez2KfwzTGSushLHKwBsyx5VEk=; fh=53tDE54uAbGWTgaegrI/oOrsTh38Ao2IXD0IrA5mCUE=; b=AXTNGiPBzzQh39bTPkqsrcs1sOYSQXW1SDOdWOleNN7Z31IGmqnlDN76w/KyM7XJiP pft4l8SISBgsGEz/4fwaoiz0DOoxGi/splBnGjf12EVOHOzjlR10Zgeej4QWKbHG34kB IdoWR9f7U8aogmGftximRNc5izorSjnt2xbqdYX8gyGPR0BlAEIMAcTZQuI9Da7A0m/U EpiAUyQGRmcmN+DZVmP5WHk7IdW6jQMnqU58MO5QCETS4f+UyzJJoH1DR3APTsyY/Djl 0P4iqEh6zUefB+GoLjRMZxpc0OkqLW+ZH/ve4qFR4xheRvLTd7fjXT/QekKMjIwt5Mkj FoqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Ms65bXKh; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-71264-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71264-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jr14-20020a05622a800e00b0042c44c065e6si5734327qtb.733.2024.02.19.04.02.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 04:02:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71264-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Ms65bXKh; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-71264-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71264-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 58C8E1C23698 for ; Mon, 19 Feb 2024 12:00:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 44C8D32C8E; Mon, 19 Feb 2024 11:59:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="Ms65bXKh" Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 B43552D60C; Mon, 19 Feb 2024 11:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708343981; cv=none; b=WaguCnGqZXHuQ8Hk7TSV2iduCGE2gwiiCjZQ/q1x+o2tdkr04KEbWpMxeaqWAaBo+HBMVtzC8tqq7gwpe97holtDvKTbNmFZ+Wd/F651xKvNJLox3yrErDdFkEPdTWAZBH7LF/Usjjiaq85I/Zfc9CTa67z131bzQBjT4ki0y5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708343981; c=relaxed/simple; bh=Mp9hOgHSBLyn/IkdgO0pLAaR0KKQJX46nMeFoyl+HGA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ub8QomU3fhbTKHDBJWp1uXtEMvOgwc2iYr1+lc4uICbi2uTWe6vbpPSip2LIxpEF5Bp2DEi/xr6CWiIwBFZgLoiEhkqjNqkQdhq23UXVanX7MOV9W/IePcj4VjDXDVGXJadgA9TRbgVgSZp4JVFJdQLg2DjxlXufU4Aa5wGJqec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=Ms65bXKh; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1708343966; x=1708948766; i=w_armin@gmx.de; bh=Mp9hOgHSBLyn/IkdgO0pLAaR0KKQJX46nMeFoyl+HGA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Ms65bXKhzTGXO41frnXR++7fkeAcC4cH9oR5mmV0AOKnCdYG6BIBR6VU9NeFBWPH OghH2LUDssNzsUYfdQfGK3xw1NsAY10evPa/FdRkWzEnLv2i8eH+UTPj7cA5Wrkru e/G81k5Iz0yAUp/56M+oK0uHDVN07x+fa5lzOisNvM/OawtWbSyLBLvKjhA0HTapm eAkCmcYlZZ/MkbFYj2TsS13gb/jBT6VtCgd9bw0Lq1ez/GkklufEyYbJFNMCX2H9W rDmMaS/bav2xhinbtM7suBOwnhqYrFuhFZYO7AjjAKjGMHDaqJdlTCeHjS6iRLdUv /P/kL3IRi+SjcuoibA== 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 (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N2V0B-1qwd291vP5-013sCi; Mon, 19 Feb 2024 12:59:26 +0100 From: Armin Wolf To: corentin.chary@gmail.com, luke@ljones.dev Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] platform/x86: wmi: Prevent incompatible event driver from probing Date: Mon, 19 Feb 2024 12:59:15 +0100 Message-Id: <20240219115919.16526-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219115919.16526-1-W_Armin@gmx.de> References: <20240219115919.16526-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:8mOAKKOQfSiI7qUYZqObHAvj7W+O+jwuXvBstGidfNlbqOkaW1v FGMjUDnZbFTCDGvotT188mA/iUzsuFn7+Lz4mIbOZc2zFQ5mt4o2xP7YKWXQZuTPy5YMneU EScEkSubl2UCFkA/yJrxLRVOBI4Q5u1yETJTYNXpxlXMdZh9lq3T/qa9JTfHEHwX+vy46VS +YrF5CLPC+sGCfj14FOrQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:v4V1t7bD45w=;MRvAHFwlkPrjiWrjqJAfBfpOjLo thiBgDIKGaWlqLb1MiXL9Hy/gUQaaHe5kIO5iyKm9wNxvmOB+ZjjigZ9k4ylWJ7hZe8t/3YFS hM99gHOMSdS1zF/Z2MIMprlISG9TA01+OMmrZfQDZOR9lRfZQIaWNKVdDJ0Ww58mPI3N7MS+H dLllHwZVL32gbfc6JTY2p6uGBhCP50iMbPULyyq9KYVYIYf5HexHcTjuDSsfuhPPkleeiZBl2 NQ9jdfd2xMeX+rmHVtvXFSBjD87rkFt3av+I57Fs9vaQa8+fJ5hW54z5atvEC1oHtso4fyart oTTz4/A/zG56gEpV15MeRz0FZrZHi1uOIedIQv8ahvoD2GGrh+DLR/rPQhtPVZo+K91iIdptT 8xgXBj+8aiaP7F3TuHpsYKnssPHwrG0mMg/mwmYtViSzSZoHNm3XRtdE0pex+VpklD1tCRHoo IgDCgbMFlqe6lD+7dVBPHIV5YxyItQhU5qFl9MzvDoc+QWNPD4fCUfwz4Ploc4+DW31kjZ7+6 FkRV96HQft6fE0E4zApz/Ml3ZYNL06DFWhLIiRcw85Q5tsqopSJ45V/PYTOAG8Tkc2OWVcrqj rNX8TioQAdVh1+wdma0vkuaE0/XnQjuxC0XHvLRvyeB7cDATn8k2GUcbsZ8+ZZ8iGboItemsX IvrKBlInugVQ6dV+HaEBHTTLe1HTr9wgzWoyH9fgWY2J2ArHkhoWsJP3mjqzUllve28sVulSr dLu/VxyFKrkRFfpAyzJ8y5G06mjfvcjaRLCIyDPDf/cSB3Ubij4ABaLGXZm8mkb160/fO/OwT C6ro+/kP3zq43TkVoSIvlxNOeYCfrnSTeBej/XT/oAjgQ= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791328668937179599 X-GMAIL-MSGID: 1791328668937179599 If a WMI event driver has no_notify_data set, then it indicates support for WMI events which provide no notify data, otherwise the notify() callback expects a valid ACPI object as notify data. However if a WMI event driver which requires notify data is bound to a WMI event device which cannot retrieve such data due to the _WED ACPI method being absent, then the driver will be dysfunctional since all WMI events will be dropped due to the missing notify data. Fix this by not allowing such WMI event drivers to bind to WMI event devices which do not support retrieving of notify data. Also reword the description of no_notify_data a bit. Signed-off-by: Armin Wolf --- drivers/platform/x86/wmi.c | 10 ++++++++++ include/linux/wmi.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 5a613b06b269..8fb90b726f50 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -57,6 +57,7 @@ static_assert(__alignof__(struct guid_block) == 1); enum { /* wmi_block flags */ WMI_READ_TAKES_NO_ARGS, + WMI_NO_EVENT_DATA, }; struct wmi_block { @@ -869,6 +870,11 @@ static int wmi_dev_probe(struct device *dev) struct wmi_driver *wdriver = drv_to_wdrv(dev->driver); int ret = 0; + if (wdriver->notify) { + if (test_bit(WMI_NO_EVENT_DATA, &wblock->flags) && !wdriver->no_notify_data) + return -ENODEV; + } + if (ACPI_FAILURE(wmi_method_enable(wblock, true))) dev_warn(dev, "failed to enable device -- probing anyway\n"); @@ -1094,6 +1100,7 @@ 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; + bool event_data_available; struct wmi_block *wblock; union acpi_object *obj; acpi_status status; @@ -1113,6 +1120,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) return -ENXIO; } + event_data_available = acpi_has_method(device->handle, "_WED"); gblock = (const struct guid_block *)obj->buffer.pointer; total = obj->buffer.length / sizeof(struct guid_block); @@ -1131,6 +1139,8 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) wblock->acpi_device = device; wblock->gblock = gblock[i]; + if (gblock[i].flags & ACPI_WMI_EVENT && !event_data_available) + set_bit(WMI_NO_EVENT_DATA, &wblock->flags); retval = wmi_create_device(wmi_bus_dev, wblock, device); if (retval) { diff --git a/include/linux/wmi.h b/include/linux/wmi.h index 686291b87852..781958310bfb 100644 --- a/include/linux/wmi.h +++ b/include/linux/wmi.h @@ -48,7 +48,7 @@ u8 wmidev_instance_count(struct wmi_device *wdev); * struct wmi_driver - WMI driver structure * @driver: Driver model structure * @id_table: List of WMI GUIDs supported by this driver - * @no_notify_data: WMI events provide no event data + * @no_notify_data: Driver supports WMI events which provide no event data * @probe: Callback for device binding * @remove: Callback for device unbinding * @notify: Callback for receiving WMI events