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: 855355 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.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 C3DD41DE2AE for ; Mon, 6 Jan 2025 13:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170812; cv=none; b=GbasBByX3pr/Vcl2g9isPjDg6QtAZiqW2wxSZZGtCPqC2koZ9LvuFfmCfRR9BSmm187MP9N/jMKHAAOwuIh/F64AP4Uh3YgvtjznvEoLFPXaY8saWDqq84cwqz+hWIcH3IwtaIoxCnx3KjahmDtZAKGhR4NcDK/F72UQ9fq5CTc= 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.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="Akfrpqpq" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-46792996074so141381181cf.0 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=csC5kZJebL7rQLX/y6KFc/RRe+wMlsNjyTPAlaCcPihYJm6H2o8ggBYbkH2kSiDJJl JqfCsGbb4YksqfM7H4ahW2vwGbZMCuRlprMJMMw6IVuwowxGntqRWRy9puwG3Tmda0pn NVfKivDyb1QC/42zx9v1P63hGX7SnMn0Hn2zIthJLzjssA57EF1b8gWsUbH0TxslYTlF zNElWJGwRrI8bpYt7e9x7Xyq9QgleMUITZ54fhDzXyF8nO9Ie3pYTjnpdhyXJejlwJET DzBQs8Id19NnjKCzqiYYDp0SUsPm4/1qTFpmdNH+A06XVw6Iwvt6VjU/wVoT1zELt6eY IwJg== X-Gm-Message-State: AOJu0Yz1yWPCIywnJJTWHchYO1TdDG3KhlDHgGR9efiNWUMaWb20ohVw JyYqU0eVRaV+Kr+9nqsPHX4Z3slhDNuF5km5/Z/23eIg3jIUvRAAGS95qxomMQ== X-Gm-Gg: ASbGncs/2jAkFMfjCb9BsR0vx+WnhV7+cWfuPYLBf/dkn7ACAJHL9pgxoj68p+UAYUe XEPaooxxv51S7bcUApCiXctaW42ZqY2q5DsIs05E9vBzO/j1LOmU1DWOUnuWh+61VA+OqCgAK/p 1wIQM5JV+P0I1k0MoWCdq71KlZW1eJcyB34pJQ4JWK5o2QlcT7cRFIZGFLf7Tm4jUCwuKqVYzhs Ex8JxnOD6xHnJCnoH0iNF4+48tBTuAVSkIA1lsU/VoQROg+jP052Jg6SZB8n7Hq+VjeoA65j/dc +ZBMSbgL91EPtKviY4UCgN5Fvef2RW+xrAsD 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-media@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: 855354 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 B2C371DE3A5 for ; Mon, 6 Jan 2025 13:40:11 +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=1736170813; cv=none; b=plIHFTE+ImGQ2qSG9Ofn9L4bfD8bPTt9qPpwW4szCmfqqi1kq7GzB1mZUY/QEhWH/WdMiJ/wOONpY3f5aoDeSGy4VuKY6CUfNdp38DzfHOmg2dhqL8esCo4iw4RlwC6bdUb3SrbiqYsmrPO+RftgX5lzU5YDBXmJTL1w/lHd0YA= 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.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="NK/aRmgz" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7b6e8fe401eso1201362885a.2 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=GWtzstneSJ0vUlJ4yrYRCCoy0s+qjRhBJmumc88FhTR15SOa54Dl0myD9hIBTOvM5p 3Bw5bDMf/BddgftwbDSMfuWc7kZA35B0G0zor3mtZosIbhxX38x+R6ez/i4M1uU/P/wz mQa0jWH6JsP/OFbQI4pS8smaZc/9dhPSOUKNrm4tsb9Xn/Tr6XfnI/1PemJFu2SmRIv8 eb08ESB4z7p2n/SaUIFygHF2bk1RV1W86wpaCsdlcwnzfJrIb9SicBnOmOQARvRvVgt3 hLhf0X1GuT4wS4s3m1jcX16T7DQQKQbV27VCkkksFngne7AGu1uJcj6djtAoN2TGqaDU ZLcw== X-Gm-Message-State: AOJu0YyjIJUz4yKmPHrDNqGcRarGFCJKSv42DwBrmr98gEY0UlHyH3N3 Hd/gDdoZlfxSJscHxLVwDTiQHWW6JiTC8qqU+W3uvQfFZ66AFLRoOUGJKYBt/A== X-Gm-Gg: ASbGncvBCdJlH9ldAMzStuYfU+6N7yah6MqWj2uMmCAdDLUFI1gvDO0MhCFwPRHrQON U5b8AZzYck3A51bSqRT6HTuraqO4L/iz4/7UCt/5Ut9TvkplB38ATWjYvXqJ9XjSR+9ciETEyih 3INgKTtqCL1fylZErWIq8n7gN9aYEr9MeaYr0GJQLBxI7W7HD3aMXVNASP4tYvVZb0lLNmYfEdh tzuiwnIZAk/7qTY1C1Hc+489hwHGA/tTfJYyH7EbhlChp49puFwGVbSKwTWMFE3NuGHjym37b4/ 3emVi5ObeOe8U6FKtCUbPbpWowjCqzTdlr1p 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-media@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: 855602 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 4B4331DE3C1 for ; Mon, 6 Jan 2025 13:40:12 +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=1736170813; cv=none; b=krkeOS1tTX/P3gWa4YmPGYiPXvehP3nq5ZmXsWZlR+CS1qIF66wk4cN/06LoqvmaDxPa1aKE8Ud5gceVL3d5d2QiA5zniU0605prCS1bLyNZ8bh5XG19aYnwEQPXAxfqAkUHr2h/YeqkFnLR8ZOBAsEQnHQYw+xg7lShzo2/aFg= 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.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="kncgcZxE" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7b6eeff1fdfso1086874085a.2 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=q0PVVIccxjUUbSA6rQfj8vG30bjo8o8THiHK8HNL96u05MCXRosllCoKetCRfNmDeG OfTSgv+me0qttgfjoBostC5n06WfGJVev0PagqOD34f6MnGkeTMsbJeSJHx9+FH+Pt/Z CoIvtKgGUIhGHQt5iIAgXjCxb9f1tZJpePfEYBQoJOrZpdti3ib2LQ4HVc58nPTjlGL9 1neKN/0b7rWbV35xzrGMs8kCVFJ7AMotBkeQqbjdjXIJRfZUXQVMT8+nXZYsZRrQoU7Z pK8dYIZAIAkD+xJAlY+B+ejlKNHoLyrRo7YujzcBIRWWZSjXAbhbbdtY+Lz4ivLz86Ba J68A== X-Gm-Message-State: AOJu0Yz2dWwykNgZqekHCOo70Wbd9Z77hhpf5QgnbmieY2m0qPpR8yeu +W/ffyVa3lT1bzsUhQ0zMvK2/QF6vGzFi1x9HownoVnyKjweivyK7ca981SGdQ== X-Gm-Gg: ASbGncuPl6j7//3PIynuC8IasGeFRBiwKIGMKD6Bjw9I0x6eiYilJlVBK8RbX5OcfWo GIvCrSWcDyA/CdMvvzGsuLtoMaEeidJkCCQ5RMfvruOfDiLAOMHHs17yMV3s/Ny0/R5rWpMf9Ys v71FHBaXXUzObDDgNTbHXYneQIoXOZkVDnYbgG6V1BFmX4UvWnjs39wOKz+jSzL1Wm4MqwaX8UV ppGeEwl1lRk7AAoaWPGykBdo8B/7ChbAkE0dj60J5DY1NVgpoxlmHWW1L1ofaAIIo9t8BvGb8KG 02PpALelxNb6AJtptiUol+NIiTYdVNMtwLvo 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-media@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 --- 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: 855353 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 B62561DDA2D 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-7b85d5cc39eso1544492085a.3 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=Y6eujJHqjgEL+B3f/mNG5D4UevREJQUXEr8ZSjIc3pslO+IJVUfViYGjPzYnErpTAw VdjCb0wxdf8raBXEnAGQZDUR4e/2gUye17b/m5Z3uQkxavuGqrvFVRxplcn4Zi+vuOt/ UyM3CYVrzEqU1NBCEvBKlA1CD8ZHTBQL5Iqy0mXETS4THd++RHzOcA/sKa+Cay/pUoRF d7biNBWtGaZcELbZg/N71lFszjbAUdgufTsWPnB6evgl7IV3rnXF4K3u3BXYoGYmKivs dU0S9ag/p6k8Vb/kdUurFFVfaeABRQvCW9/tavq3qPGQ8/rDIoEQGqBt2HjfDwF41KiK bHFQ== X-Gm-Message-State: AOJu0YxAgZYGtffAb16gKcCIhtsyyH5LkVFaU8DfOLxzFyg85Diz6S7y GH+IjAFoWEA99oEK+w3l+aI2MrTP8zyVXFjiPDh+a+9urpU50GJdZjtLRlQqvQ== X-Gm-Gg: ASbGncuEy4mz6sNNNMwZ++8BLmWUj+dpFCkxX4hjQwZzbWDKpzodIFhfQ3FwYFE8fMT tAIqHas3VmSr0McLApSBdA7DEDjHqvN6uDUOdQEmUyao2f6mkg6pC4wZ5+7Fs+W9ZHP7221Uky7 bHuNlnLlIjlVup6vMB6j6zWS8r8mm9k9HBaYwFOCW3+q5RX66aj7HYBQbCOYAJVuwQ2nk+b0FKU eo0dGnPFojOSrZ2dPduW29ZkOEfGBDH2yCdEDyUE01MljmOHrGFmyrcyhMAoNY7I1Z35Ou/ItF7 trm/jQz2Oe123FpgRBkVusnYtLcoxy+HlbJu 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-media@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: 855601 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 36A9D1DE8B4 for ; Mon, 6 Jan 2025 13:40:14 +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=1736170817; cv=none; b=Qq0bgLtyKpExm7vZJC0ZdBtDSSngCN9bwsIJfMHMj8zNNgUNBtDhHK7c+uwx8RmTeIDkLlFNtLHvmIQ/B2W5NQVYEfq5JkQrkwSlCcKW6RfDR+C3HUgcWm76y+15VOs+6Y94t6Ci6B3NYcsUydSxw9LiQAFU2uwdJswZVzjdIOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170817; c=relaxed/simple; bh=MKfqw2WVGARyLQAOD8Mt7Dqo3jHse4EHvr4z1KQ2TkE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e9Gjgp2LWR87Nka2SnxiAEn+G73Zk0aXxBtT4zE6++b8vR1Fd/25uuAMFLmCQWQR3dO/+tPlCi9Lcqllq4wnagvLR9IwA1OLlm6TsqjFkVHVyNR5R3iIe14og5sjPyKxR3cyua6/DqCRruH0QuT1Njr3SnB7ea0doGujgH25+KE= 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.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="UJXIyOZD" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b6f95d2eafso1403643785a.3 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=NStP7tt5wMYIog5vq2Bo5HX/7xB3fzS2a4i0laTJCPbGTkC4bWesrVP1bQvFiRyPTu g0K0AQntIp6z7V1MutQHEy/zHusMSWJnMiBreyHE43I9zMdtlfy12oKTacjxKBv4NKMs chXJoUhxfhXoKqgNyd+Uykhsf5Nq9RbJeFv4pR+D2cIe95w9p4vFKgvppiIqzxmUeUoE 5pzAgeocLTJzNPR4bi09zsHpJo50u+CtPHC3VAh1bg+XgkHN++vNZpm6pO8l+K5Bjc1C wvX3tzmcButxbEVdVIPZQFbthufjIdrCRuJRcEIi+xej0+R0wzp6eYASTVTiINlGKOmw Cxkg== X-Gm-Message-State: AOJu0YyLFeUze6WPE7B34A4KAAE7/jatK9DE4uXR79PhlvdOakimpFgE +Tslezf0ylwFOWDXarjVGsvPDCtjs4XG3tWE+u2Fbq9UGLMldul9uI5etLeStw== X-Gm-Gg: ASbGncsLV0uJaqfe+Y13HndiegANrCI6J9P0LUG6MdZkcSWjoJS8xyiYfHjai8dG1if 8ntpn+vI3J4zLt3r4CE3lfH3BaHizhjDWB+YDgf4cXcDrqWhIsXjhEoWCLzXfS4gajF3x8qwuJB 3DyNDU19NjxFqLWABZkBvmdiNEGGIqXrdkhfBsmcFx00Mp+Btdfdvokij4zdtmozixMVkKIlU1S U4oEXFhMAnaV4Ln+MmL6txgfHUE8xAsEwqy+oqPDbwWVz1+QSIBs54Vx94S3k41bmu+Xd3b37s5 Uqq7VVkHFIuNMRw3JCibFVacZ/JUA4VBTIS/ 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-media@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: 855352 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 36A471DE8B3 for ; Mon, 6 Jan 2025 13:40:15 +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=1736170818; cv=none; b=lEnR6E7BDufXgV3+AB3N5I5P6Q4nhXEvxZD60jXhUlEdBoMPa2ysCGkvql5LTX4EjnquadGBt1MGnnruaFx2knEnAZmDL0QNpQCv4fTeq6+H2EI9mHankP2wKFJC/QHgQLiduXw9LOyd1YyASY0ImkxFTYxGlvGxoM9r2evaN8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170818; c=relaxed/simple; bh=/hPtkiqbMiSuYUABeLf0k0X64qWSBh2CcTj5F3/fdPI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YiLv7bMOsSARwPxuIHrYEOp0haWr0Eg7A7dosjWRGWWMSN4XhFb9ASJa2quugCIVWqysgVnezV6DORMx24GGBSgzmAL83SW6PbD69/fSXIT3YujwFZnoBdIIYw2Jab3s/Yee9DHKlyOkOfbcmW4Pkm2vr00uORFHLozl2R1jS54= 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.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="PAQxFpv9" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b6e5c74cb7so1030717685a.2 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=pV4VuuFPcGV87A/9+BKkXsAh0798cs2yZaJf08ihwYU6vmVA4pT1ifcrpENWa6Dg7S 9VGRdPwVloxCPoAnSS2GXiA+NQAu1esh3mdqgdTZpXXHLTxY+AOdm3YmFHpx5IMF9A+9 18ifsAWzfo+Pf+WqbTH73S+nrmiB0GcSsMc2Hu3VNDJ+NK25QDPsf8pHP3deDcCktbun IeyRBCwUFq1ZKK27wU/HBTc0BRWsxR5LOdBiEsRuj90XejktEdu3bDnivmjAmyBxLH2H DUw98cuHXrgbbr4tB/d/K2Ftk8HCIVj/1st+Jt3ET0sR7gUS9wlhK5UE6GWESxfNeTBP YLvQ== X-Gm-Message-State: AOJu0Ywz9YDKGPdXdIwxhqsPKpS5EPBTfNUO9PlLHusEtRJkvtfYJ8T9 zVPNORQ1KZBDEenQppoDpi3zbfC538dm1sLPuMiAh8cMGDEmYDTcEqFkuwiPLw== X-Gm-Gg: ASbGncsxhSo/IRVwE2U3qDV6F5InpoDBQZ54x83or8tPW1hjvA1KHXQOZTXeUv3WiYg CB8S2d61STu3l1zily6LkCPg9eXBXsWUPUQArXV1EEkQR4cO1d9ewNNJiA1m1lH3PfOqPawfyhX crstR4sQwjKiNAYNtujx8dxZsLwydKXE3UPs5zOgrKuXlDr1axNiNYvOTVPbpv+2q/u6MBTEyf4 XUUxlBnAWdr44b8/pS2WyndavyOT7UyrAb5RRFXgF4EmA6GkUp+W00ylvhSCCxJxVWVItb2fX+u r3zMl8osmj08JiC0OE2JkkWgSlmcNzV8Q6mV 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-media@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;