mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Raul E Rangel" <rrangel@chromium.org>,
	"Heikki Krogerus" <heikki.krogerus@linux.intel.com>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v3] serial: 8250_dw: preserve BUSY-safe fractional divisor programming
Date: Mon, 26 Oct 2026 21:16:33 +0200	[thread overview]
Message-ID: <at-nEUdDMYZpY7oQ@ashevche-desk.local> (raw)
In-Reply-To: <20261026-submit-serial-8250-dw-divisor-v1-v3-1-7dbd194e1f38@gmail.com>

On Mon, Oct 26, 2026 at 09:59:10AM -0600, James Hilliard wrote:
> dw8250_probe() installs a divisor setter that makes the UART idle and
> checks DLAB before writing DLL and DLH. When dw8250_setup_port() detects
> fractional-divisor support, it replaces that setter with the library's
> callback. The replacement writes DLF and uses serial8250_do_set_divisor(),
> bypassing the divisor setter's idle sequence and DLAB readback.
> 
> If the LCR update fails to set DLAB, the subsequent divisor writes can
> reach TX and IER instead of DLL and DLH.
> 
> Expose the library's fractional-divisor calculation and DLF write as
> shared helpers. Install the BUSY-safe setter after hardware discovery and
> use the shared DLF helper to program the fractional field only after DLAB
> has been confirmed, alongside DLL and DLH. Select the shared calculator
> when fractional divisors are supported, preserving the core calculation
> for integer-only ports. Keep the check for fractional-divisor support in
> the shared DLF setter so callers can use it for either kind of port.

...

> +	/* Use the BUSY-safe sequence for both integer and fractional divisors. */
> +	if (data->data.dlf_size)
> +		p->get_divisor = dw8250_get_divisor_dlf;

Yeah, this will be the similar issue with layering violation that Ilpo pointed
out elsewhere. So, perhaps easiest way for now is to let it be as is here, id
est not assigning .get_divisor() at all. Otherwise we would need the same check
in there and the branch on what to do if it's not a DLF case.

> +	p->set_divisor = dw8250_set_divisor;

...

>  	if (reg) {
>  		pd->dlf_size = fls(reg);
> -		p->get_divisor = dw8250_get_divisor;
> +		p->get_divisor = dw8250_get_divisor_dlf;

Just add a static function wrapper that simply calls this, so we won't
change it here at all.

static unsigned int dw8250_get_divisor(struct uart_port *p, unsigned int baud,
                                       unsigned int *frac)
{
	return dw8250_get_divisor_dlf(p, baud, frac);
}

>  		p->set_divisor = dw8250_set_divisor;
>  	}

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2026-10-26 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 15:59 James Hilliard
2026-10-26 19:16 ` Andy Shevchenko [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=at-nEUdDMYZpY7oQ@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=james.hilliard1@gmail.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=rrangel@chromium.org \
    --cc=stable@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®