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: 856586 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 --- 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: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: 856585 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: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: 856584 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 --- 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;