From patchwork Sat Jan 11 09:55:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13935969 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 5C2B618F2DB for ; Sat, 11 Jan 2025 09:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589328; cv=none; b=EJjnIWIePQruhAw2t3j+0sMQrU7+MwiwJROemDw3ud+ZQyGBJNvBymzvgcPPEZ8fQHYILxBF2LMd/DVIOMRr5laGrf0f6+OUSjjSNKdRHM94H1WBc5G9xneEmkbssoTvYYT9LRD1xnDBYw3JX/huwJgTJGaCYxvHEfdBMRgaEtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589328; c=relaxed/simple; bh=cJ3Ao2R6zgoGJgyibADb5EAE6IKBeo/pElOZjlQDp0Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RbOEhxcagcbji92U2swtSJ7f25AT1rcnUniJpw9yf4ovs0Td9bseQsDOmERLT+0kNDe06TDah7hIrrvot0ukxxqxqMViOdASCfDxA7BbATt5zsvdLWv3A+mrnvgU+LlwRyLwV5A6A9796amsh1dvPPjiDuJxoUrHv5LAzafpy+I= 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=OuMYyroZ; arc=none smtp.client-ip=209.85.219.48 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="OuMYyroZ" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-6dcdd9a3e54so26223826d6.3 for ; Sat, 11 Jan 2025 01:55:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589324; x=1737194124; 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=52iWgPg8zx+q33hKer1CkCPQAZHddOV8vj+q0ZyeQAY=; b=OuMYyroZ54iH3H6THbYRxENeEoSEm6U9dF9xpWxmLlRUSPh2Ze2UF+ZOeCuX+s/OKM wnDnthyOIuTqks1c+0lB8q7kVXqGtBxV2xi8rJMwDWMTZd+T9KBlxHodSFZuIlK+g83u A1KZ1Mz1rf1NnH+dkinadBwAmyVmx7LRXFlbg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589324; x=1737194124; 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=52iWgPg8zx+q33hKer1CkCPQAZHddOV8vj+q0ZyeQAY=; b=L/XYUsDx//5oLrQ3/U8/LUQ5c3g3UOxYGqxwcVivsov/W1E62HCxuHKMkoEEiygLzc 3NmBmw71nCXjWU1GNXhPj9ffLycjyJdshK33CLpsAU3rhMG4FXQowmDUkDQaQW/ysE4e yUAmowkBEgn1YV5wi9g6Tl/Pn5wL4nH+dLMpD4392qa7c+SGBqtpgyxlOc/W9sWOYXh3 s2d7iozfMXRIqwYx4rgPozRvoxnFmWkOx9CsKvk/epjnkTJ2GrBCYgkmk2yM1Yts3KbN 20lX9I3SE/VYTrlAFFOmtP7/ZSgO4qBU062/E/Sc54No3ypCF31HVT+6Jmv51zB2i1Ku J0Gg== X-Forwarded-Encrypted: i=1; AJvYcCU86TOmPpxLgDluX6cE9nZFDIVT8ZBcDdlS87Y40JXQ3BqPrI2hcGbWOqfv2+ImDyjDuWbgIa4OwcWY6UAU@vger.kernel.org X-Gm-Message-State: AOJu0Yz1/MHDStEZ2wvq6OsYCdayZWPLvlprZJU8+trc6yMQObt6mehA 0j0Qhgy5B37xnfXtDlmeUE+5zVs7DZVvn5EuIG4l7jLiEfR/951AzxHUddG9Hg== X-Gm-Gg: ASbGnctuL+muQy0rSA0+nF9vfsbO62FNaeunXx/mv+t5xvgbRlvk7qDHh96VOVFRQZ+ e70f/hw1Kb0A+r8XLWsh2U47g5EiLPMKIj/4FSUjLUd9sjXfx5Jg3ZRb+pwx/vUSzeLs4OIQ0yy LhMvc9D95wEM1hPj2JSzuwqORYs2jS0K5Dtu0+r2ukVfLdUvTkaW3JZ0BonQUipCWLcvFLcCuN4 rxlRJPUiJWEeoe80TrOBlQV00uwnHH+KJjH6yMXQ1403r80vRZokDLe0tj2wJoTjlQf0oQce7s+ GVjjimXjuhLJ5DrDnDdaeWk5h2429Je3xN4P X-Google-Smtp-Source: AGHT+IFqiGK2VIMRcFvBZ2YyjvHmdtNauhF62df7aKlMfYRbakz7XnEj9n0FSoSywyG9ImyL+3sm3w== X-Received: by 2002:a05:6214:2a8f:b0:6d8:8e16:7c29 with SMTP id 6a1803df08f44-6df9b2383f5mr216932866d6.14.1736589324231; Sat, 11 Jan 2025 01:55:24 -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 af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:23 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:14 +0000 Subject: [PATCH v6 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: <20250111-fix-cocci-v6-1-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@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, Kosta Stefanov , Ricardo Ribalda X-Mailer: b4 0.13.0 The datasheet recommends 55MHz frequency sampling, with a max of 69 MHz. (Kudos to Kosta Stefanov for the calculations). Replace z with a 32 bit uint, and make the range of the variable explicit. 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. Reviewed-by: Kosta Stefanov Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda10048.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 3e725cdcc66b..1f87eb0dcf2a 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; + u64 t; + u32 z; dprintk(1, "%s()\n", __func__); @@ -341,6 +342,11 @@ 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 typically 55 MHz, with a theoretical maximum of + * 69 MHz. With a 32 bit z we have enough accuracy for up to 613 MHz. + */ z = 7 * sample_freq_hz; do_div(t, z); t += 5; From patchwork Sat Jan 11 09:55:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13935970 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (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 2CA03190665 for ; Sat, 11 Jan 2025 09:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589329; cv=none; b=mP7dJhyeuWIzROU/VI39WNdMPMhnYUDXUSBDYLB5I5xtnloRZjrnXbo+/gRPyi4QWz+QAnsHNykw4vuzRHyYgoh57PTxH/wttCWAxtYSeuJTds9sdkmw6/Q9YcvbKcT/xb5MyfS5mPvB5D5f12q1az9A9y7tmrj7WjTd935vdYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589329; c=relaxed/simple; bh=wNqPLVCH3hrYmgRdcOul7vFmT8NC6JPiLWWSYrAMGoA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m0XyAz5zi1BLRvgdkCc6VfI+tRiWW8SS4mCUmOyhiocERGbvDlV2K3iuoq3Tx1bH2j17h3D713sbh3+arZEiefEF4WNnJckfFs0YYE+3FshNApbYgooAtD+DEu97Byufvy3C+ooDTXMXi5v5jR3CMkDFq7tqFE6PIDF4BZ+VAWk= 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=mzmvtG/6; arc=none smtp.client-ip=209.85.219.50 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="mzmvtG/6" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6d8f75b31bfso23094076d6.3 for ; Sat, 11 Jan 2025 01:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589327; x=1737194127; 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=mzmvtG/6r8mK1zoH6VyrK6+xwRRAqfawlkHIsMszsUYLwvRYn/6TL6Qr61/nvx8rAs Gdd6cw9NSir9g7J/HgO8xO7qrQTrxXDEXPVfhXpquWrhuvR6ClZz03Lm7piHlXl+HFPd BDIm1RO4GnaeoAduoXWkj5W/YsYTt8+q8gCHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589327; x=1737194127; 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=W7yiGOfg2qE9DlGd9EzJveCYARc0sClF4Aq7Y3pHkUOYVA0X2LSlJBYVeCAHEpJ/Ku iN/7HcFv1gaY7xje1Y534q3BbWjKiazOwPQttD2dZKdSI+fbJvBUE7Lge7CccJB1U0Fl v4/crxX04+Ps0tBFgGFM9U2UwlDdadb02ljlwv5omfdptSPLRPlt/QbLpDu3IL9Ya57u 2fAtetzCZQlGvKmp/x/5GjGvAN4gtJzmCON9vPDMM0sslP4u0zDp6Oj4seo2GKTuZX4P WWHnPD76EtmLjL2AYkvjNczXDiuZlEAmQyaCh6UvWJVlrQJrfpY2JxuSBneq2+XyfLsN uqJg== X-Forwarded-Encrypted: i=1; AJvYcCUkoQjZePoMB8KT97HV7HZcJUtBPq37KU+SEV6MIsRgTXxMVhZSYce4iGc168PS3srDei9nlAI5kwfONqxS@vger.kernel.org X-Gm-Message-State: AOJu0YztSu/HCVxtDu9POahBvqyzOWgTJ30eueV8vYpaScHN5OcogRc6 fzO/MXz0CttbnXcRnETeaDRSD6eZ9La9VcgNOCas7aH0lekeEj1oTgEW214gmQ== X-Gm-Gg: ASbGncuZGM+gbLY+swcHI94oNVlr+ZVSgOVy2UlSpdhpxcJQPSNC2J2XIUp/xYQpepz X4K/cBsd7zG7VeomVyWJvhqfdgknew+rZ5uJnqwttiHTHU8NxxAbkJ2FDcG4rHTl4k6d1auE31c V8i88ZLvdUs49F5DQbdEw4yxDtE4Xx08u8V2kSXztJruJ5ReKgL0hYibEc+G9c7QZ416wsrsOD0 Ulg0tRM3fHJhD1woVdiagnYsdDAppd7zX6sxA5WDPIfui1OtnIp2DNK5ACHUgMc7KThiiCh1AjU TkvIGCOvuLWmPR2TTLFhy9UJT2blj/4Pk13I X-Google-Smtp-Source: AGHT+IHefNcjGKIvCVrBMfxFKkoA1dyzaoWQ3H4EQvH1E/W+4lJXoiyaYADeYG3+4FMKAC4ihgK0qA== X-Received: by 2002:a05:6214:4111:b0:6d8:8416:9c54 with SMTP id 6a1803df08f44-6df9b1ed60bmr244663736d6.16.1736589326457; Sat, 11 Jan 2025 01:55:26 -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 af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:25 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:15 +0000 Subject: [PATCH v6 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: <20250111-fix-cocci-v6-2-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@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 Tested-by: Bryan O'Donoghue # qrb5615-rb5 Reviewed-by: Bryan O'Donoghue --- 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 Sat Jan 11 09:55:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13935971 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.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 9204B1917F0 for ; Sat, 11 Jan 2025 09:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589331; cv=none; b=fTTlVfH7WOyz0eQAv3Bv4lQaIOIY54U0FXDOjZxrjDAnOjRiCfb20i2aKHQlHZXlzb84GZE4COQleK3BWWzidxoUOrBFTX9CIVRk6slB7cBa1TstQNsFNl8lDJm8igHG/az3N6kyxTruNqG4d53PPz9acG/DDd84n0B5l9GhaNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589331; c=relaxed/simple; bh=+5gKBR6lmCbLgDxwlcOKTLF2APbAil9sB0eDtQkBz/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZvXiVAPiCqKfIIN4+2yqRTLQFAflD9kDxPoJZ3hESdelDm4271ifPuKzH45WzZOZt4WsuYcC1+G36nlsgykF+feIyDQ0HHI/P+uuqUX5vedjC5U6V6jbBDAXsKD8/ojfcLYT/5/rw1X2GXqv5WrGNXUutfakkcMtFuGQBrG70ds= 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=C96bSz6T; arc=none smtp.client-ip=209.85.222.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="C96bSz6T" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7b70e78351aso236813285a.0 for ; Sat, 11 Jan 2025 01:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589328; x=1737194128; 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=C96bSz6TaoQXqnsfWjFREu7KcD0EjOj6CbbnAHPSV2wqMTwI6pYbppEnh56C8ciRLt H/6p4gZMwGnmmDFNwcYC9KGNozEAzwSgg1WjdQioFifHmeBNay88+Q2Nqm16gdQZszcM ZX50gFtVpauN4oFNajPz3VpJMepN/dQNUDEQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589328; x=1737194128; 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=DULErJhT+7PC49mI8w3G8isu0J3FYF4CwrZBHnj5gEU42r7fcTeztG4dOBvHT4GFPK GJ6uTNXgX43Kj6VCkO+lFpD3VAGjm413DNOA3QbIBPxaU8pXjTUuDnUfYU/zbARmioiq B3ne/PYz9j1jHLLzdg1B/5TGaVq7jwwdFCALwf2Df8VifHF7ySS5FF6XGeRLq8oQIxQB HOQGDZiZuoBPl89c7lI/WP90Z1bjDo5ixjB+Z43047mcYzqIUf9w20kn+Dc465ixyEyX VxW7P49HvrKwdyEkXamE8eOWNtBg6UfxfAhS92JqbDql7wdI/Zxd93w3DPemRnUCzuTD /hZA== X-Forwarded-Encrypted: i=1; AJvYcCWbu8Vmu70tU6wgik2oq3aBoPRKUF+WB7ISJvrYx6HKH9aXWRiPcZNcJaU3xi7ZPliU/+/xdYIex5oyWvdb@vger.kernel.org X-Gm-Message-State: AOJu0Yw1wk+XG1a7MtlQ/t1HkXxU/JsqB3NR9r7siGyOoN8onCLjKgYV Ya8JYfF/y8Q1N1z7RdAiRRy6on1Cpg9GbAKaOPItzNv8efsotNGNJI7+Q5n6Gg== X-Gm-Gg: ASbGncsxVBGNG6iqIkLjeQoVB6XyVug00fLaptswv8N9+9vDRXhmf6uxmAbrLMpXMkE b7fPpbZjTbKSI2y9495ob5HbnNQB/EeLuR+DpTMuibAWGcOxwW0Y5fhm+W++oN62foeNjP3ymY0 HVqrPdLYCMRHgRAZkn0P0AZZJtxxZt25VkIHo28Q3meDGrRN4+ZsRM4aLueuWubwYi5+exSw//C 1iffmSZsXtAnUq3ppPx+/5pvwTsw86eruWOSGm2QJKGlO1Y7WvjNCSKvBGIfyYyiZTkXFEVsVzR xrYm7kAowh+8BGw8rFKf12I++wCo4wLhBm9O X-Google-Smtp-Source: AGHT+IEpVR9I5biYuCr+SXV0UBeBGfKSe31bfLKgP7VOr+BuuQiGS7W1xlNlsmHP///j6pnH4LIVBQ== X-Received: by 2002:a05:620a:462b:b0:7b6:c540:9531 with SMTP id af79cd13be357-7bcd974a281mr2043337685a.18.1736589328570; Sat, 11 Jan 2025 01:55:28 -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 af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:27 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:16 +0000 Subject: [PATCH v6 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: <20250111-fix-cocci-v6-3-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@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 Sat Jan 11 09:55:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13935972 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (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 9B18A1922E7 for ; Sat, 11 Jan 2025 09:55:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589333; cv=none; b=Dk7A4WKY5B0Hs023l7ZSP/tf9YyIBx8teKXbcoPpi141vHQAW1EFQdqiFZkh6KfQBmwo98dyvvN6GyCt0ptczEYeCwZteAZ3xjy1besvLTIxEDWloEk3B5zxIgYcSvXXOOFusbsgaeHhE+ppijcWIV8vzlfo1TcbFwQE+G/sACA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589333; c=relaxed/simple; bh=BHqXjzXegfvyleJbFzCIkEZ/Ohsk17MMdh8326GOkbU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ljy/8MAPurhzQf8ISosQ+HgEOeiDuzURGlfII+V3kj3hNdhzSVLGrNeSzLOHagZ3grupTjEKIliYF7SilLh+04MtfALBo3aUEe1TA/055OV9/dUhIJr1o0CUhdUPNTGRncwGv7k+wdptyCoyxa6lmJJjFtPE4ZyqQdeloSDM02g= 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=eCMys+aI; arc=none smtp.client-ip=209.85.222.174 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="eCMys+aI" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7b6e5ee6ac7so232739285a.0 for ; Sat, 11 Jan 2025 01:55:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589330; x=1737194130; 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=eCMys+aINUeyPpHOqwmcacUWkFZpKdFbU3ZRGl2lokoR4qr5aKpr4UDxLxbAkP0xhm W17GheV+iCuPMwLG3CEpQO/NQ1bwW2Q6OJzTb3cPHwjchTh3BfTxzkGoqiSEtI9FfXfO ck8Uj5y3NhBNhIllRRwxnAaPKwhiZJUhubre8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589330; x=1737194130; 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=Trb0koaDlbOQVEj+FYP7IbxPkRHTgJ+jcvT8t+ssd2fZta+PZZz6/DjY9z92IhwLC2 k8sdR1O8K4SxFO7BXvQZh9xs7db/DODGxd+1Dpiqq0IAbceUZtBcxW5XEOpNBxZf/NCz op4jzAhtsmjWlsa/R//ZFtp9I2jShPQvdyYEAF8EOyQ1QKmqcbKGTGw7G5AUG3m0rMKD 4UHtITsZWMV9PasZyfm3CqEIp1TDZw8+wXmDzLjW2dLjzhnuboIN6ocHZOAMuiBhGsod uJ3tkTareQg0ZMl+WxAGv0r7ZZFiF9w/zTgXx4E3M+VysuYd+LSfn5+/CHytppzJeVff E4uA== X-Forwarded-Encrypted: i=1; AJvYcCXyJPEnmB6d7KImLuQ3RofRYG2ZY6NtY/UssCTTi9S6J1v2XJTKFm883Rol98uTfRQaG8L6hjQzjP3Jxjoy@vger.kernel.org X-Gm-Message-State: AOJu0YzOTgVCM3EYX8G600MuPAkutCHXudMRMiUzfL1q8FRHKxtzNE2D g9Vrk70iSj8qDqLqJkyYhThdDs5X8qsLAMIHFvrSryIosEY5Ey9BW2oX6SyZVQ== X-Gm-Gg: ASbGncv922pvF3iKrr8cvE/QfKSgon3Cgh25sW1hkiv4hZHUhqTWwGHxhxm0XoMxqlz pEym7xoDMLe3y/DEr0TLNlLtQOJK4vQL3retj7y7n/RECi/qk+SRvQzxBJbgsV+fCrxfwO3x3yD MCsp8rqPACFSdBq1vizl/BtOMXjnycowMabe1Z4MkjaIJf+w2jVtQlKcb5q45EtEcNY6QxIzAQO OAVOS0fC6pSbQqcEOADfisFr+whhAIFvKC2Y1lome18dp3DhLyvfZsTeeWHQ2zhOqAKZoTfw8Ai LgDhrxLBqrxYMuxbn9CVDXJqEaFCxpUu2JNU X-Google-Smtp-Source: AGHT+IEPxC3OyMHAru8G3Gzds3v7OF/JkO9AvPzj8XxD1gntOl6n6mbYKW7VgLUWHJdUgNP6gB5oAA== X-Received: by 2002:a05:620a:4402:b0:7b6:d6dd:8826 with SMTP id af79cd13be357-7bcd97b8724mr2371667285a.55.1736589330581; Sat, 11 Jan 2025 01:55:30 -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 af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:29 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:17 +0000 Subject: [PATCH v6 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: <20250111-fix-cocci-v6-4-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@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 Sat Jan 11 09:55:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13935973 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (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 B8D4019309E for ; Sat, 11 Jan 2025 09:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589335; cv=none; b=Ev+XlbVS7Glb7Dk91n7pLr2qtgpxYcbGA2hZZetOK3JiVxhMIeSB9BUx5LKYwHtQGLWZL04cdueCDZOTbgzGvSwdiNIDfc+VSJhEYxciOKGWW+9F5KVbnPg46Z/23miAKWC5/GzYMyajAOCbBA/eIIGrcTofZQ06IOxA3nXsuPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589335; c=relaxed/simple; bh=jFMkE+aUW4A2Tjf06APpBG1sAvp2ejflRJ8B5s0jBLU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EvMylIobWCAbmJALgwYgx9hO65y7bFCdE8WSqM76rx6hs/wzGKEreoa2nLhjc9BkYVrMF7Yfgwxhc7RhCRCz6fzotun4c61ENoRsEb1JGwDaqWUsBCdzKjMb9ga28HAOUD4dqQwiJUSqHRE2ASgAkDAspbnURG99s5uW3Yp85zU= 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=mCcEB6AR; arc=none smtp.client-ip=209.85.222.174 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="mCcEB6AR" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7b6f8524f23so300720885a.2 for ; Sat, 11 Jan 2025 01:55:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589332; x=1737194132; 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=mCcEB6ARKeodZcnA1Gx8oNr0n9S6uBgT4tEHYUrfrd7tMsEO7wYPvOQ0fK/n63Csj+ RFrq4t1x2v/PutZLK5hQlHThygxjHiv4blcS/bs0Rr2U0DB1D/kMEVRFW2msX4wL84rH ClMYhX4zc2NlCWB+x+wv4fq4N23H693Egy3O4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589332; x=1737194132; 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=LmTTiZSUNNwV2DYLt8dSIpmf5ZCu9fbkc76renLrEYdkDfj7bz8aN7VMtDBUEQy+h6 6nGkz7PeCNiKsVNGBdmgVG8XCPOLYpC06fef2nQAxhN92r3sRVjOEr0mmtJbD2ZilfD1 4IZWjJf5k3iGbfs2k+DoZYehqC33BDdRpHssNatH+QaNz3FWDbxAwFK2qXCp/N/uYJr+ 1F5NBsibHT5c5pgQXnn0Q/4uJn3wzXNlEUq3twIUa61z87jAV++ScSZn9hJelSR0gw3T Nu5haLOHHiB0tKmv+ECN+px+fMyPF3frCOf2IiXxUoH6lQitXk2yrgw9EXIVddi0opcq vB3A== X-Forwarded-Encrypted: i=1; AJvYcCU+1PnUF1XtYQu0Tulv2OElsnZbf8DCZk7pYbSKBW3RdA78nubB4T1NbwQfijgP77m5mc5CcDHj33E/Kz6X@vger.kernel.org X-Gm-Message-State: AOJu0Ywtdj20cEbTVlG3mJK3hCdAnkCLgefj7znOshyAc+qHkw4vR3+C 8EvsEnAPxrkZoucY5uuoh3B2Pa31uuUIIAamUohr5Ma2JJbC9dwPwDk7B/g2qQ== X-Gm-Gg: ASbGnct0q20D/3kjeQ7nRGd7RELwrliUJNu3zJ1RNcKUCG6R7+rVmAwdSqJlXwzdDXI 47aNJ54qOqdJPHC9QaN1bDM37WmFT2qalwgXSxUzBYUZ0O0CyyczZW2IkXG6c9lMLazO61ysxu6 Kml0wA7pkvRfP1gl6pIPc4Vsp4XURCA1j5exfavk3/2zpCO1HR89pRv3b50njqCDDpiCDzQOaNq kZ9USNjNTZZUNLO7EzIrmGt2j8CIUpnyp81xKgzGUBJAPtiOIyGIwjXdudw7vLcVbFgqqVLcerz whobmDbNOQh6h2DG9WV+U0GttA8yv4/NjyJJ X-Google-Smtp-Source: AGHT+IHlflZapXB2U5EwdDsff9V9lka7ZWi7FvO7mOnx6N5gTF17d6mrdBuskWw0aArQ5dE890/KbQ== X-Received: by 2002:a05:620a:2481:b0:7b6:ece3:825d with SMTP id af79cd13be357-7bcd9726520mr1906864685a.12.1736589332721; Sat, 11 Jan 2025 01:55: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 af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:31 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:18 +0000 Subject: [PATCH v6 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: <20250111-fix-cocci-v6-5-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@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 Sat Jan 11 09:55:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13935974 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 686C818FDC8 for ; Sat, 11 Jan 2025 09:55:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589347; cv=none; b=RbyBug6KUWZ0e85pgtCAvm4uWjd5o7CtWdsh3iWJiSN47gHtMcWcezsA7puhftMUQea/j2URvy8E1n6Qa+FJaFqOM528e7f91ClsLhxEBkO6AiylAiAOmGl0XPXI+Ps3rdkZvLh4SW8i/Tq+t1tRy8Y4/ofOUIRBZb/GVyF0AlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589347; c=relaxed/simple; bh=hAlPOuL4YIiXg0HpbIYhah7+pVVbm4tj/0Q43k0VF20=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QEiTd0bVF/ilWEC+5ChYBiOEArUm01K/tmy0CzYJAEpIL2zgA2suq6n4LvCtbyNkW1n73QzSOZWVoDE/pJYUb6m7SWaAOxqAIjZoc/IrhjLXshppegcNKZBkt/fRw0dtB+ZoaAvJaFPguVoP3fOaiZV+67gDL/JcxGhoB9tDWZw= 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=iSdlN1C0; arc=none smtp.client-ip=209.85.222.182 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="iSdlN1C0" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b6f8524f23so300729685a.2 for ; Sat, 11 Jan 2025 01:55:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589345; x=1737194145; 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=iSdlN1C0rGRnzvzQnMULxgVbw+tZymFS0zBYfHuPP8TMxo83WqVvB4UixO+VAxvbz2 0ChEh5pE4hOziKajDXj05dtstSe723KgbQrUMfEnVjvEEJAgYOODrKkMgpR7sdZMmW2V pZvGnB+SfNoWgq09RbTmkiHx65BOzFdglgjlg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589345; x=1737194145; 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=aUD4XyKjzoy31zV1vphn0SwtyKKeXUk/iZpRtAis+oO/79/L3EKbJO+Cu9pCLg3Wpn 2bRw6fEXseiKNf+9P0lBCGWhthkFfHQ/mzRqCVlodCxlTrnMHGmAIbY3yjos4Czk18j3 5m1O1ogD1oQC0NH0/i0iV+6gVMV5VxcMNbxIvFb6RdclNPXzse7DQvDDtmmEpO8Lo3Q9 giBeDeYGpbZrD96bF19xkvyUC4zjGLXdLTx+Ual3jlBrpQ4jccjoXCeQAfvecPLuH4w+ rNRNb/F8+eRUlI/Iw2gM4DVdheftbgJgLefsVtfnfVrqnNSnpALBNcBmX80/0ektfOSA GAtw== X-Forwarded-Encrypted: i=1; AJvYcCWbcuAuAtr0aP/dF+VLAiOMXDxFFWYohu8pZ364yVIUIGwv9nDil4gTeC+yqf/I7jTHThB4OSIlqN9JxzX3@vger.kernel.org X-Gm-Message-State: AOJu0YzMhP4Sg0X48vLzS8egsvLPqCbCLJ+rKiIAub23qWoac510PQM3 4zzFOaMOCW00JqxEi8FbCzFzGmcde0vBAqWrz7SJFQvgr7csuuD6776lbvf/ebai+fOpKNF2bxb sMw== X-Gm-Gg: ASbGncuayDybgQ3KMAVuqRTVBQplfkG6cHcLskKxlQ9Ni6iVF4d4i4Z+zgcXn4KZBV8 dd+3QhvkccCTFXV2LppOZUmpXpuG0M/0PZ2C21mpla8n1UGJNtC1ijhUM4AQUKqIR1F48qzs7P/ TvGH337W/YRz4qcwylcem2Ty1ersA/XjrLJiB3tpuaBluU6Q9VKuITXyugc4aXLAO9hTFHgy9aE KLVGQcBR8ubrbK43MHnOCBoOrIYxT9M+s0hQ9o7WESciW0Lan+gLsw3lAfX7uDLCfFX/ckoe12s KzY1mVDiWT6Zv8JzWwc+T3nyIEWXMWspRo9t X-Google-Smtp-Source: AGHT+IFPc65u5Xb9RCjGLJ3Jl3Vf9y0Du5AsKFgmKuWXejd7Aufwu6k8jsIz9OTvYdbOGhoPzK7nZw== X-Received: by 2002:a05:620a:462c:b0:7b6:d0bd:c7e6 with SMTP id af79cd13be357-7bcd9759db8mr2313763885a.32.1736589334727; Sat, 11 Jan 2025 01:55:34 -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 af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:33 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:19 +0000 Subject: [PATCH v6 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: <20250111-fix-cocci-v6-6-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@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 Tested-by: Bryan O'Donoghue # qrb5615-rb5 Reviewed-by: Bryan O'Donoghue --- 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;