Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1249352lqe; Mon, 8 Apr 2024 03:33:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGJCWZn1Gc/l9XLfi8wDCbfO+JtWkNk6ytazS++KNf6QPQiJyqNv92PipAdR+zJeKdtNjTuj9Ob+qU+HuNqS5U2EcswF4GAHH7wv3Clg== X-Google-Smtp-Source: AGHT+IE4w0l9OfFCxiEK8Bi5TlgVkHRLpH4btItU9Sx299nGOvL2w9SjMxbKYeyV5Hv0PuWGwWUg X-Received: by 2002:a50:9315:0:b0:56e:2daf:1ee6 with SMTP id m21-20020a509315000000b0056e2daf1ee6mr5661829eda.16.1712572428576; Mon, 08 Apr 2024 03:33:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712572428; cv=pass; d=google.com; s=arc-20160816; b=I2aJZse64KkTCqvEnM5GiLoLgnQLaUOSD7GBABwnwcD4Q0KePKJaWo4Tgl7dgxHmAn tmYUvdvZ5Ho4kaRd1NS+ZX46++60ys7l9wml1u5JKWCrR3koN4fa0Qi/8LzvzwT8rmHU LMVOuy/zeaXhekpF21lgT+4b0VAyMFeYTii6eQCVgMz5La8IVotF5g9WenTBgufWUBCV dudr1oAHzuskSr1D22Vqlu+tVx+BkD9/GW3YdtXewvCmAOZ7RbSet0SnnVgx93Voq0L1 0tLlJnLtrFldgjg+sRQY4u3VkhpFZl0Wb9kZZKT5FlsccS808raKyyod7//bej4mInj/ EZsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=hphz2ky7JASmqSzC5TBbBdgSGD1DI1JxngEKY+2Lsac=; fh=NEWOf/+we8/Zjwaftxlxe8rDnT2wZWDhvUIAz5NXOAo=; b=qmAVTanlVwRF312CqV0gyRxqIhY4cJnRQT55Glevj/OlTAeTZEb2Pr6lNT0l6LyTPp spi0cafhWlq6XhFKzRgMpWtx6izvQPhk27lH0nWeZ6caCNaedKwZwk3BHqWyyX+m5df3 1WNnlTyfFBpljq8PbTowYti2XcbyjKmBtVC5qVEhqclq/XM1HBfv2XEH8Ickmq+4LNEk uO3WDz/2eKrhfHx5wQltp0vybSF268Kz5HrfapByh/ZaWPqRMQ6hvB9jrMAq3uGiSQnF eZcadkqh8livtM+mu5LZgERUJ+lL3pkw/9k75XoTTGZR0t8ETgO0Tpv7HgOZkIdiyJHL 7JXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ZZ/brF4y"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-135227-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135227-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z3-20020a50cd03000000b0056e0de084a3si3655608edi.30.2024.04.08.03.33.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 03:33:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135227-linux.lists.archive=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=@intel.com header.s=Intel header.b="ZZ/brF4y"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-135227-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135227-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 244E91F21A55 for ; Mon, 8 Apr 2024 10:33:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77FDC5810A; Mon, 8 Apr 2024 10:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZZ/brF4y" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 F038C56461; Mon, 8 Apr 2024 10:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712572419; cv=none; b=sFYNWcsrzqu5DnmA/luurmvN5VEzcSdckJV+B5AH+ZpOJBP8hnEMGRPEjWJP1A858h7jt8wYipejF+hDu2xnat/lfbzbKuk5XsiKOp1ezdJez7+X8iFFkTCzlyYkCPEQZ3eho7eZvYEbnsF9wEa59/aZkyQL6dYPSmLKIyul+cM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712572419; c=relaxed/simple; bh=ClOpZ0AHH9yZZkGvJ+uxL1FXrhBie5+wy8x5tlWlRsc=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=R17yFJXsVZjjssFUzIPZoQQlSKpBUveaIn40srMn9/H/y0eGAN0oycoWRCRqgDEw7e+MNlj1pFvZbO1iQKLkka4tDIV2XguOD1i/MlA+Oa7QeHnyB7mAtaMaGuzyeJrCy1WKs5O/6Teerqpv95xxDrrMQj+Ng7fqEl0hoF/elEw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZZ/brF4y; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712572418; x=1744108418; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ClOpZ0AHH9yZZkGvJ+uxL1FXrhBie5+wy8x5tlWlRsc=; b=ZZ/brF4yf1EaHXq0cvyumsOHxd5xJ9rAAWoavKai/qe9LTbel3Qs6GVp IfBwkp1fflM7usGAIsptrCgr2qLYmA85U8LOwsYWr+C0z1ShXNpnydVgu W4YMv/dWPbQYLCbQr/P01/isEypqA+c90yfAoj8N+1Mkw4t1/4TfWLGUn pg9wkpItkdPTeJYfTywuDLZYzKogVlScSTNUK3c2SW8ngTs+hjRXibYAx gGCz1LCwbXgRqJF7QIPDU4eElKLJXlyqlutlvRoBx4WWCWFxBsuxFNuOC EHiEeWlbgtJdYEeEWp+omFQQennzf7xEXV8zgdBQ7mLK1He9j2F5DucMp A==; X-CSE-ConnectionGUID: rbWS5ig5TXK3Pb6GG89llA== X-CSE-MsgGUID: qjBqXD34QUaPMklqCImTKw== X-IronPort-AV: E=McAfee;i="6600,9927,11037"; a="19212441" X-IronPort-AV: E=Sophos;i="6.07,186,1708416000"; d="scan'208";a="19212441" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 03:33:37 -0700 X-CSE-ConnectionGUID: 40eWzVcvT8+d8Jcpadl6ew== X-CSE-MsgGUID: /KCd51CkSYuRPI3FXVJx9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,186,1708416000"; d="scan'208";a="24586450" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 03:33:35 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Mon, 8 Apr 2024 13:33:29 +0300 (EEST) To: Hans de Goede cc: Armin Wolf , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, LKML Subject: Re: [PATCH] platform/x86: quickstart: Fix race condition when reporting input event In-Reply-To: Message-ID: <6d89b1f3-f37d-918d-b497-fc9b877ac297@linux.intel.com> References: <20240327214524.123935-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 Content-Type: text/plain; charset=US-ASCII On Sun, 7 Apr 2024, Hans de Goede wrote: > On 4/6/24 8:57 PM, Armin Wolf wrote: > > Am 27.03.24 um 22:45 schrieb Armin Wolf: > > > >> Since commit e2ffcda16290 ("ACPI: OSL: Allow Notify () handlers to run > >> on all CPUs"), the ACPI core allows multiple notify calls to be active > >> at the same time. This means that two instances of quickstart_notify() > >> running at the same time can mess which each others input sequences. > >> > >> Fix this by protecting the input sequence with a mutex. > >> > >> Compile-tested only. > > > > Any thoughts on this? > > I wonder if we need this at all ? > > The input_event() / input_report_key() / input_sync() functions > which underpin sparse_keymap_report_event() all are safe to be called > from multiple threads at the same time AFAIK. > > The only thing which can then still go "wrong" if we have > 2 sparse_keymap_report_event() functions racing for the same > quickstart button and thus for the same keycode is that we may > end up with: > > input_report_key(dev, keycode, 1); > input_report_key(dev, keycode, 1); /* This is a no-op */ > input_sync(); /* + another input_sync() somewhere which is a no-op */ > input_report_key(dev, keycode, 0); > input_report_key(dev, keycode, 0); /* This is a no-op */ > input_sync(); /* + another input_sync() somewhere which is a no-op */ > > IOW if 2 racing notifiers hit the perfect race conditions then > only 1 key press is reported, instead of 2 which seems like > it is not a problem since arguably if the same event gets > reported twice at the exact same time it probably really > is only a single button press. > > Also I think it is highly unlikely we will actually see > 2 notifiers for this racing in practice. > > So I don't think we need this at all. But if others feel strongly > about adding this I can still merge it... ? Hi, I know you already merged this and I agree it's not very likely race but still it can turn two presses into one which seems unwanted side-effect, even if it's unlikely to occur in practice. -- i.