From patchwork Mon Feb 26 16:46:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 206770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2198391dyb; Mon, 26 Feb 2024 08:48:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVBHtTEcEbtUYp4JXkFTPQZvjd4MaQqSRbiUDojG14GH4mNhODez1moIOJhWCiPOljMWsW/L2S8q1nn3LW/BNnJNJSTDw== X-Google-Smtp-Source: AGHT+IE4rXNinyMZuc/oENxBxuWOtmwhwGg5eQkbaTJKfSLYeaS372O/MN7HiOqV6902wViYQRZn X-Received: by 2002:a62:f205:0:b0:6da:bcea:4cd4 with SMTP id m5-20020a62f205000000b006dabcea4cd4mr8128381pfh.16.1708966080935; Mon, 26 Feb 2024 08:48:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966080; cv=pass; d=google.com; s=arc-20160816; b=amq+3fbZFFZMmmzT9UTRW53oP2OuyV3GQE2FVfXDvoax/RGXTmCrv7FldivlVLYxKH vzYW59Vt7V8GF3b1d4oVV8YTugoVVhHwtny1gKOY/0TZ2Wr67+BZ8nVUd9ztUGqWOlOx i0V5okndk+QR4xjHuti4FrppsOuk2d0iBZMr3l7xvp74cg/UkiqKrEczgqwNFvhK1iVq PWO0Hj8BBXGSxuTdSpX3C3W4EGYLkRCXP8yzdDybkftaakHDJoJMfAY15x6nvt3lGzqD pjHphqxAp1rlDaQjKk6kteiuEjfHv1yI0Kv2preGxC+rHeb+T033b2Jly38qsKvtIcG+ 9Kzw== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=RNraMNt09Crz5/lmBH6okJFfAneomRBHG/dT9ZI9t+M=; fh=s5Fc0MEg8Xcp85xwyejK4S4zs7msQB7g1OY0X3YpOJg=; b=L7eWlNIHd2FRDP3YB+cU91qFKvPpk2/XocjFBWVFJka9hrFiSbLXfhysRjSb5lONso azT9oLojAdnLG+fHCVDyuEXdUWItQSjq61Pnd2O7FEFYikYhBOgEwGp4caZF4GbFR7pr +XxvDTW5N7F9a4S2/dnofjgcWOnCzz9+Rq3mOB1nGy70eMuVF5hrWvwEhjZFrKnFKqoA xkKIsRdfQnNsPAcpXslNtMBPjdIlcCHwS2oA5+csCbEOdaq3U2Ey7fPvayuCEPRU6ebM eq3NDbfF60ECEWtDQ5w90AWBjUz8cHgKXOfPsp34eSXWeLi9YQZ1gwwCrEbCQEfmhDa+ oyFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-81929-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81929-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ca12-20020a056a02068c00b005d8c245c500si4123889pgb.397.2024.02.26.08.48.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:48:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81929-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-81929-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81929-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 98E13289FBE for ; Mon, 26 Feb 2024 16:48:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0589712EBED; Mon, 26 Feb 2024 16:47:11 +0000 (UTC) Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (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 0E7E312C7EB; Mon, 26 Feb 2024 16:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966024; cv=none; b=hCfJv+w2eO+u5xcMt40eLAicjdM3xKnK3qvka76POcGyRZ7D16YFwaE0310L+mXLLxUgCpyqQmMAX5E/VsBPWk5vRKP9SW1I0+Sw3+jgg/CJaYWkQ0elZ0JR3WVlnI6bEK/Qy/m4SZ9yLbbOWXpUPRZqeWfHS2dPhpQjeWQFVzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966024; c=relaxed/simple; bh=TWH1mWeEyDwYEEfWcXxNAb+Yi2HEXBh8NMr9ZJ5qlNw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cg5E2PD7PZCvp8bJzP1JXnmzlr2vjZlyeWWf366QCoEVERu+Zz1Wfsp4oOXiUKdGTOzIgxLSUn/OGBqle7e8RY8VKSSOqaV7glehToPtTI+nTTMCpLj1vOIpjgfxgerzEfsBHW5h1iHJNsiNyBlNKABrQb8V4GAn+bfVrrPxs4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.4.0) id 85ad80cd23f10339; Mon, 26 Feb 2024 17:46:54 +0100 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id C751166A4D4; Mon, 26 Feb 2024 17:46:53 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI , Jonathan Cameron Cc: LKML , Mika Westerberg , "Rafael J. Wysocki" , "Russell King (Oracle)" Subject: [PATCH v2 5/5] ACPI: scan: Consolidate Device Check and Bus Check notification handling Date: Mon, 26 Feb 2024 17:46:41 +0100 Message-ID: <7632957.EvYhyI6sBW@kreacher> In-Reply-To: <6021126.lOV4Wx5bFT@kreacher> References: <6021126.lOV4Wx5bFT@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrgedvgdeltdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeektddvveeijeekveekvdffieffheeitdehkeekfeeiheffkefgledtheelhedvudenucffohhmrghinhepuhgvfhhirdhorhhgnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepiedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehjohhnrghthhgrnhdrtggrmhgvrhhonheshhhurgifvghirdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhhikhgrrdifvghsthgv rhgsvghrgheslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugiesrghrmhhlihhnuhigrdhorhhgrdhukh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791980816996047677 X-GMAIL-MSGID: 1791980816996047677 From: Rafael J. Wysocki There is no particular reason why device object subtree rescans in acpi_scan_device_check() and acpi_scan_device_check() should be carried out differently, so move the rescan code into a new function called acpi_scan_rescan_bus() and make both the functions above invoke it. While at it, in the Device Check case, start the device object subtree rescan mentioned above from the target device's parent, as per the specification. [1] Link: https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#device-object-notification-values # [1] Signed-off-by: Rafael J. Wysocki --- v1 -> v2: * New patch (split off patch [3/4] from v1). --- drivers/acpi/scan.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -336,9 +336,25 @@ static int acpi_scan_hot_remove(struct a return 0; } +static int acpi_scan_rescan_bus(struct acpi_device *adev) +{ + struct acpi_scan_handler *handler = adev->handler; + int ret; + + if (handler && handler->hotplug.scan_dependent) + ret = handler->hotplug.scan_dependent(adev); + else + ret = acpi_bus_scan(adev->handle); + + if (ret) + dev_info(&adev->dev, "Namespace scan failure\n"); + + return ret; +} + static int acpi_scan_device_check(struct acpi_device *adev) { - int error; + struct acpi_device *parent; acpi_scan_check_subtree(adev); @@ -356,36 +372,26 @@ static int acpi_scan_device_check(struct dev_dbg(&adev->dev, "Already enumerated\n"); return 0; } - error = acpi_bus_scan(adev->handle); - if (error) - dev_warn(&adev->dev, "Namespace scan failure\n"); - return error; + parent = acpi_dev_parent(adev); + if (!parent) + parent = adev; + + return acpi_scan_rescan_bus(parent); } -static int acpi_scan_bus_check(struct acpi_device *adev, void *not_used) +static int acpi_scan_bus_check(struct acpi_device *adev) { - struct acpi_scan_handler *handler = adev->handler; - int error; - acpi_scan_check_subtree(adev); - if (handler && handler->hotplug.scan_dependent) - return handler->hotplug.scan_dependent(adev); - - error = acpi_bus_scan(adev->handle); - if (error) { - dev_warn(&adev->dev, "Namespace scan failure\n"); - return error; - } - return acpi_dev_for_each_child(adev, acpi_scan_bus_check, NULL); + return acpi_scan_rescan_bus(adev); } static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type) { switch (type) { case ACPI_NOTIFY_BUS_CHECK: - return acpi_scan_bus_check(adev, NULL); + return acpi_scan_bus_check(adev); case ACPI_NOTIFY_DEVICE_CHECK: return acpi_scan_device_check(adev); case ACPI_NOTIFY_EJECT_REQUEST: