Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1349621ybl; Fri, 10 Jan 2020 16:53:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwvMamuzVmPOA2mXLAPba00vlSznvwTrjBdwf0fX1vVJGmKDryLpavgBjXP8ADBHuNPYyQC X-Received: by 2002:aca:1a10:: with SMTP id a16mr4750592oia.9.1578703986945; Fri, 10 Jan 2020 16:53:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578703986; cv=none; d=google.com; s=arc-20160816; b=RTtuGj0AzUVhKJmmG4TtyKcaW3Ekro+OL1//OUHp5bud4ie/pF1QjrI2SGcrV3pSVZ zKhXVsQcSoCKASKMw7ayZVZT9FV3JUaD+lqhFC74V4YeJZnOf9Bq53WOQ0EyhClMx6gP l9XoXXjiDgWx4dmpGpOZopPaZOjHyoVfhGzUjiRYxiKt6JKEA/biml9xzOu0ZHJOtdxA xwmRbctEGHdEDUj3z5J1eHm1y0jC1eUsiufn8283Gv8bHv7M1pffF9LePuu3RAzEbw17 87NSSzrC3Ui/f/fFlq3HfOeYuxU4ditge1mQ3nZ1kx7WxoluxRKBcfz7XQqi8CSy8Jfs W1tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zbgMmgPunuCU+6eAQTwKzCS91MthkUUJmXAiSzigQk4=; b=p6XMdhPqzbqKoMLM/OISndUW1zKR/mrC1zhrIdYhdFUkI7Wo7Xw+INdMujB+2U2hIG WrGZ4NNXa5kM1n2XXS4hsOk1+oS09Rb5He6a8edI0pQC7VpJ9isFAa7NynCLVtu6NrvV fyFKExNSc37VNiLc8c6c+hWviGUd8gkPv+53I+0pK5MHq2vTZuZJP5xDFCP42FV/BH7K ZzjG/RtH0fzmKEtHtaxWL3fbgCQCvAt6et8Nhxfa07obkxSxMp9VidpMEGzc/Mv9S3i+ /XQsTODUg14TO0JRfKlmOBsNHl88CCCSBizTAP8fDh5NipB1zeYF18DmDkJ35bMsR5/v YHLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bfnHAhM6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si2514003otr.197.2020.01.10.16.52.55; Fri, 10 Jan 2020 16:53:06 -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=@redhat.com header.s=mimecast20190719 header.b=bfnHAhM6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727805AbgAKAv6 (ORCPT + 99 others); Fri, 10 Jan 2020 19:51:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56521 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727629AbgAKAv6 (ORCPT ); Fri, 10 Jan 2020 19:51:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578703916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zbgMmgPunuCU+6eAQTwKzCS91MthkUUJmXAiSzigQk4=; b=bfnHAhM6cPU5AxgbLKbDKqTJX/FM8B//3zMZN2p0a4rDJhWfdJyXERhKpwv+/2QBRL8CM+ OKGRh8bOCSt6Rsh30hu8X/ayc36+8979+XraQcuH33MqUDxuJgrlFTi7R0sGdhPLLSzxje 76ZXZXYmb+4oRgiOJ1qW9z0MeAYfPCM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-GnAe3hIvPAGU2VTL5DUq0w-1; Fri, 10 Jan 2020 19:51:53 -0500 X-MC-Unique: GnAe3hIvPAGU2VTL5DUq0w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDF0B800EBF; Sat, 11 Jan 2020 00:51:51 +0000 (UTC) Received: from localhost (ovpn-12-27.pek2.redhat.com [10.72.12.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D68521001B00; Sat, 11 Jan 2020 00:51:48 +0000 (UTC) Date: Sat, 11 Jan 2020 08:51:46 +0800 From: Baoquan He To: Jerry Hoemann Cc: Khalid Aziz and Shuah Khan , Bjorn Helgaas , Kairui Song , linux-pci@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Deepa Dinamani , Randy Wright , dyoung@redhat.com Subject: Re: [RFC PATCH] PCI, kdump: Clear bus master bit upon shutdown in kdump kernel Message-ID: <20200111005146.GC19291@MiWiFi-R3L-srv> References: <20200110214217.GA88274@google.com> <20200110230003.GB1875851@anatevka.americas.hpqcorp.net> <20200111004510.GA19291@MiWiFi-R3L-srv> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200111004510.GA19291@MiWiFi-R3L-srv> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/11/20 at 08:45am, Baoquan He wrote: > On 01/10/20 at 04:00pm, Jerry Hoemann wrote: > > > I am not understanding this failure mode either. That code in > > > pci_device_shutdown() was added originally to address this very issue. > > > The patch 4fc9bbf98fd6 ("PCI: Disable Bus Master only on kexec reboot") > > > shut down any errant DMAs from PCI devices as we kexec a new kernel. In > > > this new patch, this is the same code path that will be taken again when > > > kdump kernel is shutting down. If the errant DMA problem was not fixed > > > by clearing Bus Master bit in this path when kdump kernel was being > > > kexec'd, why does the same code path work the second time around when > > > kdump kernel is shutting down? Is there more going on that we don't > > > understand? > > > > > > > Khalid, > > > > I don't believe we execute that code path in the crash case. > > > > The variable kexec_in_progress is set true in kernel_kexec() before calling > > machine_kexec(). This is the fast reboot case. > > > > I don't see kexec_in_progress set true elsewhere. > > > > > > The code path for crash is different. > > > > For instance, panic() will call > > -> __crash_kexec() which calls > > -> machine_kexec(). > > > > So the setting of kexec_in_progress is bypassed. > > Yeah, it's a differet behaviour than kexec case. I talked to Kairui, the > patch log may be not very clear. Below is summary I got from my > understanding about this issue: > > ~~~~~~~~~~~~~~~~~~~~~~~ > Problem: > > When crash is triggered, system jumps into kdump kernel to collect > vmcore and dump out. After dumping is finished, kdump kernel will try > ty reboot to normal kernel. This hang happened during kdump kernel > rebooting, when dumping is network dumping, e.g ssh/nfs, local storage > is HPSA. > > Root cause: > > When configuring network dumping, only network driver modules are added > into kdump initramfs. However, the storage HPSA pcie device is enabled > in 1st kernel, its status is PCI_D3hot. When crashed system jumps to kdump > kernel, we didn't shutdown any device for safety and efficiency. Then > during kdump kernel boot up, the pci scan will get hpsa device and only > initialize its status as pci_dev->current_state = PCI_UNKNOWN. This > pci_dev->current_state will be manipulated by the relevant device > driver. So HPSA device will never have chance to calibrate its status, > and can't be shut down by pci_device_shutdown() called by reboot > service. It's still PCI_D3hot, then crash happened when system try to > shutdown its upper bridge. > > Fix: > > Here, Kairui uses a quirk to get PM state and mask off value bigger than > PCI_D3cold. Means, all devices will get PM state ~~~~~~~~~ s/PCI_D3cold/PCI_D3hot/, typo > pci_dev->current_state = PCI_D0 or PCI_D3hot. Finally, during kdump > reboot stage, this device can be shut down successfully by clearing its > master bit. > > ~~~~~~~~~~~~~~~ > > About this patch, I think the quirk getting active PM state for all devices > may be risky, it will impact normal kernel too which doesn't have this issue. > > Wondering if there's any other way to fix or work around it. > > Thanks > Baoquan