From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 32B2214D717; Fri, 6 Dec 2024 14:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733496050; cv=none; b=Td1mqM2y5JNEzuuO6TWjG/wnq20113JbCGhg2IGo8x88M+ZVhTZVnfEctjG4n60DRWrVMG5YlROLJWndWst0jbTgd+BPLpFXyXNnDbZUctsZ+b/hEYwTpbY54IqsZrJzqehaDsW5Ve1gkJb1SQ3yOsQ7aREqI9/N8NOdUrKvFvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733496050; c=relaxed/simple; bh=cm+sUET2mq4cXsYFBcgpebqqNaqUjWfXlOmX80vg8Og=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QJ/6r6Fbf18mTBVBFNbpVZ2qr0nkv4DJAFQRwz5fCjmQgXP/qJSZpZB9sAO1yVaNTiCWUqccEFMW/wegpPEWPTXGjJGbX0h7DhT3B+z8K9sxwSupi5Qe1DqTV44ipZS/2r7S4RcTHKkpFe9H6heY1u9oOWp1MKhO7Td/7aCf1yE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rYI3F+rv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rYI3F+rv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 968C4C4CEDC; Fri, 6 Dec 2024 14:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733496050; bh=cm+sUET2mq4cXsYFBcgpebqqNaqUjWfXlOmX80vg8Og=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rYI3F+rv2zVPkb1rvlc684Swfei4tZYdBWsEDesqmK2+BKvtqsWoPH3I/kBQFlmRx 8MY6tpep4rQy3Lkf+oFiSYSlq/3SLMtBywsOF5G3bPedkfUDfUt2Tw4rAcllN4KK2F g3zYIq5sMAMbl5t3jRgYjDhwOuB+7Lb9/CYA1JLM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryan ODonoghue , Sakari Ailus , Hans Verkuil Subject: [PATCH 6.12 036/146] media: ov08x40: Fix burst write sequence Date: Fri, 6 Dec 2024 15:36:07 +0100 Message-ID: <20241206143529.053426675@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143527.654980698@linuxfoundation.org> References: <20241206143527.654980698@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryan O'Donoghue commit d0fef6de4f1b957e35a05a5ba4aab2a2576d6686 upstream. It is necessary to account for I2C quirks in the burst mode path of this driver. Not all I2C controllers can accept arbitrarily long writes and this is represented in the quirks field of the adapter structure. Prior to this patch the following error message is seen on a Qualcomm X1E80100 CRD. [ 38.773524] i2c i2c-2: adapter quirk: msg too long (addr 0x0036, size 290, write) [ 38.781454] ov08x40 2-0036: Failed regs transferred: -95 [ 38.787076] ov08x40 2-0036: ov08x40_start_streaming failed to set regs Fix the error by breaking up the write sequence into the advertised maximum write size of the quirks field if the quirks field is populated. Fixes: 8f667d202384 ("media: ov08x40: Reduce start streaming time") Cc: stable@vger.kernel.org # v6.9+ Tested-by: Bryan O'Donoghue # x1e80100-crd Signed-off-by: Bryan O'Donoghue Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/i2c/ov08x40.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1339,15 +1339,13 @@ static int ov08x40_read_reg(struct ov08x return 0; } -static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, - u16 last_reg, u8 val) +static int __ov08x40_burst_fill_regs(struct i2c_client *client, u16 first_reg, + u16 last_reg, size_t num_regs, u8 val) { - struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); struct i2c_msg msgs; - size_t i, num_regs; + size_t i; int ret; - num_regs = last_reg - first_reg + 1; msgs.addr = client->addr; msgs.flags = 0; msgs.len = 2 + num_regs; @@ -1371,6 +1369,31 @@ static int ov08x40_burst_fill_regs(struc } return 0; +} + +static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, + u16 last_reg, u8 val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); + size_t num_regs, num_write_regs; + int ret; + + num_regs = last_reg - first_reg + 1; + num_write_regs = num_regs; + + if (client->adapter->quirks && client->adapter->quirks->max_write_len) + num_write_regs = client->adapter->quirks->max_write_len - 2; + + while (first_reg < last_reg) { + ret = __ov08x40_burst_fill_regs(client, first_reg, last_reg, + num_write_regs, val); + if (ret) + return ret; + + first_reg += num_write_regs; + } + + return 0; } /* Write registers up to 4 at a time */