Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1573736lqp; Mon, 15 Apr 2024 10:09:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQT3FStdZNMpcyS4zZWTSyaYd8VUzVsc3B/yen4s9hcy++ca/TQcFXHLaPP8v1oKGsuQoQV8bQGecjMO/veKzKHqEZkxK0cgAJ7C6gMQ== X-Google-Smtp-Source: AGHT+IGe8uQcoyG4Iyk+rSjkSxyaUXPSCpsTuSuc4aYE6UyrbrPgTCKkFlpMBZ22buPwObCO2Uyp X-Received: by 2002:a05:6122:17a4:b0:4c0:1bb6:322 with SMTP id o36-20020a05612217a400b004c01bb60322mr7558706vkf.15.1713200974450; Mon, 15 Apr 2024 10:09:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713200974; cv=pass; d=google.com; s=arc-20160816; b=LNzwcSxnaIjUe6lkvbODj2O06tN18NhSW/AtEZ2CAIZ9PWG5GqkdeixDgsdaWJVXBY 3BYWlfYkjLQSa/dsdhYIjOtDEccV9jKZfKsqmhfp89Vv/crnMt50UpWiYR8s24Fo5v/y uar+0NMUVcxRX62+cOIvDKoLBQTpUrwaAFZcdB0bmOlG+drBYHq7Mb4aqLQWyJxYVQqH SeEamGJe8CsRspXIZDZzZLP5QLMVC3H8aRPXLRDomG7BnqPEqkgRPST5pX4G9fEjwRUf itRx7TRgQDHSP0cPpXQnMLRHMI049/0kks4UDNT9Aw9+LxmZyK0Z/j/sKRj6/QSZZxzc PhNw== 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:dkim-signature; bh=1WfmmS5PxSX5CFZyjQLLWweyw/cLTYP+dIZNO+as+8A=; fh=Mm8hlFdBHUY0fyqKU/MWlqkizWEw7qYBWD0xRewgNf0=; b=JSz615Uk89t6vWT5GeWt3PI1ri49ESrxGUzcgc/LTeoAp1n8Uqq7WqypwZzcQ7FpLR idMICE+DWdM+A4D2T+gQqMo3CqI6nJ5iZLq0w2a6HeV7Od6eRZwjY8o4GVRJizDdLHnx 04Qdvjv9cNGfK+sP22pxeoVRGWvJbsscL594q52kjxgM2aUXUQ9pj72tu4gZp1xyFDVp n8MzWTstKCfyv9qSImCX1V+y7hHBO/0Ag1S/M/iPmWXUizM5bIq2qTy2qKF5MG4QdjOa Turx8FRM9NvLEeHDm7xiCdBJtbSGZJCgK41Kz6I/QosdAL4VH+DP1Eg/rQ4UnGqwfcs7 iTcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=qtN+DFJ9; arc=pass (i=1 spf=pass spfdomain=kl.wtf dkim=pass dkdomain=kl.wtf dmarc=pass fromdomain=kl.wtf); spf=pass (google.com: domain of linux-kernel+bounces-145628-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145628-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kl.wtf Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fu4-20020a0561223c0400b004daa9650746si1343281vkb.87.2024.04.15.10.09.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:09:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145628-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=qtN+DFJ9; arc=pass (i=1 spf=pass spfdomain=kl.wtf dkim=pass dkdomain=kl.wtf dmarc=pass fromdomain=kl.wtf); spf=pass (google.com: domain of linux-kernel+bounces-145628-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145628-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kl.wtf 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 3330C1C2209A for ; Mon, 15 Apr 2024 17:09:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 581FA126F37; Mon, 15 Apr 2024 17:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kl.wtf header.i=@kl.wtf header.b="qtN+DFJ9" Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (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 D103C84FDD for ; Mon, 15 Apr 2024 17:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713200753; cv=none; b=LY6aVO876/oqJ/QXQNxn/uJuhZV2HGsOpthLcpmjsgSmbW7L6hBaHKrNn6ZftZjCDkSEJSE96PdUzjFSooBdBUFDZqei/5xF4h0cd8slwTgzqcRAbb2g4LFFIhSNY5E+XKMA/aakn3v4qZzJRZZjt9p9XB7QzHMssKeVD9J8i64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713200753; c=relaxed/simple; bh=/owCXnojrcK1rPeZ+23v2V4Et11EpdLYIdz8dAbiBSs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fvv5LWUHjPi8sakILdszrnLkQmXHMGzPNffdE+sH0gISpGCSi8JB/63HEyvx3ji1VyLPgu3v8FTFrLDOk2xsTplwgJqqtUkvBCCElQXK5xXF7MCKvjv/THbxBZFJaPnRvp/1datVCDysk2fLKxQUMR7BSuRfvaqkzhYrygLJHRs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kl.wtf; spf=pass smtp.mailfrom=kl.wtf; dkim=pass (2048-bit key) header.d=kl.wtf header.i=@kl.wtf header.b=qtN+DFJ9; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kl.wtf Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kl.wtf X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kl.wtf; s=key1; t=1713200750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1WfmmS5PxSX5CFZyjQLLWweyw/cLTYP+dIZNO+as+8A=; b=qtN+DFJ9nSgl1ggQcGdR5Rvb8WamgFzvKuWuS14fqyLJx4Sq4xAGotXjRchgmVA2iOOwAe pU67DlEslVx3lk1UmdX+onUyiHOCKCmFxUKFpqBny+/Cvx90rR25p19EVVYfkv0TNMVt7D wb/+G9V2cTCDV0X7Bpt16GNF5yP45f/aYdeZbiIxMkzOIx+vQ7yTnN0ZNG0dnVI/R9l9Xw Icu/zw4MG/q8dZXQOlppS/M4WrTWkeQ6cIeHZ8la/tYdWPNo6X0oTpKWaztw5/ljy8+fD+ s3rAc8TIARFNs6EH7DxZI/sUxnihXnzTXPa60ciQpLJB64+fhKNuVAZf02M32A== From: Kenny Levinsen To: Jiri Kosina , Dmitry Torokhov , Benjamin Tissoires , Douglas Anderson , Hans de Goede , Maxime Ripard , Kai-Heng Feng , Johan Hovold , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Radoslaw Biernacki , Lukasz Majczak Cc: Kenny Levinsen Subject: [PATCH 2/3] HID: i2c-hid: Retry HID descriptor read to wake up STM devices Date: Mon, 15 Apr 2024 19:04:12 +0200 Message-ID: <20240415170517.18780-3-kl@kl.wtf> In-Reply-To: <20240415170517.18780-1-kl@kl.wtf> References: <20240415170517.18780-1-kl@kl.wtf> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Some STM microcontrollers need some time after rising clock edge in order to come out of their deep sleep state. This in turn means that the first command send to them timeout and fail with EREMOTEIO. Retry once on EREMOTEIO to see if the device came alive, otherwise treat the error as if no device was present like before. Link: https://lore.kernel.org/all/20240405102436.3479210-1-lma@chromium.org/#t Signed-off-by: Kenny Levinsen --- drivers/hid/i2c-hid/i2c-hid-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index 515a80dbf6c7..ac661199d2c8 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -1010,7 +1010,15 @@ static int __i2c_hid_core_probe(struct i2c_hid *ihid) struct hid_device *hid = ihid->hid; int ret; + /* + * Some STM-based devices need some time after a rising clock edge to + * wake from deep sleep, which in turn means that our first command + * will fail EREMOTEIO. Retry the command in this case. + */ ret = i2c_hid_fetch_hid_descriptor(ihid); + if (ret == -EREMOTEIO) + ret = i2c_hid_fetch_hid_descriptor(ihid); + if (ret == -EREMOTEIO) { i2c_hid_dbg(ihid, "nothing at this address: %d\n", ret); return -ENXIO; -- 2.44.0