From patchwork Mon Jan 6 13:40:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13927445 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 C49501DE2B7 for ; Mon, 6 Jan 2025 13:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170812; cv=none; b=SMg1CyXD2iRR9zUeMF0oQ4fdp0iRw6FcX6d419wJHVftAsHTmmbLEaOBAIWQbjC7LYLtV0Z7iUqktivpdLAHgmegdQDzSOfi08CdwcRXwfrHUxhBLt6pTOT6phj8lsBO2gCNGyojWJ4r7dFN4jIsxzjJDb0ewFnw9vQRBL2rso8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170812; c=relaxed/simple; bh=/HaOC0UQuUCRG7UtKoSrqnIxQLLgF8uNCr3tEiNAggM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m36XGjRwQcnLW69cwHfWWgvo+lCRL0W0U4vZhS8RIvF82CV2be6YF/nwj1e10rf2rtQMNqwJyXKrDQdZNvjEgy+B74RdDS3sH6UZO2wCAbNelzt9ujthoQQpRmiOAPGbk8YFJBBQa9y7TOE8BeOgjFvubaPtruUlRK7bSIgwQyM= 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=Akfrpqpq; arc=none smtp.client-ip=209.85.160.178 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="Akfrpqpq" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-4679fc9b5f1so109082941cf.1 for ; Mon, 06 Jan 2025 05:40:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170810; x=1736775610; 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=AkfrpqpqFkO9oYZ8EYkAjIdvYTBAZS8RS6VjxAJV5+HAulLkuQM0eWq4+GwaEll40a AphnfeHRT52gMbNs2fGLn2YH2c+zJpGEiz7HEXDlBhKpfNPgFFn6KE9/Neyvyjj2GHry L3lLFHXzz/486wxAb9TzEqzQzovowwV9tsgtg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170810; x=1736775610; 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=H3cTkmLJk4lQEBaQqXI/9ZJoYKqOuAlVsz2v5f6v7QWf3kII0xieutAEO1hzPBI0+m Pv9e0TgOnw/nOYvjOCZU1FU4gb/lp0HJvy/l7TW14SoZY90PMo4DgcfExURzvRJCntTG ek2Z9KGIGFzWUfEZrt6T5NneP6CCH7F6Z/iE0MXNwoh4cPLVi+QWKtBHMR80uu4EFPWI inj3VuNl5k1H3YZcUB6VEF+wVGj6JmksJYCkh9q/hG0M1Pw4wbv4drrLCvhXDNmdJFHV JJPLBw9QvIkJKqPwfkfFX8jmDicaAMRaZbvx53TAiTm23HB5LwjWx74Qqdy5SB4x290V cJ8A== X-Forwarded-Encrypted: i=1; AJvYcCXBxDxfDlNAOk54b3pjgw6uv4isWwW8j5PXroc14ph8yIJs/wMMzbzMiCSPPshUFG28i7DuSjcdYQYA2AIX@vger.kernel.org X-Gm-Message-State: AOJu0Yy11D1DOO/Ho1+SMx/7/Ef8zMFagoFpnSKs5BwbhmcPGsFZLK8t 02VOxVzkY/nCcsk5IEv0y6nFJFZ5RjpUTKZAhTCt4dQljspWn6P6TFSVemLWKw== X-Gm-Gg: ASbGncsxML/ix+H0NXMt63GNvbRqz6oLSNYCLgVB5M0JKzLTXVrY9ecS2rQJrmJrhWA QgqTYX3b6b07cxZW5uzYC7ZFReATPbMhiD0nuMvdu7Y/oCcgbCfShjxMEUf717ihxPgKjXATgMW 75uqGQDbNZfP6RLdr0aH0Kymr00xkuY6rftCx7K5DyzQTP0mJaCzVNdx4PKRr8GxjUi5I5aneKG lRRsSvKlLoGSe+G5UYdXosokNBy7XiDKU/IA2S05Pfi7Eqy/j94HqX4IB2wws5VxlFlqWDtXNvw iJqTLqZG3HSGarHjn1K9n3dn1Y2VI/Kh++DF X-Google-Smtp-Source: AGHT+IEn5Ou8N6A5ZuxRVWPs80QvCQAMfXcoa0B7FLd71FuJaMTg55qppld2zbRIfvJF/yb+Z4SD8w== X-Received: by 2002:a05:622a:54e:b0:467:6941:4ecc with SMTP id d75a77b69052e-46a4a977daemr1272210731cf.39.1736170809768; Mon, 06 Jan 2025 05:40:09 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:09 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:07 +0000 Subject: [PATCH v4 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: <20250106-fix-cocci-v4-1-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , 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 --- 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 Mon Jan 6 13:40:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13927446 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 ADE9C1DE2DE for ; Mon, 6 Jan 2025 13:40:11 +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=1736170813; cv=none; b=G2mBAJRl5dOXxpWXSw2NUenYyyxx7vpL+ZxdGqaCdcu5Yp1CAeMUR/eJlCTZGgJPD1cQPi6v4Tae4npmhGoD6birdSrIdE2I+wHj132550LDg21hvvSg5qlWSL3TIwJd720/RoWfPODtCDBwiM+d/1WVQo5a9ABMIJnx7ae2hJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170813; c=relaxed/simple; bh=gyc7PHkVIuT7bzGNideviSZKpST9Tf7H8/ISjHyIIjY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T24RKNHWQvbkMvL714m/L0ymoPcW9nSU6yFYGnifBst5omr2Bssh5a1iJoUbaD5OpNLQwX0RvzqxTxDOOM4vYbY9H2RfzzNCMFafwHLNrlH37ISTg6fg4FsXdhs0VgasQvPVIEOPYCWbOq0XGOgHMOmyDpRuqxwqfVlx2v1TpqA= 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=NK/aRmgz; 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="NK/aRmgz" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b6f19a6c04so1229032685a.0 for ; Mon, 06 Jan 2025 05:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170810; x=1736775610; 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=xMOQdsC3jIKqQqpuSf98ArK9l8+i2xudhvOp7OPxjDw=; b=NK/aRmgz9LKIXUPVFMhy4wbRTxq1E/szT1BUS+4vaPjUKQHxIGmfMG204yuEF8nR60 2DTN020rRv1oUH9UU2NkN50uF8OzswPU35kGPe9JsG0jC/V0sNcyqkqqzikKWH22Z6ri GoW4F87p3YkOt6QfATh0uQ+pputPvZLNlKzXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170810; x=1736775610; 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=xMOQdsC3jIKqQqpuSf98ArK9l8+i2xudhvOp7OPxjDw=; b=wcv1yj8SD3Tt5nfXLdKYq4gOeVkA/Lso7xcmYyaqRY43zeF2Bfi0z6TTIaJntmYiSV cQAvdjyMlF6TKIDR5mHTjxnKS3eKrAigELDW6EvGkNIm0SbgHpmH4XqKTkq25ZqZaji9 5YdDBi19DX2WjcYNXnCxw87yqNh52tbEj/6uS9WmWT4OwlTHJSVl5Da6Dk2nHAg2NQEg KW2htNvA7EH+cS1d0pdTn3KU+KGzcVdqnQd7mmWZEXHIAggvEaiPFQwFzgQ6MT2+OpQj 9VTLofI3aDwzL/E0frd2jwg9TDJALKaD7iAxMBWVZil4a/WaJb5KQ9g2imqdQi8PvJh+ 8Ejw== X-Forwarded-Encrypted: i=1; AJvYcCUna0r66s/Wn/WaZX12Iplg+IfMWunh7pXmcEiLtniBbgGh444mnbg6qLRhvvvT8wsr6Z491rycC7exq0tM@vger.kernel.org X-Gm-Message-State: AOJu0YxD9ciUCLlE/B8kNFOR4KAUp29PViet29CBnytCwgElJwdGzyHu 9pI5GxyWk5o/WDgvv81XbIF0brp46SykgkPdJNGNSAglpEEXryA2MgpNXoO+5Q== X-Gm-Gg: ASbGncvBpkpfEoST0lDTfra9TS0nQ2n6K+qSatCMXddepi8JBTB+rOy3x2WVWtb45J8 B5RKVHcrKKKceqT7rLq34v/ecy1cx0ObPiHPnGPtvNqUJs9jphFQSmOmI4OyajTMOVkdu0Tihpn 51ygwViwYW+LisrQHfR9lJetG6NwbhfU/WgMqoJWxG1O+m9jF9dhfGV7bKj+0o6ee2UrxywP/ED UKvrXoGJmGXCATZXB2TB9RKxQ3XVYJAv97PzS5A+H+nKozIx6kUt2axJuN7fGt/8UDBc1HggIix Abbrpa8LAZYrj5Es4+KGYsv8cYxPJRUah+K1 X-Google-Smtp-Source: AGHT+IG0tS/HxvwhAy9Tnpx7Oq6KCN6+Gj7OoItlkC6sM95sCyRq2jDgb+/eacthbZcfoPddSstN/Q== X-Received: by 2002:a05:620a:2904:b0:7b6:d959:59e with SMTP id af79cd13be357-7b9ba715e92mr8941485485a.3.1736170810497; Mon, 06 Jan 2025 05:40:10 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:10 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:08 +0000 Subject: [PATCH v4 2/6] media: venus: vdec: Ignore parm smaller than 1fps Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250106-fix-cocci-v4-2-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , 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()) Return -EINVAL if the user provides a parm that will result in 0 whole 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 Reviewed-by: Bryan O'Donoghue --- drivers/media/platform/qcom/venus/vdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 98c22b9f9372..25edd77b9cf9 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -481,7 +481,7 @@ 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) + if (!us_per_frame || us_per_frame > USEC_PER_SEC) return -EINVAL; fps = (u64)USEC_PER_SEC; From patchwork Mon Jan 6 13:40:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13927447 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 407171DB34C for ; Mon, 6 Jan 2025 13:40:12 +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=1736170813; cv=none; b=PwVrowReuelxOfIGhcBYX4PqNGMuv+SV2Rq2PWYpwdoWsKQmW42Phq1v5djPZvu9kJmnGag/4BIGkWGGba8I3WCKx+dHgxHv9LL9tIU6J+Ie8MjDkuQh3cg1djitrIRrkIts3AMS8WK4fZ+7BkLc7NWBOS02ObNsQKhXRASX5t8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170813; c=relaxed/simple; bh=6S98sC9zb379SpXjPj44qvbnzAChVkkYXuoHqOebMyY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ADE5274KTueHQ/bG7Z0KkFzzEgHFWNOazIjuzdWOr4z6jGuDq/VTximvkNdFPiRnsaUbtqh858iDbkR5dKuKm33acVZHlIBCkiLi8WfDj93plxd2l1E3vUXyMEzeQrREd1AicjusUYKdksLlJypt6Y1aCkfBqwH++L9lhh83/W0= 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=kncgcZxE; 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="kncgcZxE" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7b7041273ddso1006625385a.3 for ; Mon, 06 Jan 2025 05:40:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170811; x=1736775611; 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=1sua/H7q/HxBmtn5ehYvB6xIDSURBEgE+eseMuH9rt0=; b=kncgcZxE+nBN/bBF+yiZX3cdt+EhOgfulXyNO8OT6URRm2wHJFX5LnH/1LaVH81cxH wKO54jBDLv3VQ1vjsWJIb4f5SUHhVrmGISlKnT3S7TzbLB5FN8ocZkkLe5lHXmL1AGaC kCTFK4/URJCBqLYNKduqa16gpwyYMMUVyWyKs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170811; x=1736775611; 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=1sua/H7q/HxBmtn5ehYvB6xIDSURBEgE+eseMuH9rt0=; b=hucfpk6LGq2VpcxObJ9pn7hXOhf14hqn1JZThoXPpgCvkrLSGRuioPpoheBvehsqLQ U1CDSaEio9QAYl8xjsxHXbS17uYyXEAZHAvCTQjZBETz4bkMnFklnV9ztPv/zAnWxqLx SInYlPF0nEE87Egkdxx6Lzb+319Deh1yCJJ9KhWNAC1XnX87OXRmSuYn1vIqmedcddDm wT2H0W5QmjQkZg09Kr4i5E82QyyuSKeG+BSlvr12brUOAHiztZyoTCWLQQ0T7Zr/1JE8 qTAkWJLvXrCetJ7T9Jq10xAzjY7aX6oQMdmgu1Po4ZkDtY7AY4RXPAzx4jvuCVx3HsGW Cneg== X-Forwarded-Encrypted: i=1; AJvYcCV79chpjgfQp0lOkM/5NRJfYHa7mhkCn0UgsKuY5naRwryWUNcPIAPDAJULDsOUbYd3zdrim9LLTd+HPo/w@vger.kernel.org X-Gm-Message-State: AOJu0YyMIeB/HQ2wgXgdk8GctE3M6TfgZlutyzJk9We933of4AmapLEK 86EWKts30GQ2CHGsyexxJpdtFBgqeL9WEYMRn5uTPI3FXHNhcFE5MO0m+RrUVA== X-Gm-Gg: ASbGncut4EwDUP+KDI4KLaWNEEpcqvNPA4IerhvEe98IPewY9ERWpgmNbZgPA+FAz1e +exN4/9SOHtjK75iCOJI//KgkB77CCVCDRZK/h+J41RzG/gfFjqQhJ+46E31we0qHqQwhB8VZAe OFIttVGl2MplrcEBwsQnbzkEm9pRxs7Pa8X2EFbhfQFxcAKaVfiMFSwUmzlOuttTxKhyb846gzR hhbyKkFhJviE025NvKdyyDR//GGEb/mDmfI09z+W1+Rm3dcI1NlBDKEiAf4ry+RIHPh29YLeSbD vQw1Sb2+lY8eLXgqUnY62S8ZxiNP8TmtV973 X-Google-Smtp-Source: AGHT+IHL/i9PYol7/BeTRyIFkBBCg5WCtmISC7fUpGW6mAhMPY0gQu9kkKdiaUQVy0qOM3paHIXmwA== X-Received: by 2002:a05:620a:4410:b0:7b6:ea22:3069 with SMTP id af79cd13be357-7b9ba79c26fmr8894375485a.26.1736170811310; Mon, 06 Jan 2025 05:40:11 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:10 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:09 +0000 Subject: [PATCH v4 3/6] media: venus: venc: Ignore parm smaller than 1fps Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250106-fix-cocci-v4-3-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , 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()). Return -EINVAL if the user provides a parm that will result in 0 whole 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 Reviewed-by: Bryan O'Donoghue --- drivers/media/platform/qcom/venus/venc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index c1c543535aaf..bd967d60c883 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -411,7 +411,7 @@ 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) + if (!us_per_frame || us_per_frame > USEC_PER_SEC) return -EINVAL; fps = (u64)USEC_PER_SEC; From patchwork Mon Jan 6 13:40:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13927448 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (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 B62EB1DE4ED for ; Mon, 6 Jan 2025 13:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170815; cv=none; b=Ji4VDFV1kuNUxVxojV5egzp/AxF5Dicv0q9ggG3n+SShyKU7nSROp/lII0iPAeLL37RqTKHiKsclvrmnIWnSehsSlALP0NaKEXZkR++6LTQNqgdRpjX9+PoA0ZllLPu3jzFKVKdnrPTGTdSz5HeVFUrWhHXOCHAR22TVKppqy2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170815; c=relaxed/simple; bh=5Q5B+vO8g/U6CHt36fHOQ4ZUPAjwu5u+O8RVnGjaQOU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U7sl7D6Cxr9BfbbYajsUJGoetw77ZzJI0pFKP8jeRCBulktbhohnIx7uXFEUDhRiNbVrRzX8rvOKbDI4eVuiuuAbCho3ToarcjSQKtJy2Rj2YohJubaw7VYAPYP56dXOb08ALi1ZVSZBgz8AJYw1xg8ChRtCHWgD4XixNQs9uec= 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=mN0cEaP6; arc=none smtp.client-ip=209.85.222.176 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="mN0cEaP6" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7b6f8524f23so1574972285a.2 for ; Mon, 06 Jan 2025 05:40:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170813; x=1736775613; 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=dtAqvkDjh2PaFdbysTqXE6H6Y5IVHgLV/gXYs6imBU0=; b=mN0cEaP6+zqFP3CRdYSnZ20pm0BZGOTdsrwZhW/nXoWFBxwmbnxCilPsHodXzrauar txXVO+SoTpGWiv6USoURd6crXGqArI/7m+8y3C45AmbUh36TZ9+7SlzmN4vfsQ3zVgVP eg+W2bU0xLG7DEeVqE5+MBUkOPrDHpCZSt0Es= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170813; x=1736775613; 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=dtAqvkDjh2PaFdbysTqXE6H6Y5IVHgLV/gXYs6imBU0=; b=PiN/Uw5Bd+V1XXw6oOTBpBSIjF0R4YNQgndZuvMWIQIRUX1GuFspgzRuF4ZS8K9p7e bgXAX7+B6xLMBFh9ekdPjNwFIRrfYbEdPW2icV58UOzbB6xMWUYZhhBznCzAE+3EEkJm VPEwRAhxukMDnlZHvkx+U1q/7kGa+33QZMuLE+hRgsz+vkuF1Nitq2J2B7D6EIjW73NK jxG9kvgobJIra+U4l86xNnFkHJnDH8N59u6rEHNIQ1x0Q7mgouoGh9Ea8oPR3+QXaLZ/ bunukCAyeyZY1mkHzr6dwgEMwtjl87/E30ewxBS3bc/qjD41qYYSEyDpG8XnHqStu/xM HhrQ== X-Forwarded-Encrypted: i=1; AJvYcCU4A6BQZjZgaAfevi6GAzG8H/xcfD5TuT+08e9UpavIemCBCnTK17W4gixJjvWPMi++bK0AHpk2n46ebkqd@vger.kernel.org X-Gm-Message-State: AOJu0YyMY3CIMVd1MHD5HsCpcnTXMON7gpaxqDP/MeG0o53TTKkdzMdU OejcLj+GedVor0/5I2M5qjsJlTv/vw0/GqC2DS5WwtvDqTQjoCIZtpDNbK5K/g== X-Gm-Gg: ASbGncsy6FG3mriPCIVcj39LjXYRjGQ2CDewkk2EuSyViWij0o2wrs91T22jRD7eTRB 0SD+90DXHTPeUnKiMAsHlU/BH7VbD/dkECk5D9kVFWgRBD5FhU+4dmIBrq5feiM5NifFq6a9TPQ UDlbMarD1k8JF26SLwzeOFEEenDXh14rg27bvMTt6D7qtts9VAbRQFV/NX8mA83yJ2shYBaDhLJ ejzp+MTBmbWG3lgPO9yJ2BHWO25eOXwOGfWos+sqVDTntdmB5m1vcsHSmB5/W8Jdi0S5sCEOcW4 o4Ca6I44NcrR8yHFVwMC1QmrSNFaQytS5efq X-Google-Smtp-Source: AGHT+IHty6kiPE899b/JSwzYcAr9Qll9mS0qFE11JSQ7TgmlLBCHUvVXP+LphtWR0tpu29q+SbqO4g== X-Received: by 2002:a05:620a:470a:b0:7b6:ece3:825d with SMTP id af79cd13be357-7b9ba716a6emr9941850385a.12.1736170812604; Mon, 06 Jan 2025 05:40:12 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:12 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:10 +0000 Subject: [PATCH v4 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: <20250106-fix-cocci-v4-4-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , 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 | 17 +++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 44f1c3bc4186..988198280687 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -405,7 +405,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 @@ -476,7 +475,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 25edd77b9cf9..6b8906ced6bc 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; @@ -488,7 +490,8 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) do_div(fps, us_per_frame); inst->fps = fps; - inst->timeperframe = *timeperframe; + timeperframe->numerator = 1; + timeperframe->denominator = inst->fps; return 0; } @@ -1613,8 +1616,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 bd967d60c883..8355bd59a5c2 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; @@ -417,8 +417,10 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) fps = (u64)USEC_PER_SEC; do_div(fps, us_per_frame); - inst->timeperframe = *timeperframe; inst->fps = fps; + timeperframe->numerator = 1; + timeperframe->denominator = inst->fps; + return 0; } @@ -432,7 +434,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; } @@ -1455,8 +1458,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 Mon Jan 6 13:40:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13927450 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 4088D1DE8B2 for ; Mon, 6 Jan 2025 13:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170818; cv=none; b=NSLbmjIvFyytkHyRymM0sSM08Ka6AhZCwyUtm/LKqCT3Y5X3SGyqMWc7aC1ewJUpP80rYVZ6HEPqfw+b95c/Ejw+gtUhgv5PsjLr1bb1AMjmT3IlgNwwGqOzzZ9Haj6Ald72J7KlhQenAWwTcPsnfs7PZDsTXRV67/evDsfpAcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170818; c=relaxed/simple; bh=MKfqw2WVGARyLQAOD8Mt7Dqo3jHse4EHvr4z1KQ2TkE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cHgmQA2G04Shhiv3Mi9nXLt+ZKenAFGbIIcwWXxDuw8k3tmUqAZODmdoxPW/hg5FJsf+m7RHWrf7LINEnPjqncfQFIJgCatHH5XZljJz3TMB+9AhjdUYkES4B17q92FzQfGARw696CQ54XChJcViDf4OPP4c61KqJonZsL7dg1w= 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=UJXIyOZD; arc=none smtp.client-ip=209.85.222.171 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="UJXIyOZD" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7b6e4d38185so1159979285a.0 for ; Mon, 06 Jan 2025 05:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170813; x=1736775613; 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=Fr8YCqaCWwp/Be9W9ht5j9c8BF4MD3nNLHYL3KKI1+A=; b=UJXIyOZDLCqwwJcc9P3iK34i7mE2hQ8APvMppE4KuCMjHuxhaRwK6GuRp4+bDGKjJZ ZOhop9yxWZC5GTrcgVozLT41m3saXmDGHZhk7ndGgvVd6dVWLHZyl5Jlw/liCnUD7raZ i4B9g/Gp7Hwlu7ybTTcNiFmJaSNEL2D+BtBiI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170813; x=1736775613; 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=Fr8YCqaCWwp/Be9W9ht5j9c8BF4MD3nNLHYL3KKI1+A=; b=K/1Cx/RLeEvkR5T27zOe/chcEiPabj/o54PaexhWJ6JdXjEDX6qo3dP1IhwFgXe2yW C0C9r6n9xQwPwmH2JxpOkEBWx7D9NNpQb1TUxCzaH2wsksw64y3ydTF7YR/1eIBxwLnn NucIonHFISsisI5NVMotPoSRP7TtKf1Oz8hS2EHQeact3Al+CisOlnH14f4j42Fr2V1f nJrVFis1Jg+H+vlSBxt7BXBpQPhim/MxekABW3p64vcXZi7K9yCM1GHVLkG/krqKDLlQ P2yR1USuStL1fFKCU/nOAlYVSpF7StanbgXqcgGrsP209RS0zdgO8OM1puAiNHOdMz4I CXDg== X-Forwarded-Encrypted: i=1; AJvYcCXJ32pbt+Q3ioSAzeHkO+XXNri+/n/81Tp0BNRr6FnbKZ9LMxHGiPAFE5X8PaxGiSdOD+kHy3Ri+sn3lGJR@vger.kernel.org X-Gm-Message-State: AOJu0YzfrD7UNAisPiF4TZgTOu0reDUbSexoB6qHQR7pa4d0Pgw/scTf 8C6vNfx6Ti/lEZH/XYamT0zTW0e3wNrXOvlQfrEvaYsgBCBTeRur42T0O90YBg== X-Gm-Gg: ASbGncvu3FZcAI3ifxJ0wG4NIoolkwvcyygJ3iobyaxI+6np+i3OV0FJqBBovRlvJHV nKOoUgWxT5du4YeVAvEehAP2DftFf8gx3lP6k9S7CcF8tK+quj0SHLLE3WZH4EoKTWg7L/z36d2 3FwDMPZ10xRAQUG+58yo7lRZb6YvACdP4SkciWopWiOTE73ahcCXmcjLI4hx6ctrMaNYcDvYx2M pGKYPw7rxP2Zic8MKZedYpRX2RWsJNJicC1Gvy98aJFE99D6qUUZbLDAlPCi4Kd/luThNExj73s BALE/f9u2pmx2nZwBpscIoAA4qnFJGHLO1jG X-Google-Smtp-Source: AGHT+IHcjB/Pb8QD204DXadECgJD3hF6JOTt0Wc101hAlBe7SX6FDrf39ifHgQZXoKerdzwzAWLNnA== X-Received: by 2002:a05:620a:2805:b0:7b6:ed18:fe2 with SMTP id af79cd13be357-7b9ba79c187mr11546099885a.30.1736170813425; Mon, 06 Jan 2025 05:40:13 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:13 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:11 +0000 Subject: [PATCH v4 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: <20250106-fix-cocci-v4-5-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , 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 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 8355bd59a5c2..5683a04bdc14 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -393,7 +393,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) struct venus_inst *inst = to_inst(file); struct v4l2_outputparm *out = &a->parm.output; struct v4l2_fract *timeperframe = &out->timeperframe; - u64 us_per_frame, fps; + u64 us_per_frame; if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) @@ -414,14 +414,10 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) if (!us_per_frame || us_per_frame > USEC_PER_SEC) return -EINVAL; - fps = (u64)USEC_PER_SEC; - do_div(fps, us_per_frame); - - inst->fps = fps; + inst->fps = USEC_PER_SEC / (u32)us_per_frame; timeperframe->numerator = 1; timeperframe->denominator = inst->fps; - return 0; } From patchwork Mon Jan 6 13:40:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13927449 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 411951DE8B6 for ; Mon, 6 Jan 2025 13:40:15 +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=1736170817; cv=none; b=icBypPM91n45jeyNDNwKJQ42+i+g9k81av3g8khPpbyMXxOeXvxmnXt+FWxeH/5BXoVoGM6yZLviNYgcyL8xlW89YdHW6tvy/Z4p6m/Ay6hx4GIvWTRwXEsJ/Y6akZi6KzGRrboeOhGFeoZYFZuiqJ2bJp6AldZsAz3trfB8wEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170817; c=relaxed/simple; bh=/hPtkiqbMiSuYUABeLf0k0X64qWSBh2CcTj5F3/fdPI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f4ElprfIg6/WVvqwnToPhhq+TMgUR+jlNJFnRtQwdrv4bKnErWDdRZLjlR25Blf46uMj5XRSmRLTxJEfTjZU2w1Me/GXMEXwdMs51/gxyB87P+LdiH/Sz3fIiA9mSkfaiQN8gMWM6RJWPdv+8twPdsxoTDY2oHAd1TzrOUAzdJA= 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=PAQxFpv9; 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="PAQxFpv9" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7b9c6c2c44eso918866285a.1 for ; Mon, 06 Jan 2025 05:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170814; x=1736775614; 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=OaluQD75i5WN0/M2E9V2xLSR9NLQRzro4V8nhNRsJEo=; b=PAQxFpv9MIGmrwTaRjVIdwABBj58hHScDnH38p+lDl4EVwNoyIoOrdWTWfvpi9x04D KhQCidNj7qaHL0gfXVUUQVleuywVolb9Jmbh4hgjbCrpwoXxgL28jr5b9EZpNulVa8Gy k2pNZmcNOjW1GJMxV+SE/kKt69WQ/iI8ChNFM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170814; x=1736775614; 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=OaluQD75i5WN0/M2E9V2xLSR9NLQRzro4V8nhNRsJEo=; b=RMvmzXgxc7ms0nxDkwMZhXkxhXQqDiVC2ne65oN8XHN20wcD9K1P3toqqefKvEormX 5WSGrK9OjtM29bIPUyN1kyG3QcBr5/qkI/ch2+SCmcjniZcvBE2GzCIHemL5GNrn5T69 wMexL9wXuwsng38mnjDsRU4GBnDJVG6tbiKoAYQrx6XJMJM+JJf1ngUvXPU34ZQdkREx +bUQLTJjALlx99omngydFMR3nBDyJxr3PQGOiDlMKy5DFK0Z18Fj0AWzTVk9T+oBCcJI EO+qeoViIWRemyngWva8IqI9ue9kiv66cJyu2J38TjcnpAXLjoG831zMn13LnDj7euc2 y8AQ== X-Forwarded-Encrypted: i=1; AJvYcCX73Mg6mUxQT3X6zbtHjcpDGQE7PWWICBB9MfW2cfY8iYGQ3k0NwKqNPcPZJ9nYFi3Px+v/rrlrV3wKl8x5@vger.kernel.org X-Gm-Message-State: AOJu0YyLlaYiOwtAM1PV5XHmdkz6kAE8/ILByJJC2UVvzI2FoaZ5Pe7I v+LFLKo8UKSeGW1Ku2VJvm5+82c0lwFcxr0hT/lDZGsTV2Au45vwL0mbNBHFNw== X-Gm-Gg: ASbGncvUFF65huU3HHEcI5MM3nE0ELyfnLuVvrWZyjpBtEnsW1CDMlh43yVgRVOItR9 ZE/Q4DRTPRswa+2J3AO1r40ALE0L9KsdoKrQ5mbuN3calYsYFb3YsP9KNpFBgCwSmibvxkd40/t 78DYcG+DonTA+rLp/7rAS0KplBJzvcfPyWG5JhaNEAe4v3ikzJtCGYXbUSk9nhRLOHggUnXgDPK UR+vgH7lI4MallRpdgdgOY3nHg1XzNYIpBGItQEQzFYXfWSzokes4sS+MZiefgXOYNcHbXKt19X 1aqzMYBNvzyfVZinlYYBkzKWnSt47dnOoyHl X-Google-Smtp-Source: AGHT+IHv1oIpl6WcfgN36jKDKAWdHfzzIkAbnj9H7EHr8HHbAWlAP6Mwo+/BVH3tIZ5MTc2nhgENBw== X-Received: by 2002:a05:620a:468f:b0:7b6:d050:720f with SMTP id af79cd13be357-7b9ba79ae8bmr10079146685a.22.1736170814275; Mon, 06 Jan 2025 05:40:14 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:13 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:12 +0000 Subject: [PATCH v4 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: <20250106-fix-cocci-v4-6-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , 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 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 6b8906ced6bc..88f6b5a3a4fe 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -464,7 +464,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) struct venus_inst *inst = to_inst(file); struct v4l2_captureparm *cap = &a->parm.capture; struct v4l2_fract *timeperframe = &cap->timeperframe; - u64 us_per_frame, fps; + u64 us_per_frame; if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) @@ -486,10 +486,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) if (!us_per_frame || us_per_frame > USEC_PER_SEC) return -EINVAL; - fps = (u64)USEC_PER_SEC; - do_div(fps, us_per_frame); - - inst->fps = fps; + inst->fps = USEC_PER_SEC / (u32)us_per_frame; timeperframe->numerator = 1; timeperframe->denominator = inst->fps;