From: Dan Carpenter <dan.carpenter@linaro.org>
To: Su Hui <suhui@nfschina.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>,
jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com,
airlied@gmail.com, daniel@ffwll.ch, nathan@kernel.org,
ndesaulniers@google.com, trix@redhat.com,
andrzej.hajda@intel.com, intel-gfx@lists.freedesktop.org,
llvm@lists.linux.dev, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
mripard@kernel.org
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/tv: avoid possible division by zero
Date: Tue, 25 Jul 2023 08:51:50 +0300 [thread overview]
Message-ID: <5d096bcf-c394-4dad-b307-3d7e33ab6e6f@kadam.mountain> (raw)
In-Reply-To: <352f7c10-3592-4a18-abdc-ab554a992d10@nfschina.com>
The reason why the first five attempts had bugs is because we are
trying to write it in the most complicated way possible, shifting by
logical not what?
regards,
dan carpenter
diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c
index 36b479b46b60..6997b6cb1df2 100644
--- a/drivers/gpu/drm/i915/display/intel_tv.c
+++ b/drivers/gpu/drm/i915/display/intel_tv.c
@@ -988,7 +988,13 @@ intel_tv_mode_to_mode(struct drm_display_mode *mode,
const struct tv_mode *tv_mode,
int clock)
{
- mode->clock = clock / (tv_mode->oversample >> !tv_mode->progressive);
+ int div = tv_mode->oversample;
+
+ if (!tv_mode->progressive)
+ div >>= 1;
+ if (div == 0)
+ div = 1;
+ mode->clock = clock / div;
/*
* tv_mode horizontal timings:
@@ -1135,6 +1141,8 @@ intel_tv_get_config(struct intel_encoder *encoder,
break;
default:
tv_mode.oversample = 1;
+ WARN_ON_ONCE(!tv_mode.progressive);
+ tv_mode.progressive = true;
break;
}
next prev parent reply other threads:[~2023-07-25 5:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 1:32 Su Hui
2023-07-24 17:35 ` [Intel-gfx] " Andi Shyti
2023-07-25 4:06 ` Su Hui
2023-07-25 5:51 ` Dan Carpenter [this message]
2023-07-26 1:21 ` Su Hui
2023-07-26 4:58 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d096bcf-c394-4dad-b307-3d7e33ab6e6f@kadam.mountain \
--to=dan.carpenter@linaro.org \
--cc=airlied@gmail.com \
--cc=andi.shyti@linux.intel.com \
--cc=andrzej.hajda@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mripard@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=rodrigo.vivi@intel.com \
--cc=suhui@nfschina.com \
--cc=trix@redhat.com \
--cc=tvrtko.ursulin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®