public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Feng Tang <feng.tang@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	H Peter Anvin <hpa@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Stuart R . Anderson" <stuart.r.anderson@intel.com>,
	alan@linux.intel.com, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] x86/earlyprintk: Add a force option for pciserial device
Date: Sat, 29 Sep 2018 18:34:58 +0200	[thread overview]
Message-ID: <20180929163458.GA25608@zn.tnic> (raw)
In-Reply-To: <20180928094008.23138-1-feng.tang@intel.com>

On Fri, Sep 28, 2018 at 05:40:08PM +0800, Feng Tang wrote:
> "pciserial" earlyprintk helps much on many modern x86 platforms,
> but unfortunately there are still some platforms whose PCI UART
> devices have wrong PCI class code, which will be blocked by current
> class code check.
> 
> Add a option "force" so that developer could still use a UART device
> even it has wrong class code, with format "",B:D.F,force,baud". And

This new parameter and its meaning needs to be documented where
pciserial is documented.

> the original format ",B:D.F,baud" is kept unchanged.
> 
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Feng Tang <feng.tang@intel.com>
> ---
>  arch/x86/kernel/early_printk.c | 26 ++++++++++++++++++++------
>  1 file changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
> index 5e801c8..35d0f66 100644
> --- a/arch/x86/kernel/early_printk.c
> +++ b/arch/x86/kernel/early_printk.c
> @@ -213,8 +213,10 @@ static unsigned int mem32_serial_in(unsigned long addr, int offset)
>   * early_pci_serial_init()
>   *
>   * This function is invoked when the early_printk param starts with "pciserial"
> - * The rest of the param should be ",B:D.F,baud" where B, D & F describe the
> - * location of a PCI device that must be a UART device.
> + * The rest of the param should be ",B:D.F,baud" or ",B:D.F,force,baud", where
> + * B, D & F describe the location of a PCI device that must be a UART device,
> + * "force" is optional and means insisting using a UART device with a wrong
> + * pci class code.
>   */
>  static __init void early_pci_serial_init(char *s)
>  {
> @@ -224,6 +226,7 @@ static __init void early_pci_serial_init(char *s)
>  	u32 classcode, bar0;
>  	u16 cmdreg;
>  	char *e;
> +	int force = 0;
>  
>  
>  	/*
> @@ -252,6 +255,15 @@ static __init void early_pci_serial_init(char *s)
>  	if (*s == ',')
>  		s++;
>  
> +	/* User may insist to use a UART device with wrong class code */
> +	if (!strncmp(s, "force", 5)) {
> +		force = 1;
> +		s += 5;
> +
> +		if (*s == ',')
> +			s++;

No, you need to force the presence of "," otherwise cmdlines like this:

earlyprintk=pciserial,0:XX.X,forcedoodoo

work too.

> +	}
> +
>  	/*
>  	 * Second, find the device from the BDF
>  	 */
> @@ -262,10 +274,12 @@ static __init void early_pci_serial_init(char *s)
>  	/*
>  	 * Verify it is a UART type device
>  	 */
> -	if (((classcode >> 16 != PCI_CLASS_COMMUNICATION_MODEM) &&
> -	     (classcode >> 16 != PCI_CLASS_COMMUNICATION_SERIAL)) ||
> -	   (((classcode >> 8) & 0xff) != 0x02)) /* 16550 I/F at BAR0 */
> -		return;
> +	if (!force) {
> +		if (((classcode >> 16 != PCI_CLASS_COMMUNICATION_MODEM) &&
> +		     (classcode >> 16 != PCI_CLASS_COMMUNICATION_SERIAL)) ||
> +		   (((classcode >> 8) & 0xff) != 0x02)) /* 16550 I/F at BAR0 */
> +			return;

Move the force check in here ^

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

  reply	other threads:[~2018-09-29 16:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28  9:40 [PATCH v2] x86/earlyprintk: Add a force option for pciserial device Feng Tang
2018-09-29 16:34 ` Borislav Petkov [this message]
2018-09-30 13:16   ` Feng Tang
2018-10-01 12:39     ` Borislav Petkov
2018-10-01 14:18       ` Feng Tang
2018-10-01 20:30         ` Borislav Petkov
2018-10-02  9:16           ` Feng Tang
2018-10-02  9:17             ` Thomas Gleixner
2018-10-02  9:48               ` Feng Tang
2018-10-02 10:44                 ` Thomas Gleixner
2018-10-02 12:10                   ` Feng Tang
2018-10-02 15:31                     ` Feng Tang
2018-10-02 15:41                       ` Thomas Gleixner
2018-10-02 15:49                         ` Feng Tang

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=20180929163458.GA25608@zn.tnic \
    --to=bp@alien8.de \
    --cc=alan@linux.intel.com \
    --cc=feng.tang@intel.com \
    --cc=hpa@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stuart.r.anderson@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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