Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5616572imu; Mon, 26 Nov 2018 03:03:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/VscDcseklZEF5t6O+ZDJ1IaID4eyjrrWXvArA9m+KwVw8BTVHUaRxbib1J29VqkadcSVKO X-Received: by 2002:a63:83c1:: with SMTP id h184mr24190278pge.437.1543230233852; Mon, 26 Nov 2018 03:03:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543230233; cv=none; d=google.com; s=arc-20160816; b=eXxIamkHXo4gjx9Zi6xXHeIXTEaZriu3xL5b7CVrIGs6SYRyHukttC1h99AZKWiDKa mSloSPC5D18bx6Jm2fVKOU9q8xk8f4xxQ10tX+Xg2yAZxOw88kCKQOdsmls4SVLbnHWF LjIiQUQLlo3PVhRfThHT8oAYtjBw+vyXYgb2DK9tmspEn8mGU7EOSzJ9MwnKplEctr6w EKrtCE9dR0GuzyFNWmsbgKAGUYytIXF+b6dve3xVlBRW4Sj7Sgvqj05F66WKza7ByYMC v8RssdjRiMpRXEdFOWgvReaut5Go2nI4Sl+fNiTrqmVusAMyUjiTv6X612PA6NKFY8U7 INSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4PJaHCCpRLVdmREmrnlEhacZXiV9W4H3M4VZENLfVNU=; b=QRIWrB3UMtHHnNFZhmvZN9B9rSzn+lavU+V9Nw7ynGvnaSdoEhD1WkAaMgcNX+qzBx YtY7V8yTdXb4ut43A9Tc1vDHbsY+Nn20gr/tg+7tmBWh2B7Iquh1RrG7KeTOwJZpqlpg gh8z5yVENiCDA734Z+r55a9n2zqgEimICVBZoD+L2TGm60r1vAkvZ6nBdMPDZti9OTkh LUoFsSQgwkNeHxAyjDHHJSv7Tz1p7ZRHLZnyCD4ZhMKk53P9CRHR6peYWR/SHNGvn8D+ Ex+TCDCIIffbTdHRj0tcZxhdpyYb9Dve3qJYboxC2wPuAiTbqNbnzx3rT6njhT5Pz8Kc NHDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zQ9Xiz2E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si11141278pfb.166.2018.11.26.03.03.37; Mon, 26 Nov 2018 03:03:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zQ9Xiz2E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730461AbeKZV4N (ORCPT + 99 others); Mon, 26 Nov 2018 16:56:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:39188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729135AbeKZV4M (ORCPT ); Mon, 26 Nov 2018 16:56:12 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9C63F21479; Mon, 26 Nov 2018 11:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230147; bh=pLabZEc3qzUP5IReUum+GbQN3DgS09nLClXiwJF0erA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zQ9Xiz2EI287KT2Gw1g+P2M9bGGqhaOAkO1CdFbPLpSO1f8Vhf+ygW7Adt5k5BOaI f5qgHpMpmz/EYbgGUA5mNQ2lPiJ4GLuVjrImTi08e7oIErq+KKdimmy+vwGXWzmLsb 3ra979D4TirYyrwCBidVr9SlLA5lGFLakfeg1Xok= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Feng Tang , Borislav Petkov , "H. Peter Anvin" , "Stuart R . Anderson" , Bjorn Helgaas , David Rientjes , Frederic Weisbecker , H Peter Anvin , Ingo Molnar , Jiri Kosina , Jonathan Corbet , Kai-Heng Feng , Kate Stewart , Konrad Rzeszutek Wilk , Peter Zijlstra , Philippe Ombredanne , Thomas Gleixner , Thymo van Beers , alan@linux.intel.com, linux-doc@vger.kernel.org, Sasha Levin Subject: [PATCH 4.19 025/118] x86/earlyprintk: Add a force option for pciserial device Date: Mon, 26 Nov 2018 11:50:19 +0100 Message-Id: <20181126105100.829963680@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105059.832485122@linuxfoundation.org> References: <20181126105059.832485122@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit d2266bbfa9e3e32e3b642965088ca461bd24a94f ] The "pciserial" earlyprintk variant helps much on many modern x86 platforms, but unfortunately there are still some platforms with PCI UART devices which have the wrong PCI class code. In that case, the current class code check does not allow for them to be used for logging. Add a sub-option "force" which overrides the class code check and thus the use of such device can be enforced. [ bp: massage formulations. ] Suggested-by: Borislav Petkov Signed-off-by: Feng Tang Signed-off-by: Borislav Petkov Cc: "H. Peter Anvin" Cc: "Stuart R . Anderson" Cc: Bjorn Helgaas Cc: David Rientjes Cc: Feng Tang Cc: Frederic Weisbecker Cc: Greg Kroah-Hartman Cc: H Peter Anvin Cc: Ingo Molnar Cc: Jiri Kosina Cc: Jonathan Corbet Cc: Kai-Heng Feng Cc: Kate Stewart Cc: Konrad Rzeszutek Wilk Cc: Peter Zijlstra Cc: Philippe Ombredanne Cc: Thomas Gleixner Cc: Thymo van Beers Cc: alan@linux.intel.com Cc: linux-doc@vger.kernel.org Link: http://lkml.kernel.org/r/20181002164921.25833-1-feng.tang@intel.com Signed-off-by: Sasha Levin --- .../admin-guide/kernel-parameters.txt | 6 +++- arch/x86/kernel/early_printk.c | 29 ++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 92eb1f42240d..34e6800dea0e 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" to "pciserial" enables use of a + PCI device even when its classcode is not of the + 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 5e801c8c8ce7..374a52fa5296 100644 --- a/arch/x86/kernel/early_printk.c +++ b/arch/x86/kernel/early_printk.c @@ -213,8 +213,9 @@ 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 "[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 overrides the use of an UART device with a wrong PCI class code. */ static __init void early_pci_serial_init(char *s) { @@ -224,17 +225,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; + /* Force the use of an UART device with wrong class code */ + if (!strncmp(s, "force,", 6)) { + force = 1; + s += 6; + } + + /* + * Part the param to get the BDF values + */ bus = (u8)simple_strtoul(s, &e, 16); s = e; if (*s != ':') @@ -253,7 +260,7 @@ static __init void early_pci_serial_init(char *s) s++; /* - * Second, find the device from the BDF + * Find the device from the BDF */ cmdreg = read_pci_config(bus, slot, func, PCI_COMMAND); classcode = read_pci_config(bus, slot, func, PCI_CLASS_REVISION); @@ -264,8 +271,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 @@ -289,7 +298,7 @@ static __init void early_pci_serial_init(char *s) } /* - * Lastly, initialize the hardware + * Initialize the hardware */ if (*s) { if (strcmp(s, "nocfg") == 0) -- 2.17.1