From nobody Thu Nov 28 03:31:11 2024 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D80713EFF3 for ; Sat, 5 Oct 2024 10:31:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124273; cv=none; b=rdS3ayH4MYr8llJm/IiFEE6ZkxF2AxXaaLSWNs/2zHDFHuU1q8p67/lVMyG6qlyaoqCrebRiR5AsS9gk/+rgUE5W9mcC04c1T6zs4aC3wDrxhkdHPEwCFBQK3J+u5GD6J1+IMjcmwf+ZnvvhAioRAVayySXnSbZJhsvsVDvWxlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124273; c=relaxed/simple; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QSXt8kSI4MMwDL4MwiwxQdYzehTsz/5ZzKQeW2P2qHjkO4eDzrjQQwpJBrvTr1fsR4qD0NK9MgHNeO4tpQ4VDHmpIcIAjcAEGwcSOGcWBYV8S+FquYl59/ChDx9qyAwBBdO+I8qaZHGVQrw1dPaJqCqfe9MXHzaXE4TiQ1IIM+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mnpatQ9G; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mnpatQ9G" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5c42f406e29so3656284a12.2 for ; Sat, 05 Oct 2024 03:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728124269; x=1728729069; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=E7nKjwcfTxwC0PwN6GrPgJAgBaaTNk6QSx4URpDS/gc=; b=mnpatQ9GEEEMayWewFkEs5Jrn6hI6nlA/jNRwo4KPX1V6Zi1cchTK2DhbBeYgwV6Jc tnKgq3V2QTK0j1jljiXdcsJNFPSR3JwppcwgVT4s42dk/IMLtn/wfsGYj3u6ndPBhzId Kkg6fPnfpqQ8hBPzJTX3plE5wXfj/sbcvKREM4AxxejfRh7+X3kVpJyx+9jhUxjmQv+N 3Rxl5rvN6XWiy2Q85Ld0zUbLeXXa+3cb9AR/iNJPoTebVL4qiLdqwug6eImtLxFoHxHC 0y1rh2yt7bmQ2FGWxUMt5wtPjTGWnLkEY7G3OVHWmDC//cpKcJ5ZBVlo+oH7OvQosOjU xMgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728124269; x=1728729069; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E7nKjwcfTxwC0PwN6GrPgJAgBaaTNk6QSx4URpDS/gc=; b=gyikl9XvbstheaqPLL20lfaPYbzojot3d0Hrx54/4UfU2hwZ3Fw1cTjwLrQDVm76fj W/dbJAxOHCsNRpQF9WoUSUFomkwDXoVvjUU42TZqFuKIbRfINbkntydPfNKtR5zm4pCu TOtInXhjIPPnlsfB+c4Lu4qEA4D2gwGIvXlkZiaqzYK9pykiR6eu/fhtp2RqkRZwgz2a R9b+cPejdJdRyDdRhGz4S3fKpX97RxQRPvtVUmLPXa32SGtVMPgohOH8fNqkS2PywDLX Lywwa6EPrGYo54Y8Uy3UE7d7P0NRqZuRfBIVwODuZQO6i54J10K+5Qj3CHUy61SiqwaQ NgsA== X-Forwarded-Encrypted: i=1; AJvYcCXjICSBB8KaK17Ut0eUyBSITgwop9/igSKostpMAdNxEtzATk9lRIt0oOu7PWC5jNq/731Q/9KJYb9wFGQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxVUPELBs8TCYD8TQiPNRc7nrAhf/6S4ig4RDJgXItj65hLSJZi WeHHRdaI0RnAP7j6eS4NmWMdTx6W5ox5aQs+GjE/ki6AR0WBt7pe2n7m7aVg7v8= X-Google-Smtp-Source: AGHT+IGMw6qNSWut4ShGQ2E89T3alI/rY9/tMRu5/jv2l5XfRLkJFb4c9fLiEXAjApPQ+ggWZtlBlA== X-Received: by 2002:a17:907:25c3:b0:a80:f6a0:9c3c with SMTP id a640c23a62f3a-a991ba979famr577085366b.0.1728124269473; Sat, 05 Oct 2024 03:31:09 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e7856bfsm116315566b.138.2024.10.05.03.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 03:31:09 -0700 (PDT) From: Bryan O'Donoghue Date: Sat, 05 Oct 2024 11:31:03 +0100 Subject: [PATCH v5 1/4] media: ov08x40: Fix burst write sequence 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241005-b4-master-24-11-25-ov08x40-v5-1-5f1eb2e11036@linaro.org> References: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@linaro.org> In-Reply-To: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@linaro.org> To: Sakari Ailus , Jason Chen , Mauro Carvalho Chehab , Sergey Senozhatsky , Hans Verkuil , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bryan O'Donoghue , stable@vger.kernel.org X-Mailer: b4 0.15-dev-dedf8 X-Developer-Signature: v=1; a=openpgp-sha256; l=2802; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBnARVpPvMthR5vaCpvzYZx2Ib+Iducs9nYCFnN1 kMDZUqdG+KJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZwEVaQAKCRAicTuzoY3I Ohj/D/49VOqkWw6B83cchu7024YSwZ9ifrGHWKGj5dPQ/pm5R19PW26WsWa9rD4GKbaz8Yc+ZZw qoIiRg+ezt6zLVHtRjS6xIM9k8tlZYGEyNoKtyqJGO54XJdkNiJc6P8cEcStc7YGOne9VV0/bFL FSx2wzfl1K4qmeiSn+sS2jV46Kbv/tjCXPQwgeEpv70mnkeQ0EA4AYOTrlVBmmNaSHMPrPW4DVE xIhnrV3xpK/kqwuAXSKdQGG0nFL+iAGMp3B0205d/l/PHqhuTFBGn14Zzm/pTmqfxOdCw763PWY o1YLwipqSyEcV/wtg7Abr6cIUeAu+2q09nasK2hla/bUdgNWoEnyXx/Vc+/7TwTZvd3e2K5ACys sJZlgUdlXQLDpZO5VeZC8xUEIew9i6d7nEm0SkwEMgsGKwS0VgyVHgOgDTo4PcGyyggx6ESl5ni IusIKJlYVKqpR3JYlRvmrDaLMSNUKQRGJhx0Jg5Jycrg3ZZSxe3YB+eor5oh3r9Ekf6xWoY5IcO xvA/5zvwRKDbWYUORrqVy2idpiPdK6T3huVpvn2lJshU+3qybWkyTg/vIFclJb673AL+AcD54+8 Dovy2QRQMtreUzbPnbf8ehZ7B7crZjvGFlHONpM8G/Xzb/876xaePKi+dhDpflmHfkKrFoLpUSn TN06H04H50FCceA== X-Developer-Key: i=bryan.odonoghue@linaro.org; a=openpgp; fpr=E693FB2AABA36DE117AB6FB422713BB3A18DC83A 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 29= 0, 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 --- drivers/media/i2c/ov08x40.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 48df077522ad0bb2b5f64a6def8844c02af6a193..be25e45175b1322145dca428e84= 5242d8fea2698 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1339,15 +1339,13 @@ static int ov08x40_read_reg(struct ov08x40 *ov08x, return 0; } =20 -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 =3D v4l2_get_subdevdata(&ov08x->sd); struct i2c_msg msgs; - size_t i, num_regs; + size_t i; int ret; =20 - num_regs =3D last_reg - first_reg + 1; msgs.addr =3D client->addr; msgs.flags =3D 0; msgs.len =3D 2 + num_regs; @@ -1373,6 +1371,31 @@ static int ov08x40_burst_fill_regs(struct ov08x40 *o= v08x, u16 first_reg, return 0; } =20 +static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, + u16 last_reg, u8 val) +{ + struct i2c_client *client =3D v4l2_get_subdevdata(&ov08x->sd); + size_t num_regs, num_write_regs; + int ret; + + num_regs =3D last_reg - first_reg + 1; + num_write_regs =3D num_regs; + + if (client->adapter->quirks && client->adapter->quirks->max_write_len) + num_write_regs =3D client->adapter->quirks->max_write_len - 2; + + while (first_reg < last_reg) { + ret =3D __ov08x40_burst_fill_regs(client, first_reg, last_reg, + num_write_regs, val); + if (ret) + return ret; + + first_reg +=3D num_write_regs; + } + + return 0; +} + /* Write registers up to 4 at a time */ static int ov08x40_write_reg(struct ov08x40 *ov08x, u16 reg, u32 len, u32 __val) --=20 2.46.2