From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E62DC43143 for ; Tue, 2 Oct 2018 16:43:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A974C2064A for ; Tue, 2 Oct 2018 16:43:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A974C2064A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728022AbeJBX2K (ORCPT ); Tue, 2 Oct 2018 19:28:10 -0400 Received: from mga12.intel.com ([192.55.52.136]:11427 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727691AbeJBX2K (ORCPT ); Tue, 2 Oct 2018 19:28:10 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Oct 2018 09:43:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,332,1534834800"; d="scan'208";a="94005264" Received: from shbuild888.sh.intel.com ([10.239.146.239]) by fmsmga004.fm.intel.com with ESMTP; 02 Oct 2018 09:43:52 -0700 From: Feng Tang To: Thomas Gleixner , Ingo Molnar , H Peter Anvin , Borislav Petkov , Peter Zijlstra , "Stuart R . Anderson" , alan@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Feng Tang Subject: [PATCH v3] x86/earlyprintk: Add a force option for pciserial device Date: Wed, 3 Oct 2018 00:49:21 +0800 Message-Id: <20181002164921.25833-1-feng.tang@intel.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "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 "",force,B:D.F,baud". And the original format ",B:D.F,baud" is kept unchanged. Suggested-by: Borislav Petkov Signed-off-by: Feng Tang --- Documentation/admin-guide/kernel-parameters.txt | 6 +++++- arch/x86/kernel/early_printk.c | 26 +++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 92eb1f4..08b4484 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1063,7 +1063,7 @@ earlyprintk=serial[,0x...[,baudrate]] earlyprintk=ttySn[,baudrate] earlyprintk=dbgp[debugController#] - earlyprintk=pciserial,bus:device.function[,baudrate] + earlyprintk=pciserial[,force],bus:device.function[,baudrate] earlyprintk=xdbc[xhciController#] earlyprintk is useful when the kernel crashes before @@ -1095,6 +1095,10 @@ The sclp output can only be used on s390. + The optional "force" for pciserial means insisting to + use a PCI device even when its classcode is not of + UART class. + edac_report= [HW,EDAC] Control how to report EDAC event Format: {"on" | "off" | "force"} on: enable EDAC to report H/W event. May be overridden diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c index 5e801c8..4eb5545 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 ",force,B:D.F,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,17 +226,23 @@ static __init void early_pci_serial_init(char *s) u32 classcode, bar0; u16 cmdreg; char *e; + int force = 0; - - /* - * First, part the param to get the BDF values - */ if (*s == ',') ++s; if (*s == 0) return; + /* User may insist to use a UART device with wrong class code */ + if (!strncmp(s, "force,", 6)) { + force = 1; + s += 6; + } + + /* + * First, part the param to get the BDF values + */ bus = (u8)simple_strtoul(s, &e, 16); s = e; if (*s != ':') @@ -264,8 +272,10 @@ static __init void early_pci_serial_init(char *s) */ if (((classcode >> 16 != PCI_CLASS_COMMUNICATION_MODEM) && (classcode >> 16 != PCI_CLASS_COMMUNICATION_SERIAL)) || - (((classcode >> 8) & 0xff) != 0x02)) /* 16550 I/F at BAR0 */ - return; + (((classcode >> 8) & 0xff) != 0x02)) /* 16550 I/F at BAR0 */ { + if (!force) + return; + } /* * Determine if it is IO or memory mapped -- 2.7.4