From patchwork Tue Jan 7 10:54:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13928685 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 7AEF71DFE15 for ; Tue, 7 Jan 2025 10:54:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247274; cv=none; b=PkR3n/p1UuPgwTCjG3CA9UYMrDq781zgpAwy/2v+nCElTCJ7lEim7E+ZtXv7G+YfJhLKlGElCSH5pwJkR2NT4y6sB7uEfNtkLWB3nvAR+hAueCBaFJ55JRoj5ICcQB6DGpxlNjlUUchKsRgx+eAKbP3PNLlXPDrhNAXr3i7dzQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247274; c=relaxed/simple; bh=/HaOC0UQuUCRG7UtKoSrqnIxQLLgF8uNCr3tEiNAggM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LuQcxTgP4BPdADdrxKV/0B92K5ahT24by96WSywA/cZbD5Cje2Li1u/sKEkXrES6leKz9qd/2yw9oALKhXZpuRdkVqhB1/bKtp0paWCbSWvUihZKcSGsJyWgmCdPNGxx6Hx/kdjSmDP7X02VSNEKmIrMHZUVXT8xRawx6VFO44A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=cVJPobvo; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="cVJPobvo" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-7b6edb82f85so1988184685a.3 for ; Tue, 07 Jan 2025 02:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736247271; x=1736852071; 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=TwdwuAkwGCHw83yVS+OBZ5UTbtgtyF3XHLP2TniQ+hw=; b=cVJPobvoPkV8P8HWiWovB6paXXBwUIH1OXR/aah3q7AIQn94XZ03Kc2uwvfjsVvOqa 4O2jX2uv9n3KWr8T1MqycoW2edSCeJ085yplu3cTUvr3/Ynwjr/MVkYCIOh+x49w89nA 6V3Uejb5jeblgoOD3YC57vvpGlghni5vquHZg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736247271; x=1736852071; 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=TwdwuAkwGCHw83yVS+OBZ5UTbtgtyF3XHLP2TniQ+hw=; b=DiK01leLNu5qqG/ynUW7BXgkig3QAMvmfw8NwhvKwZecZbam6oN9Xi9IeQPu2zTdTM CGoQ7YNGYhdSMIQczVtoP2WCMRuMp4aNu80IjXEgcNEXKe0DqZ52qCxUS75irPwi2Hzr Bq+WVECSWiZ2lBGlnTMsVz9Q14q9Q8khPRQF8nfTOR78UFeLIVDHd4dVIqK6WBlxS6Pq c657mr5jRb83A52XMFgejof+EO6qFOeU8WkT4nGJqUc8n6AUgs4yYli3YTma2gb5dikr 5ZtbWRPdxOPGmQfhR+8yWC+25uQ0WdHCG1/1RegYzz0LucIuJHikn3njxWwcMo5IMFzM /YFA== X-Forwarded-Encrypted: i=1; AJvYcCX0gaqQi7J7NbH+LmKkM1TtenvW05hUetwvrlFWUTbpikc1F1sV6hEFQ1O2gwaKAvxOGX1IdN1OQfC01E3I@vger.kernel.org X-Gm-Message-State: AOJu0YzjFpkmmz9qJWvuJXkRoPRAm8msIFTqvoK28X9ahTEEVjrRdQ1L iIRqmVxR3rSTtqg0oIsH4Ry0I25OtBztiZMfH6H9aqxgqzfv8FgEJuwhtYZlgw== X-Gm-Gg: ASbGncthLIPG8yMzXTMgcwFsdJqs1gnUNmLYaunz0dmEnUpy356zBkXJEc+BDJw9VzR XpwQhg6CCVaD5uxNijdN7ycsWAKFoyqcnmw3u0T8Xwv6KPO7XAXYOxyS4Vt/KmiBx1VRGIHN3Dw 47fRK6RqEiVrHw05cg6NLc/64SJsBI5bgoqO+/L7PJ0N+Jg49dz5MmstRg9LSkgtHT4Qg3sasdY FAC8ti8eeMVpyi8RV4KGvhpLrfYMtw9jrgKM124k3Asvm428hUyMhgEhK8accJIB9HN25pvh2dy FxY7KVrAdobueWqZ0KAlm558v27GWlbKffC+ X-Google-Smtp-Source: AGHT+IFUED888CZMdpqwUZpQU35gMcTaIVUuxirN6mnBatoGC47VT9cuT03Is5gpmuF9mhyyMM8HCw== X-Received: by 2002:a05:620a:459f:b0:7b6:d4df:2890 with SMTP id af79cd13be357-7b9ba6efb22mr8450427785a.4.1736247271590; Tue, 07 Jan 2025 02:54:31 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3eb30b97sm185094401cf.86.2025.01.07.02.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 02:54:30 -0800 (PST) From: Ricardo Ribalda Date: Tue, 07 Jan 2025 10:54:26 +0000 Subject: [PATCH v5 1/6] media: dvb-frontends: tda10048: Make the range of z explicit. Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250107-fix-cocci-v5-1-b26da641f730@chromium.org> References: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> In-Reply-To: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 We have not been able to find the relevant datahsheet, but it seems rare that the device will have a sampling frequency over 613MHz. Nonetheless, this patch does not introduce any change in behaviour, it just adds a comment to make explicit the current limit: div by 32 bits. Found by cocci: drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda Reviewed-by: Kosta Stefanov --- drivers/media/dvb-frontends/tda10048.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 3e725cdcc66b..1886f733dbbf 100644 --- a/drivers/media/dvb-frontends/tda10048.c +++ b/drivers/media/dvb-frontends/tda10048.c @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, u32 bw) { struct tda10048_state *state = fe->demodulator_priv; - u64 t, z; + u32 z; + u64 t; dprintk(1, "%s()\n", __func__); @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, /* t *= 2147483648 on 32bit platforms */ t *= (2048 * 1024); t *= 1024; + /* Sample frequency is under 613MHz */ z = 7 * sample_freq_hz; do_div(t, z); t += 5; From patchwork Tue Jan 7 10:54:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13928688 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (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 E3F8F1E32D3 for ; Tue, 7 Jan 2025 10:54:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247278; cv=none; b=bNhB+jkUct6yWDZ7JlruWorpjhAHaTn+LnRfA3Ph8VP5ks9Ib8HRuLICEBvxvmDv0lBjVa+HTgphTdIzbqr1KyjIIYzj5ZbAdzObKq9+9xY8h5pEYWN1Dn8Ee4DEvnJpzVOsnkdtokKEhTV3z9L2ZykJtsJQxw+Mes0Lgqkf7RQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247278; c=relaxed/simple; bh=wNqPLVCH3hrYmgRdcOul7vFmT8NC6JPiLWWSYrAMGoA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RdmTZUjpxll8RHNhso1M5JZ4vfhg9bu5PBS9uUJ9Ou30wExknLNnJkSYYOZ0L3j2kRKyg0/K+b1DzJjVjQs9lqeJ0ZRS6y2QFSexQTSDViFnjq65vrcAQ60MpFYBivGpVPqNuaIxbZXp5pZa92HgR3SS4MjeQhxY0UbvjDXaHZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=mWPAcYSj; arc=none smtp.client-ip=209.85.160.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="mWPAcYSj" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-46772a0f85bso128425091cf.3 for ; Tue, 07 Jan 2025 02:54:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736247273; x=1736852073; 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=oCQd+Ixr8eKIqoAvIvPqynaVVvGYXfmfSE/3mmNL7HE=; b=mWPAcYSjr9grfY3JXlYpA2Sy3GBF4dZ7nxYh0BxR0v/EwB+LHCcBCT/ExMOdapdhgx qXgrZOSJb57RU1His2CdnDRybknfFEkK2dG96jPfVYPvK83BSqwHSK/araJ6vqgSpUKX YSstVU4HyZlZpqQi4+5zo5K7Zw2m+QYrttPFg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736247273; x=1736852073; 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=oCQd+Ixr8eKIqoAvIvPqynaVVvGYXfmfSE/3mmNL7HE=; b=W4swgnImucUqglihxUwSq7Xbs6fkkinG27RzA/NHDP2hR+YCKOk7lgyot4j287Ctaj YZf6/1npDWzJ3rmbj/grbOUxXVdLpj2kVA9ILH/6rliZwToLh1Jzy77MoIwKnJXkXwO5 mqmXhIc/sH3mp5/9+EmPQwpf0K8eTTW7x28HBCeoFAY8j2TIS4t6fqLzcu6RVlSw5L61 +DU028uRC7JXTjvyGmrF0ZfpYcpChNyNhceKz1sT+WJYGOPSEJ+rz9ttRsw9zruKwQi3 efjF6c2ysxmZ2rEBJ1mBjfoqWAUxLg6HHE8UKj9kmC6JsBtlh338QT0ZkPaaMzWNFopM aU6A== X-Forwarded-Encrypted: i=1; AJvYcCVD9CW9wxLbjXxKpX8k2LMT86F+ZvjxwN1NZ6hTUfPTaadze3y14IQYtmRM23Z8ZN6BCnPtji6PgBtYrq4P@vger.kernel.org X-Gm-Message-State: AOJu0YzuD1aJyV6nmnbND5A2uV3LNwF7hdshj7l3VnP7BANehatZR2EE ARwEuK8rPig4V0CTOvf27Xgxoq+P4KUZNzqe2XMoY2DeD/3nH2Tz/ihj/xyWeg== X-Gm-Gg: ASbGncuNlZs2ak0yhxtV5YqIOEbbBu6rRhndUv/p93xr/wq4ZcAStRFiwecd6FAqcKm WPKR91lQUYNFbBHzDrvM+2WRo9XX0BWLZeW8dzno5kR7YIN+CNALOOT8Js+PrVDSdTL/OEqfQNJ mJhUu21eXoTeYdRc8CjblVPyM27scsuCTaw5GcuoEgR4cwDo7YgPdDXjV0Qc37Mt8eYmXYqzI3X qzGkxUqmEzjijMreTqLrdtBVOX2xPXqTM+Lv2lEOmKLKQTX8jLTPR1ebaecrCi0fWJf7yoVJEHF VdpSeOPvmL01hWN+CchjtfYziybBjY05C0BJ X-Google-Smtp-Source: AGHT+IGKeyvvoUZ2svFx+YPGpG6WrV538GXxzvSPHqikjfxzI0msn6hiyTBtp0Rw8fsFZQS4ecDYVw== X-Received: by 2002:a05:622a:8f:b0:467:5e1c:1ab6 with SMTP id d75a77b69052e-46a4a8ebaedmr1117456131cf.24.1736247272995; Tue, 07 Jan 2025 02:54:32 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3eb30b97sm185094401cf.86.2025.01.07.02.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 02:54:31 -0800 (PST) From: Ricardo Ribalda Date: Tue, 07 Jan 2025 10:54:27 +0000 Subject: [PATCH v5 2/6] media: venus: vdec: Clamp parm smaller than 1fps and bigger than 240. Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250107-fix-cocci-v5-2-b26da641f730@chromium.org> References: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> In-Reply-To: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 The driver uses "whole" fps in all its calculations (e.g. in load_per_instance()). Those calculation expect an fps bigger than 1, and not big enough to overflow. Clamp the value if the user provides a parm that will result in an invalid fps. Reported-by: Hans Verkuil Closes: https://lore.kernel.org/linux-media/f11653a7-bc49-48cd-9cdb-1659147453e4@xs4all.nl/T/#m91cd962ac942834654f94c92206e2f85ff7d97f0 Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files") Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/core.h | 2 ++ drivers/media/platform/qcom/venus/vdec.c | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 44f1c3bc4186..afae2b9fdaf7 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -28,6 +28,8 @@ #define VIDC_RESETS_NUM_MAX 2 #define VIDC_MAX_HIER_CODING_LAYER 6 +#define VENUS_MAX_FPS 240 + extern int venus_fw_debug; struct freq_tbl { diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 98c22b9f9372..c1d5f94e16b4 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -481,11 +481,10 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC; do_div(us_per_frame, timeperframe->denominator); - if (!us_per_frame) - return -EINVAL; - + us_per_frame = max(USEC_PER_SEC, us_per_frame); fps = (u64)USEC_PER_SEC; do_div(fps, us_per_frame); + fps = min(VENUS_MAX_FPS, fps); inst->fps = fps; inst->timeperframe = *timeperframe; From patchwork Tue Jan 7 10:54:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13928687 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (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 CDB4D1E6DCF for ; Tue, 7 Jan 2025 10:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247277; cv=none; b=i0LSL6PmJTUE/c4kmkXXcMFkaOvtfAUQQhdtHbUdEx13oXEKfULDxU1CLQdSYQpPo0RHdPH0mFD+wMRMLx2gKhqoLnaHjnmmguE7qgmY1jLqmi0pUXXEfqkMtcX8efrx/iFwTnw9t0XhTFBR4DtFdLhdmoOuHFAW/bnFyd2AbAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247277; c=relaxed/simple; bh=+5gKBR6lmCbLgDxwlcOKTLF2APbAil9sB0eDtQkBz/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JRLhwztVnR2W4e4r+cF8lVyBJQmKQSDjKE3XitdJLvhY8M25hsxMRuUoi7INJgGBz/BAntoDb8WmCv9Khk5fEILu8BdvXrSKjqa/QcFOLthUGuCqMML7wYydA+fQLQY/UB3ByzQSi/yGQst+ZUv3DUUivilAwJEwNp+2oeQ273I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=OmYDnlDY; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="OmYDnlDY" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-4679ea3b13bso114472641cf.1 for ; Tue, 07 Jan 2025 02:54:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736247274; x=1736852074; 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=oGXizJerOok0lDZxPeMPfVFSvShgmDlyLJgvxCS81kE=; b=OmYDnlDYdk/KuFj9tntNVbb0mjhr0Tlsf69d3jthYs7lazDlPW1KmPyMtj2epA/9hR ZidYI49re23KxMxOg23mgOThD3MRDN2sRnvUbCP1etLl8i+W8AUK0ZceWqU8vULe5oIP zxLOE9T94ciccTwrhOcnenUlfd19N7OBaDtq4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736247274; x=1736852074; 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=oGXizJerOok0lDZxPeMPfVFSvShgmDlyLJgvxCS81kE=; b=bjTNWDbEYTWoQ3RC/8YUlYbLHMVyof/pzxj5oyTANR/0QX/DRjRjDLJf7FdNDjQOwD baOCcCqp9SY20HKTQkN39QHs0xhB3JEYcAIgs+KUmaL0LRgHzwzf24xMi2Z9VCFZnO2x k6nRy2NuZtP6f/A9iZ16VlR0MgccKcBC5FcO5sGbrwldu35aDHVxB5tvGfcbvdGl2M+q GbZ+hYNJGf+1yw0n5cbrGsUJnOR+FYUDyBjq3jJLll6zS9AGYk9Qj402eey5fd5wEXDQ sgzTiteAnOL9u6oJE9XvOGker5kiZ9mZBqIAOUbjsj19QcW2+qVbo70knJS+HgG+R6A/ lAEQ== X-Forwarded-Encrypted: i=1; AJvYcCWTH1osksjmJ0RuUJlKgOCGU8whTeeLOiN68Kakj6kgBY8sza6iMpbVL+6XavN8v+o1r1ug2BK0IC4HOUnw@vger.kernel.org X-Gm-Message-State: AOJu0YwyVt2RBHthNqlah9upjZhjLPjqmxuKZFRvIZH+vKgf2u20+Tiv mBJkjbqMhqeeNEIPFQAosr9frbRta3UkVWr3dBt7KT1uguoPMoLrz4sPFvGxMw== X-Gm-Gg: ASbGncur0b97Wj7pVTqZLdmNYEVePaneV0xj9pI9WFP8eo/kwdzlTV1FkZtUqHx446c V5JCbLNC7CEsgaB72DQhuqdY3EQepYwXtyrWMhbgZ/GMHVU3MizTqWVAo+87dLLgRtPsCsh29hP JSXat9IgnF5QznKl2JPCYA1Y1xss48B7cDT5fmecseHOReaVaY8xsQgPTgjOIZqAKMXBwM6BGLX SGcAkTLl5+VCTaRvKz5tQw9f7ptit8kMtQpJGmfGpKwy3ZollxXsHMURm0UD1VX4E15aulbh3xl ZnpmkfvlowFur7U+O7RsDeZBfZwOaW+BH9jn X-Google-Smtp-Source: AGHT+IHz199hYVLZJGl8XkV6sZ980/ECQyaTerXAnHVSgTk+59gGPDGHyUBPMp6JKsfQxJgo8zL/sQ== X-Received: by 2002:a05:622a:11d6:b0:467:b625:b37f with SMTP id d75a77b69052e-46a4a9e2d94mr1239780591cf.56.1736247273768; Tue, 07 Jan 2025 02:54:33 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3eb30b97sm185094401cf.86.2025.01.07.02.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 02:54:33 -0800 (PST) From: Ricardo Ribalda Date: Tue, 07 Jan 2025 10:54:28 +0000 Subject: [PATCH v5 3/6] media: venus: venc: Clamp parm smaller than 1fps and bigger than 240 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250107-fix-cocci-v5-3-b26da641f730@chromium.org> References: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> In-Reply-To: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 The driver uses "whole" fps in all its calculations (e.g. in load_per_instance()). Those calculation expect an fps bigger than 1, and not big enough to overflow. Clamp the parm if the user provides a value that will result in an invalid fps. Reported-by: Hans Verkuil Closes: https://lore.kernel.org/linux-media/f11653a7-bc49-48cd-9cdb-1659147453e4@xs4all.nl/T/#m91cd962ac942834654f94c92206e2f85ff7d97f0 Fixes: aaaa93eda64b ("[media] media: venus: venc: add video encoder files") Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/venc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index c1c543535aaf..943d432b6568 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -411,11 +411,10 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC; do_div(us_per_frame, timeperframe->denominator); - if (!us_per_frame) - return -EINVAL; - + us_per_frame = max(USEC_PER_SEC, us_per_frame); fps = (u64)USEC_PER_SEC; do_div(fps, us_per_frame); + fps = min(VENUS_MAX_FPS, fps); inst->timeperframe = *timeperframe; inst->fps = fps; From patchwork Tue Jan 7 10:54:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13928689 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (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 5514B1EB9F6 for ; Tue, 7 Jan 2025 10:54:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247280; cv=none; b=P1/V12wAYaY68KThu/UzHxNvwE66frXzSHG9pv5gbM/r6/j/4FLrWvWSV1XPvHusIwlQP5UnYST6ZlZVFHPZpEkX6mcAZxJsPEB+Cjt6mK383jVedEY/Bo1MIJGwtTwzemjRB2N1Pfe+ontWtj1gqMflYtwc1Td8EiiteRSt3wU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247280; c=relaxed/simple; bh=BHqXjzXegfvyleJbFzCIkEZ/Ohsk17MMdh8326GOkbU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hPOl40JymeH/FB3Hz6zmyMqbvLxcPdY6dHxmZIWx4VJGcTccJj28aKRuCTBVm2wVayG/zdN7fH+6Nb8KzTK2NHAutW/amUnOQ4Dm4LfxrS9dwv24SkK2V5B41rrlw2aWq1M3b+mKDh7j6+xRQgEpT447MG95ICva2v5WGtm6Vwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=CguypKy6; arc=none smtp.client-ip=209.85.219.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="CguypKy6" Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-6d8a3e99e32so125532636d6.2 for ; Tue, 07 Jan 2025 02:54:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736247275; x=1736852075; 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=L1KYqWnRc25c7X6AgX8mJMBcXv6X4I+XW042aps6zcs=; b=CguypKy6ZMpZRnG+NSQzB6lh9yeD8YcENqMQfGVUa4ULeiqNmnTg1QRAxQZwJdFTO2 vEwdjF3rFscKcLvgTNHNyZ1V+SXQOuSvd4ewAzMsfjPaBCIAkxpWTRA2qAxYY9IQUD5B 0d/m17Vb6rOnGE6tr2Lfp0fMXcxyKOSOmBYKw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736247275; x=1736852075; 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=L1KYqWnRc25c7X6AgX8mJMBcXv6X4I+XW042aps6zcs=; b=b1D+NpaQTMGOJGtm9cnDq0EzK7aFS1rm0YGJvvWBE2JHxM4mBl0ySKaLY1fN4h/Pna dSZmeae2PCPBtKHJbsogGc910C08KaXPi4ZI0LIVIXe2kyJGpl84TeEvqfl/4JUijZaB Ab4D6Ozq+y1wINZCdWyVpTfsFRBbJCmThCrYV6yRBflZ1nk9Wko23nPzdmPFNvvAdgAY i/C5NcMRpy48ZGuL8S8YfiauTvAwM0Iil7Ilh71kriobP3CDPZGFt8vIFTu62l2Pp3hl 7/iQ6coL80BgqTVsANF5xFwKfHXZNuefpCKMICKbd1TZVNlYjT8tdAat9b23SR7jLuUa Y9cg== X-Forwarded-Encrypted: i=1; AJvYcCWxktUX6LYMK2k/0Ku0qFzkXXu4kfOcoL5iMrDOyOpsaVuUy8P3BYbHM1FKz3A7NdzaC3GD9BicKBj9KMM0@vger.kernel.org X-Gm-Message-State: AOJu0YwtslvWd9+DvBETlZdKfDvzroaUWz5hPgjB2uvsK8DYWpf9GjNd SryH7KsE1JxdiFuN5FJEUy6Hk3Ro+TKGIC0+AqXqosgX2Ciaw0G7DwVdUYq2HQ== X-Gm-Gg: ASbGncvvKk2oFUltKHApKLswRvigN9PO6mpTq56yoSUssQw+Cn4l23hboaQdbVIyERi ISPaUievmZF40qz0IN5sV8GpsiHZ3iyMPhC5HDaf4uOEeiIUNFvxz2M/0D02w7sSpzQwXKJQCCJ eEVFD1iOwqlKppf0hYUNT1qiF7r6y0LvqUNrcz/yNmyHQFNy6sxwTm3mA4TPCqj4/McxcJkZt6R 0VYfP9IuN8pNQj5r0r+HvD9wj5P1A2OOv/lGXmyjW2ObGCqz0OwcjGUtRMfn7//jHoa7j/4wbsF RG5EuPTLXHtdB0gVRQHLW/gm46JZb9Hp3i9y X-Google-Smtp-Source: AGHT+IEeYqSZWdRFjCueXXmNknxsLb2PxqwfnTmsqfcQ/lgV7+HWTnTmz1e34p6hSwZwuYchYY4mRg== X-Received: by 2002:a05:622a:2c3:b0:466:a9e6:6d6b with SMTP id d75a77b69052e-46a4a8caf6dmr989977671cf.15.1736247275338; Tue, 07 Jan 2025 02:54:35 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3eb30b97sm185094401cf.86.2025.01.07.02.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 02:54:34 -0800 (PST) From: Ricardo Ribalda Date: Tue, 07 Jan 2025 10:54:29 +0000 Subject: [PATCH v5 4/6] media: venus: Remove timeperframe from inst Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250107-fix-cocci-v5-4-b26da641f730@chromium.org> References: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> In-Reply-To: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 The driver only cares about whole fps. We can infer the timeperframe from the fps field. Remove the redundant field. Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/core.h | 2 -- drivers/media/platform/qcom/venus/vdec.c | 15 ++++++++------- drivers/media/platform/qcom/venus/venc.c | 16 ++++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index afae2b9fdaf7..1d4fd5cc75d9 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -407,7 +407,6 @@ enum venus_inst_modes { * @tss: timestamp metadata * @payloads: cache plane payload to use it for clock/BW scaling * @fps: holds current FPS - * @timeperframe: holds current time per frame structure * @fmt_out: a reference to output format structure * @fmt_cap: a reference to capture format structure * @num_input_bufs: holds number of input buffers @@ -478,7 +477,6 @@ struct venus_inst { struct venus_ts_metadata tss[VIDEO_MAX_FRAME]; unsigned long payloads[VIDEO_MAX_FRAME]; u64 fps; - struct v4l2_fract timeperframe; const struct venus_format *fmt_out; const struct venus_format *fmt_cap; unsigned int num_input_bufs; diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index c1d5f94e16b4..e160a5508154 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -471,10 +471,12 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) return -EINVAL; memset(cap->reserved, 0, sizeof(cap->reserved)); - if (!timeperframe->denominator) - timeperframe->denominator = inst->timeperframe.denominator; - if (!timeperframe->numerator) - timeperframe->numerator = inst->timeperframe.numerator; + + if (!timeperframe->numerator || !timeperframe->denominator) { + timeperframe->numerator = 1; + timeperframe->denominator = inst->fps; + } + cap->readbuffers = 0; cap->extendedmode = 0; cap->capability = V4L2_CAP_TIMEPERFRAME; @@ -487,7 +489,8 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) fps = min(VENUS_MAX_FPS, fps); inst->fps = fps; - inst->timeperframe = *timeperframe; + timeperframe->numerator = 1; + timeperframe->denominator = inst->fps; return 0; } @@ -1612,8 +1615,6 @@ static void vdec_inst_init(struct venus_inst *inst) inst->out_width = frame_width_min(inst); inst->out_height = frame_height_min(inst); inst->fps = 30; - inst->timeperframe.numerator = 1; - inst->timeperframe.denominator = 30; inst->opb_buftype = HFI_BUFFER_OUTPUT; } diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 943d432b6568..17bec44c9825 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -401,10 +401,10 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) memset(out->reserved, 0, sizeof(out->reserved)); - if (!timeperframe->denominator) - timeperframe->denominator = inst->timeperframe.denominator; - if (!timeperframe->numerator) - timeperframe->numerator = inst->timeperframe.numerator; + if (!timeperframe->numerator || !timeperframe->denominator) { + timeperframe->numerator = 1; + timeperframe->denominator = inst->fps; + } out->capability = V4L2_CAP_TIMEPERFRAME; @@ -416,8 +416,9 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) do_div(fps, us_per_frame); fps = min(VENUS_MAX_FPS, fps); - inst->timeperframe = *timeperframe; inst->fps = fps; + timeperframe->numerator = 1; + timeperframe->denominator = inst->fps; return 0; } @@ -431,7 +432,8 @@ static int venc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a) return -EINVAL; a->parm.output.capability |= V4L2_CAP_TIMEPERFRAME; - a->parm.output.timeperframe = inst->timeperframe; + a->parm.output.timeperframe.numerator = 1; + a->parm.output.timeperframe.denominator = inst->fps; return 0; } @@ -1454,8 +1456,6 @@ static void venc_inst_init(struct venus_inst *inst) inst->out_width = 1280; inst->out_height = 720; inst->fps = 15; - inst->timeperframe.numerator = 1; - inst->timeperframe.denominator = 15; inst->hfi_codec = HFI_VIDEO_CODEC_H264; } From patchwork Tue Jan 7 10:54:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13928691 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 91FEC1EE00C for ; Tue, 7 Jan 2025 10:54:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247282; cv=none; b=Ruj6KfRcdsHeTn2e8Berne1Aky6cOY8iexjgIa1wZclrqWHJqU7lcW9MvwN2Zf+jScQCpft6sc9kpb3bOqI0E7jpHVnupTNYj/RMIZGmZqqnvkaOVtLDsDIgE4MNht/2NEWLA/4NRHKxbpP6bOmkuVmvt+vY7/Wc433t3xqfHuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247282; c=relaxed/simple; bh=jFMkE+aUW4A2Tjf06APpBG1sAvp2ejflRJ8B5s0jBLU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sUOnzDJZeWODL6IRyqBNAQJ+CvzNzNFW6nKJrscdSiKID3U3B2Y7ZSHeKk82Vyifv5u4VuciIDMhPYPE3XxksH/o+mO8JxcBvYu7Ku9OvaHgSqxNNdt7XCNrJC/hwulYsz7IAS3xTAb1Lhf2IO0noS8ekxUmrB44i0/53XvMdl4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=NT2xyJq1; arc=none smtp.client-ip=209.85.222.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="NT2xyJq1" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-7b6eb531e13so791741385a.0 for ; Tue, 07 Jan 2025 02:54:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736247277; x=1736852077; 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=f3BoX2c5ZbHlzZ/xObQ8c1PFxHvs7MLN/22FFGinwVE=; b=NT2xyJq1NDPYIKRf+414boTnR47X/0q5JYL/BQjJGxhq8TTORpSUxs4SLC15fp9FJ2 yLWdENcKBDgb3V2qUZ2EKxOXApbAohhNRzb42UFuCLLTr/m26lspjIdC2HflZ0kNiGqu LmkG60b3Bsh7wEEaUPeFSiVlpUfuEW2iK+8r8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736247277; x=1736852077; 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=f3BoX2c5ZbHlzZ/xObQ8c1PFxHvs7MLN/22FFGinwVE=; b=ksucmvSBwCiCiOESvwujAZTEz+N9kOSsZnoJ48SkVu9H7A7Z4KJUuwbsXKlI0CB0q9 wWD9036XdNCs7+JTzaqFbF+WvesAbla8BJVMKaYKot3hpgPBRt0dnDDv7buNGDZuiQvk B4IdzNdr+44/tbxRbw1RzxVZ8wKCqnVF0FzSmrDDIKkvCre0GV75CGd3/j9LoYVGslgp gf38wNWQ1jmF+ri4o5RYudizTkujrxHj96yCQPDWoDgAl2bbSNxaD9xMCWmmoQc8D7SZ 4A+61sQCypBeEdXs+TGWCiOM4vLZJNjUayIHq6/UfigYPGG3Iz7SqRbuBkou5TskhtmD kw4A== X-Forwarded-Encrypted: i=1; AJvYcCVqT3zSsJaZWbVuFB6XuFGJftTUvMoDLhWv2JU2HnZmstfwlDfEAGWFTWaIhvglhtjmEa8s9GmUkaXLRqn3@vger.kernel.org X-Gm-Message-State: AOJu0YzlFwbYgZVYIjA0oTtjA8ALkdfaRIqDoBWdeytS9T8qnjiZiwYe aHrRrNTvF6bouEMqsMWu3GH6PVh0xn848RjxMR6zw0iZYmGNzES1HWgsVV3+iA== X-Gm-Gg: ASbGncsm6jtxYrAJOPz60b9J/VMUtDiXpXeZGd/nTPwRUk77z+umTixzJewT614WQNU o0Oxr//en8SKuDzcNrF9gj21KUYwmw06mde20ur+0UTBAnEZzD7GTeQRdyJmUNcwagVQTNUy7hc p7nWJvR3lA9nq3sSdE7SWZyhLiC3ltjarbVF/VvLOq8BwavKgucm+IqgD/NuerKO3W3LN8Cg5CV t83D43NWzwywwm2usr2eW+W9iUmLodpOblDfLEazMl3PVlYcvlH5j+NHKQ6UIs358uAUAyeNkU3 9/mrPyr5oWcfBCoXSxdz+c6sDjAuWS1/lPQm X-Google-Smtp-Source: AGHT+IGAVyKTISN9zpaJnwozwU+COiRxpnABqxxsvJgsi3kg81agGnrCLMtsX46fVIPT7llJuWHApA== X-Received: by 2002:a05:620a:2a12:b0:7b6:cb07:24bc with SMTP id af79cd13be357-7b9ba7f6642mr9826632085a.48.1736247277498; Tue, 07 Jan 2025 02:54:37 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3eb30b97sm185094401cf.86.2025.01.07.02.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 02:54:36 -0800 (PST) From: Ricardo Ribalda Date: Tue, 07 Jan 2025 10:54:30 +0000 Subject: [PATCH v5 5/6] media: venus: venc: Make the range of us_per_frame explicit Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250107-fix-cocci-v5-5-b26da641f730@chromium.org> References: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> In-Reply-To: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Fps bigger than 0.000232829 fps, this fits in a 32 bit us_per_frame. There is no need to do a 64 bit division here. Also, the driver only works with whole fps. Found with cocci: drivers/media/platform/qcom/venus/venc.c:418:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/venc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 17bec44c9825..2c1836712362 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -412,8 +412,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) do_div(us_per_frame, timeperframe->denominator); us_per_frame = max(USEC_PER_SEC, us_per_frame); - fps = (u64)USEC_PER_SEC; - do_div(fps, us_per_frame); + fps = USEC_PER_SEC / (u32)us_per_frame; fps = min(VENUS_MAX_FPS, fps); inst->fps = fps; From patchwork Tue Jan 7 10:54:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13928690 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 0205C1EE7B9 for ; Tue, 7 Jan 2025 10:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247282; cv=none; b=W52yifuJ3yF+o5wmV9xj/OkXWuFTTu4hg10+5Lywgn3+81MoMY+zpQmy3Ke7mRhZufozkBLaot7Ip2Xy/fo/iRY6FUfq34yiBEvDa/cxeMNF0hCk+czuMbwLmcZ9StJ+opXA+CSsJhhfNiFRMOHOWviP91UvVRm1XUD+AYuirQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736247282; c=relaxed/simple; bh=hAlPOuL4YIiXg0HpbIYhah7+pVVbm4tj/0Q43k0VF20=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JIGRR0XAiISVQg32NObrSBpI1XCEUUe/BPOAgq4xEKIniM7malpvNF66GP+1x3ruJObNDchJ/rMc4zMFzUVDqT3EpypQhFjNPie1G9HTlshO6CnzCUajf804d1sPcgFwbJeojUesNY8rfuUtfV7e4BEepyoy9u/1ml387l33Lzs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=YyyZYg/2; arc=none smtp.client-ip=209.85.222.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="YyyZYg/2" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7b6f19a6c04so1312514085a.0 for ; Tue, 07 Jan 2025 02:54:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736247279; x=1736852079; 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=x7AhuqiCmj982Ah3x3XQKiIUQdsA0iVwLzLzuPzwXZk=; b=YyyZYg/2LXoTHPab+Qn3ruxV+Qj39JIkpaDjyMXjtRQvxTsV8katWB4fkd/8Kgk9+P zBYuRYeJ/2VKW5jy9PFYSiDfvmvlzv+buDOlxrUVDVviYPktzINuMR+WQUf45VE8Q9Lc HbFRcIqnngzLTHfkwHtlcBUBegrxOJKPTbROI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736247279; x=1736852079; 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=x7AhuqiCmj982Ah3x3XQKiIUQdsA0iVwLzLzuPzwXZk=; b=U9dZ1b1Qo7FfT6FvOnKeUqBuHe2vrtvRzajuTBff5fXv3v+IvftzxYM1BIEzUVld8b n7JsapmWdPz7y2j7a8IQ+TaFj6aNgkMC0wHcesXrBgdECeTdJcXXIeZkDPSmy2csEgD7 Jsrr2a67Vu5RFfiaBBZgBEWqeDYRJlLqetoW9T8hi9/MngW6+kTpZrYY6LpXzBlgKkyP 1rSUOH4i8SLHrRUBCsRr7e0ejzliQosjP7mwC0g872YPVZ1TXSGxUUhnTagesZTFmAKg NmZIR8JoFS7GCJvFvqiGKsbAjBNEgDCGuOBOEvHdTT5aG9f0/JMxinxSYasgizH6aGVD L8Bg== X-Forwarded-Encrypted: i=1; AJvYcCXYCRGK9ttdPxjho5aPtkMUwL10NwvGmBfw0Csp2nUIaaTMFUS4KRYrAwNFkgAw3D+b35fFO0PnyyTNoAwb@vger.kernel.org X-Gm-Message-State: AOJu0YyZuId9V/BfWo6D9WO1V0JxNWdCv7Px9vHY8nQ9QyuVko7zgM5U Z6aOaiBY7SVIxUrmLrHx0lTyLrY6m/8AuP6ofj+JhGl0H8SJFSLSUcDiQOcZbw== X-Gm-Gg: ASbGnctWCDFJGS3MNK+6Or95qdIaDyY9uZwlNp0WFSi85DVN1mS1ljtS3mRxDl4/hiy jyQmTfturUrh3Gflj4cTeQIugz7QRjSYqkZg2FGgqlj+WtJze4Heglsx+DvvF4RIPvsamCdZaHH LYal4j+SlXF4dF9He26KsIFBd4/TvOOADriSgp6gCbYISj73BD5Gestmo3iQPKXA67TRYLpxo/1 1q4jH0eUQdaa3szrvnYox7cpihClskXyp2Vic/2mTiCdIwP3dI8UeGkdop8H7b7KPlGKP6fPtHo ZhUkIshW/WsG8OZxxg6aUX8B/mWK8W2zzaOb X-Google-Smtp-Source: AGHT+IEr1GIvCAibNT1Cus6y+TxBjy/ciNtZckuKb7ozOEXqw78URoC43V4anznqKm3gQW/t4bn6Xw== X-Received: by 2002:a05:620a:2948:b0:7b6:cf48:ed5 with SMTP id af79cd13be357-7b9ba7168edmr9711278585a.7.1736247278981; Tue, 07 Jan 2025 02:54:38 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3eb30b97sm185094401cf.86.2025.01.07.02.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 02:54:38 -0800 (PST) From: Ricardo Ribalda Date: Tue, 07 Jan 2025 10:54:31 +0000 Subject: [PATCH v5 6/6] media: venus: vdec: Make the range of us_per_frame explicit Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250107-fix-cocci-v5-6-b26da641f730@chromium.org> References: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> In-Reply-To: <20250107-fix-cocci-v5-0-b26da641f730@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Fps bigger than 0.000232829 fps, this fits in a 32 bit us_per_frame. There is no need to do a 64 bit division here. Also, the driver only works with whole fps. Found by cocci: drivers/media/platform/qcom/venus/vdec.c:488:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/vdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index e160a5508154..aa9ba38186b8 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -484,8 +484,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) do_div(us_per_frame, timeperframe->denominator); us_per_frame = max(USEC_PER_SEC, us_per_frame); - fps = (u64)USEC_PER_SEC; - do_div(fps, us_per_frame); + fps = USEC_PER_SEC / (u32)us_per_frame; fps = min(VENUS_MAX_FPS, fps); inst->fps = fps;