mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Zou Jianqiang <jq.zou@outlook.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	"linux-fbdev@vger.kernel.org" <linux-fbdev@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"byu@xidian.edu.cn" <byu@xidian.edu.cn>,
	"25181214217@stu.xidian.edu.cn" <25181214217@stu.xidian.edu.cn>
Subject: Re: [PATCH] fbdev: radeonfb: match a display mode for a zero pixel period
Date: Wed, 25 Nov 2026 20:28:28 +0100	[thread overview]
Message-ID: <ed7fa7b4-93af-472e-89cd-2a1c7120f2ed@gmx.de> (raw)
In-Reply-To: <20261125135233.26656-1-jq.zou@outlook.com>

On 11/25/26 14:52, Zou Jianqiang wrote:
> From: Jianqiang Zou <jq.zou@outlook.com>
> 
> A zero pixclock was rejected in radeonfb_check_var() by commit
> b3f1631d3625 ("fbdev: radeonfb: reject a zero pixclock in
> radeonfb_check_var()").  That works around a division by zero, but it
> violates the fbdev API: a value that does not fit has to be rounded up
> by the driver, and -EINVAL is only for values that are too large.  A
> zero pixel period does not fit, so it has to be rounded up as well.
> 
> The check was added because a zero pixel period reaches
> radeonfb_set_par() and makes it divide by zero:
> 
> 	dotClock = 1000000000 / pixClock;
> 
> radeon_match_mode() already has the timings that can replace the
> unusable value, but it never gets that far.  With FB_ACTIVATE_NOW or
> FB_ACTIVATE_TEST it copies the request unchanged and only validates it
> against an EDID-derived mode database, and that database does not exist
> when no EDID was read - which is exactly the case that divides by zero.
> 
> Drop that check and let radeon_match_mode() round the request up
> instead.  A zero pixel period no longer takes the short path, so it is
> matched against the mode database and a complete set of timings is
> returned to the caller.  radeonfb_check_var() then hands a nonzero
> pixel period back to fb_set_var(), so what reaches radeonfb_set_par()
> is usable; how the mode is programmed still depends on the output.
> 
> The lookup needed a fix of its own to produce a usable mode.  Both VESA
> searches stopped after the first 34 entries, a limit that predates the
> widescreen modes at the end of vesa_modes[]; the other fbdev drivers
> already use VESA_MODEDB_SIZE for the same loop.  Use it here as well,
> as 1920x1200 is otherwise rounded up to 1920x1440 and 2560x1600 is
> rejected although the table has an entry for it.  Entries
> without a pixel period are skipped, so an unusable timing is never
> handed back.  Requests with a pixel period and FB_ACTIVATE_NOW or
> FB_ACTIVATE_TEST still return from the short path above; the ones that
> reach the lookup see the added widescreen entries as well.
> 
> When the request had no pixel period, the requested virtual dimensions
> are kept, so rounding up does not shrink the panning area; a request
> that does specify a period keeps the previous behaviour.  The panning
> offsets come from the selected mode, so a stale offset is not returned
> either.  The first equally close mode in database order wins, so a
> request without a pixel period does not end up at the highest refresh
> rate.
> 
> A request that matches no mode is rejected with -EINVAL.  For a
> zero-period request this now includes outputs with a scaler, because a
> scaler cannot invent a pixel period.  An output with a scaler still
> accepts a request that carries a period and uses those timings.
> 
> Tested on 7.3.0 with a QEMU stub device for 1002:5955.  It has no EDID,
> so mon1_modedb is NULL and has_rmx is 0, which is the configuration
> that reaches the division.  FBIOPUT_VSCREENINFO with pixclock = 0 for
> 640x480 now returns 0 and reports a rounded up period of 39682 ps,
> while the same request on the stock Linux 7.3 driver, before
> b3f1631d3625, still triggers "divide error" in radeonfb_set_par().  A
> request larger than any table entry, e.g. 4096x3072, returns -EINVAL.
> 
> Fixes: b3f1631d3625 ("fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var()")
> Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Link: https://lore.kernel.org/r/20261101104107.33909-1-jq.zou@outlook.com
> Link: https://lore.kernel.org/r/CAMuHMdWyrdpVKvs=8Q+B-Syo1ZdAJvfJXFv0qiNtR9z4VnwnBQ@mail.gmail.com
> Co-developed-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Bin Yu <byu@xidian.edu.cn>
> Co-developed-by: Mingyu Wang <25181214217@stu.xidian.edu.cn>
> Signed-off-by: Mingyu Wang <25181214217@stu.xidian.edu.cn>
> Signed-off-by: Jianqiang Zou <jq.zou@outlook.com>
> ---
>   drivers/video/fbdev/aty/radeon_base.c    |  3 ---
>   drivers/video/fbdev/aty/radeon_monitor.c | 21 ++++++++++++++-------
>   2 files changed, 14 insertions(+), 10 deletions(-)
applied.
Thanks!
Helge

      reply	other threads:[~2026-11-25 19:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 13:52 Zou Jianqiang
2026-11-25 19:28 ` Helge Deller [this message]

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=ed7fa7b4-93af-472e-89cd-2a1c7120f2ed@gmx.de \
    --to=deller@gmx.de \
    --cc=25181214217@stu.xidian.edu.cn \
    --cc=benh@kernel.crashing.org \
    --cc=byu@xidian.edu.cn \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert@linux-m68k.org \
    --cc=jq.zou@outlook.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®