From patchwork Mon Nov 4 08:50:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 13861043 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 C9B1D1494B1 for ; Mon, 4 Nov 2024 08:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730710262; cv=none; b=WNs9A2Kb8Zs5ubEQqi7zPnkIdZRH7Tya6tNZ/eFC9s/jFdcn26pikGN9dal6AkwpY7bcjLZHqzq/1HaY0VgdzHOz6xVT/gdCFUP1SXLOOMNJAXGXTtUUmqft+DC3CfQxGZzz2D01vE0BVO+x5JToHDG2OPz9OCGWtkitkrv1ZDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730710262; c=relaxed/simple; bh=lwezjRJ5YhfZ0Utbiz8Yah0w9pO3zj389ko+3Egtvo0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=B6suN9gvBF8iOqgUF0m5VFR46AOdai4EStuDpgcoIwsE0gmFspRxoZIWSD2borOAwtjhwMm1zVX7znSbTDk3EZsYseyvQMDomtHknQH++rmAk/ZUhlGklkI5BH0DCefv9l8mz1sMySD9k7UMRu2/8pEYS9PzT46PbDVbN4Yy9CA= 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=JBUjx4h+; arc=none smtp.client-ip=198.175.65.21 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JBUjx4h+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730710261; x=1762246261; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lwezjRJ5YhfZ0Utbiz8Yah0w9pO3zj389ko+3Egtvo0=; b=JBUjx4h+O1W6up3SfPHiWdilNktT1AnH0rvF2nxbzwNhjSfDrSMgDgy0 ib6Efov6hgjIiU4cTZY8kvMMA6LLL8VeC5f9/4bAMLbTkI0/FCXLd9DFb g9/T4fEk3LHjIsR871Ow4s5W2luBjHj3z635SgLxNwhhskLGD2AvVDKdO 0OBmET3oLktxqYpakZDJ91xWgdPvpexOAV80dFuCZXmjYrMsWqwZxMDWM wh7HNA1KXIXHY/V/pYDbV5yMpR32PqBcEePyNY0AKjoL5N0F6M8mlBxuU BDX4MVhDaHQcMMIaJFlssBirOXPv2B8jZQ1ESP8s65ALFI6oWFH/em74s Q==; X-CSE-ConnectionGUID: JT72vB3LS8OcgSCW09OKAA== X-CSE-MsgGUID: ezd4XC9kTsOL272eib/GNA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30343056" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30343056" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 00:51:00 -0800 X-CSE-ConnectionGUID: AVPHH+ZNS2qiOgDtdqPYKA== X-CSE-MsgGUID: vBatJu8cQaOiSMags04dHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="88097792" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.97.183]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 00:50:59 -0800 From: Stanislaw Gruszka To: linux-usb@vger.kernel.org Cc: Wentong Wu , Sakari Ailus Subject: [PATCH 1/3] usb: misc: ljca: move usb_autopm_put_interface() after wait for response Date: Mon, 4 Nov 2024 09:50:54 +0100 Message-Id: <20241104085056.652294-1-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Do not mark interface as ready to suspend when we are still waiting for response messages from the device. Fixes: acd6199f195d ("usb: Add support for Intel LJCA device") Cc: stable@vger.kernel.org Signed-off-by: Stanislaw Gruszka Reviewed-by: Hans de Goede Tested-by: Hans de Goede # ThinkPad X1 Yoga Gen 8, ov2740 --- drivers/usb/misc/usb-ljca.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/misc/usb-ljca.c b/drivers/usb/misc/usb-ljca.c index 01ceafc4ab78..dcb3c5d248ac 100644 --- a/drivers/usb/misc/usb-ljca.c +++ b/drivers/usb/misc/usb-ljca.c @@ -332,9 +332,6 @@ static int ljca_send(struct ljca_adapter *adap, u8 type, u8 cmd, ret = usb_bulk_msg(adap->usb_dev, adap->tx_pipe, header, msg_len, &transferred, LJCA_WRITE_TIMEOUT_MS); - - usb_autopm_put_interface(adap->intf); - if (ret < 0) goto out; if (transferred != msg_len) { @@ -353,6 +350,8 @@ static int ljca_send(struct ljca_adapter *adap, u8 type, u8 cmd, ret = adap->actual_length; out: + usb_autopm_put_interface(adap->intf); + spin_lock_irqsave(&adap->lock, flags); adap->ex_buf = NULL; adap->ex_buf_len = 0; From patchwork Mon Nov 4 08:50:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 13861044 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 C7C521494B1 for ; Mon, 4 Nov 2024 08:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730710265; cv=none; b=DkPEOhvQkvE/SmIYK+3pazJlIwgKXjUN2aZj6LT9jupnxlMKqpcYxLjunJGinguzyApnwCIRzhjv1nC3xgaxyIJP+MRfc1jGWzl3/gjx/OM6H+riQnZrzBB9y6eP0cYQZiKkngJTyLQ/PJFiwzk1xJ7jPf3o59YLVpN8DUpm0uA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730710265; c=relaxed/simple; bh=TsEJ6ynWkB0jYGdFN81jcDNxz7kmtcx2sp769SOXTOY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=trK/gnkUTkNmyG4tNf2UIIPG1x6w14SmWaKTstRJN1cXqFufH9glh0BK4WbTI0BdHn/DCeK/5VIvyQH/PuBkXpZLTfNiDLBlkuX0f6IvQBfkwAvHRv9x60xYpPJrE4W/lK7H3RTioCQjd9gDiQazIoiDtWC7ciw4znyiRwf/rUY= 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=V3IStAwd; arc=none smtp.client-ip=198.175.65.21 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="V3IStAwd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730710264; x=1762246264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TsEJ6ynWkB0jYGdFN81jcDNxz7kmtcx2sp769SOXTOY=; b=V3IStAwdw51xPtbiDsNT6oWrY7snkwvp7H8LjYghAgQQvLNFMf4acoiv CxpIvE6q92MuqOgQ2JtGaj2V/Sim0LxE7RsU0dBHaKTGqQnGD/A0AsBKZ SsmB9MMzXTiraUYSSosKa8embaYHfZTeFiywbmso6sh87ddX+2sAno3Uk ynq3hoDEcD00qmdSkNrEPARSB+Yvx0d8U06yR94W6two54917Tv1pw7m1 +sgRNHMMUBfRm22F5pzZFhWzS/sCSmd1lnE4+ApJZJmUGZpJWLCDq/ytj DQx3Yy8xuAlTJa2Gp6Lhnh0CmCcd3lCgKpPe2nVvkzvAlQ2wiBjYSZT42 Q==; X-CSE-ConnectionGUID: EAbnAULvTDGDkAH0Cfp61A== X-CSE-MsgGUID: DSvdAW5MQhiOke3I/Dg1GA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30343060" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30343060" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 00:51:04 -0800 X-CSE-ConnectionGUID: nkO9cwpzS46ODIZpoLglQg== X-CSE-MsgGUID: /3cEE4LFSKCWEVkZpFwjFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="88097814" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.97.183]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 00:51:02 -0800 From: Stanislaw Gruszka To: linux-usb@vger.kernel.org Cc: Wentong Wu , Sakari Ailus Subject: [PATCH 2/3] usb: misc: ljca: set small runtime autosuspend delay Date: Mon, 4 Nov 2024 09:50:55 +0100 Message-Id: <20241104085056.652294-2-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104085056.652294-1-stanislaw.gruszka@linux.intel.com> References: <20241104085056.652294-1-stanislaw.gruszka@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On some Lenovo platforms, the patch workarounds problems with ov2740 sensor initialization, which manifest themself like below: [ 4.540476] ov2740 i2c-INT3474:01: error -EIO: failed to find sensor [ 4.542066] ov2740 i2c-INT3474:01: probe with driver ov2740 failed with error -5 or [ 7.742633] ov2740 i2c-INT3474:01: chip id mismatch: 2740 != 0 [ 7.742638] ov2740 i2c-INT3474:01: error -ENXIO: failed to find sensor and also by random failures of video stream start. Issue can be reproduced by this script: n=0 k=0 while [ $n -lt 50 ] ; do sudo modprobe -r ov2740 sleep `expr $RANDOM % 5` sudo modprobe ov2740 if media-ctl -p | grep -q ov2740 ; then let k++ fi let n++ done echo Success rate $k/$n Without the patch, success rate is approximately 15 or 50 tries. With the patch it does not fail. This problem is some hardware or firmware malfunction, that can not be easy debug and fix. While setting small autosuspend delay is not perfect workaround as user can configure it to any value, it will prevent the failures by default. Additionally setting small autosuspend delay should have positive effect on power consumption as for most ljca workloads device is used for just a few milliseconds flowed by long periods of at least 100ms of inactivity (usually more). Fixes: acd6199f195d ("usb: Add support for Intel LJCA device") Cc: stable@vger.kernel.org Signed-off-by: Stanislaw Gruszka Reviewed-by: Hans de Goede Tested-by: Hans de Goede # ThinkPad X1 Yoga Gen 8, ov2740 --- drivers/usb/misc/usb-ljca.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/misc/usb-ljca.c b/drivers/usb/misc/usb-ljca.c index dcb3c5d248ac..062b7fb47114 100644 --- a/drivers/usb/misc/usb-ljca.c +++ b/drivers/usb/misc/usb-ljca.c @@ -810,6 +810,7 @@ static int ljca_probe(struct usb_interface *interface, if (ret) goto err_free; + pm_runtime_set_autosuspend_delay(&usb_dev->dev, 10); usb_enable_autosuspend(usb_dev); return 0; From patchwork Mon Nov 4 08:50:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 13861045 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 4932D1AB6FA for ; Mon, 4 Nov 2024 08:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730710268; cv=none; b=SqE23fO6ujd/o0/nypYapMQIeXkZlD9FiVhCP9od6ZxI8FBvYS7n0YffCKhQSoJ0z+WBB4M1n+EPAEIpwl5C42NJ7wJlD3PIUn33/g/M1AAbrIryEdl3pnMjJAKgpv1WFiCgF/ghTgvsXB3Wkr5+LeZyIGv8NXzFd1aBApTp2yY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730710268; c=relaxed/simple; bh=A91MbdDS+1kabBRq7Ccz+n2IfT7FWdueW/mL96uoEAs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GLfsOpajR5fS+zAqvxradgxF8VWmTmqt+CKUMSVEb2vo2YvCQkM6/SCaeGbKMCcz8qRJyegREl0p+hV08OA7cUTAcViS24xqBynhARR+STwMocSbN6ulYjuEsw7Uy0WfeKamfS/5Crg97hHMhchmELewsvcOhDW6/gQAHS6MsNo= 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=eetZvepl; arc=none smtp.client-ip=198.175.65.21 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eetZvepl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730710267; x=1762246267; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A91MbdDS+1kabBRq7Ccz+n2IfT7FWdueW/mL96uoEAs=; b=eetZveplIhWF2WQYLTBFM2AH4KmTQtsPxIAmUO93RZSwCtbyfyt4nvLd sr1Nf1lRVBn0UK0U1+U1hYDzhQ1B6GMCHCjPeqq++1HfdJhDFsu/btpjK 2p4nLX/Fx9UHnRi2IE1kV3EXwPoJUCjFn3mHqKIG5yLwjcd0gHdDIdvIg H0BF6Yin8R8HiNNL2KuSE0Bz2dX8g+6X9xIt157JaaiWq/y6diI4U9v0z szBm1IJkD+CQTTqGGtB9oWyhfMpK8HcLZlZ5rn4HOcZ1XlgWDmEJ34Glg EKlzzaJ1yNsmXGvWtI1hpg6pJthnOleeKQQkYnX0zxoXU6mpE4zwiHOP0 Q==; X-CSE-ConnectionGUID: cfA9gpw5Qz6fekAIBLU5+g== X-CSE-MsgGUID: UTAK2WnwRmaBPZGtYQOnrA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30343064" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30343064" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 00:51:07 -0800 X-CSE-ConnectionGUID: lXiLAGw1R1aqbWXHZbJYRQ== X-CSE-MsgGUID: Vb+JW7P3QSSoBFCN6pPx9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="88097832" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.97.183]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 00:51:06 -0800 From: Stanislaw Gruszka To: linux-usb@vger.kernel.org Cc: Wentong Wu , Sakari Ailus Subject: [PATCH 3/3] usb: misc: ljca: print firmware version Date: Mon, 4 Nov 2024 09:50:56 +0100 Message-Id: <20241104085056.652294-3-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104085056.652294-1-stanislaw.gruszka@linux.intel.com> References: <20241104085056.652294-1-stanislaw.gruszka@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For diagnostics purposes read firmware version from device and print it to dmesg during initialization. Signed-off-by: Stanislaw Gruszka Reviewed-by: Hans de Goede Tested-by: Hans de Goede # ThinkPad X1 Yoga Gen 8, ov2740 --- drivers/usb/misc/usb-ljca.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/usb/misc/usb-ljca.c b/drivers/usb/misc/usb-ljca.c index 062b7fb47114..0f8751c51bf6 100644 --- a/drivers/usb/misc/usb-ljca.c +++ b/drivers/usb/misc/usb-ljca.c @@ -43,6 +43,7 @@ enum ljca_client_type { /* MNG client commands */ enum ljca_mng_cmd { + LJCA_MNG_GET_VERSION = 1, LJCA_MNG_RESET = 2, LJCA_MNG_ENUM_GPIO = 4, LJCA_MNG_ENUM_I2C = 5, @@ -68,6 +69,13 @@ struct ljca_msg { u8 data[] __counted_by(len); } __packed; +struct ljca_fw_version { + u8 major; + u8 minor; + __le16 patch; + __le16 build; +} __packed; + struct ljca_i2c_ctr_info { u8 id; u8 capacity; @@ -694,6 +702,24 @@ static int ljca_reset_handshake(struct ljca_adapter *adap) return 0; } +static void ljca_print_fw_version(struct ljca_adapter *adap) +{ + struct ljca_fw_version version = {}; + int ret; + + ret = ljca_send(adap, LJCA_CLIENT_MNG, LJCA_MNG_GET_VERSION, NULL, 0, + (u8 *)&version, sizeof(version), true, LJCA_WRITE_ACK_TIMEOUT_MS); + + if (ret != sizeof(version)) { + dev_err(adap->dev, "Get version failed, ret: %d\n", ret); + return; + } + + dev_info(adap->dev, "Firmware version: %d.%d.%d.%d\n", + version.major, version.minor, + le16_to_cpu(version.patch), le16_to_cpu(version.build)); +} + static int ljca_enumerate_clients(struct ljca_adapter *adap) { struct ljca_client *client, *next; @@ -810,6 +836,8 @@ static int ljca_probe(struct usb_interface *interface, if (ret) goto err_free; + ljca_print_fw_version(adap); + pm_runtime_set_autosuspend_delay(&usb_dev->dev, 10); usb_enable_autosuspend(usb_dev);