Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1723356ybl; Sat, 11 Jan 2020 01:27:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxNPLCZQMksoQx5RIq2EZPUEx454Are+NAR3eQ1LD0lhzNM+XzXCpSGXDOaM5v1iZ8FfLUX X-Received: by 2002:a05:6830:1555:: with SMTP id l21mr5765882otp.41.1578734845828; Sat, 11 Jan 2020 01:27:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578734845; cv=none; d=google.com; s=arc-20160816; b=BouzxrlKNxZDWPwPK3QDhsa1lY9Rt9KRws+as1pPX5xFxyNUS341d+9yDMNPVhA12M GAU8uIL5Q2p6Txs2TFTZKkhvJPbD5mZqn0N4Mlj0tzJGMrYApysfQnGG5NLFHPLGMlR9 s47edXKq7Ym+4SrSk12rOGZ1MMOvs3DLLJkb//tGXTLpnAQPTEdTEbr88fPEehVHWj0y HvMmo664nLajyW9PV0ag1iS1J/rVraZJENLw2vvrdRqeW9QJMbGA6h0finL4trRnQy/l 3MIyH+pib146t7FWyoHVW83xDn2vMdNGqfG1oNp+JicEbdObkizKgy5IQDNfN73/858m zT3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TEia/ZgGyocdXAkiZ79+dRz2HyOO0KgveENibSFOSgc=; b=N3/aWDXM3J7oIWK9pNW+6hRmVGRijsB0OmlthYoI5i4cn4raWH+alePC0MOYMrpm5W npuzqV3/rFTItfTcV19oq1k8mmDfYIaTsrsCriPXn46qRKv5jPhjKKycP22CD9P24D6R wx31bN3gNS07nAa6lrtwDKjI2SEJWLqKTKtoOb9FjQ7atyFAQWhSB54j1OWYXzES7Nj2 EFBfpiEBfMMLsqoH2yMObKaeuRxq7xI6aFnRKddz4scYHHWAFq7iyrGqstkl+9e6VTWM czPVpv7BQ02+qwINkgn+oa0XXeKYQnh+WyeK5+k39HC3W4uSZurxQFldYNyk83ADgDee q+0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LD4SDwT1; 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 p6si2750866oig.88.2020.01.11.01.27.14; Sat, 11 Jan 2020 01:27:25 -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=LD4SDwT1; 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 S1728683AbgAKJZN (ORCPT + 99 others); Sat, 11 Jan 2020 04:25:13 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56221 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728662AbgAKJZN (ORCPT ); Sat, 11 Jan 2020 04:25:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578734711; 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=TEia/ZgGyocdXAkiZ79+dRz2HyOO0KgveENibSFOSgc=; b=LD4SDwT1O0CjvvsBvSZZG+udF5t/1NEn4AZhfdj3W9KRCZ7kDaoLrkFZgEoUSuW0uRkSll pm+S8quQoLUrUMyKK2xYPbAM1RKDSxFRIC04ahGEOkF7XqYESYWHA+ex7i3+t5p6uJhI7R PNleGZ0Ya+AnTIeadsJTdHbTwYEKdgc= Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-WVPvccZfOhibgW5qrBpiYw-1; Sat, 11 Jan 2020 04:25:09 -0500 X-MC-Unique: WVPvccZfOhibgW5qrBpiYw-1 Received: by mail-il1-f197.google.com with SMTP id l13so3533322ilj.4 for ; Sat, 11 Jan 2020 01:25:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TEia/ZgGyocdXAkiZ79+dRz2HyOO0KgveENibSFOSgc=; b=YJsIgoqmEHK8lD1ukr4B81zcYuGgMGDrWpKmEceXWw2WupYxJQgG176Jck7ntXMTHU YQGuviKP3Ie53J36mEJygh3CqTcabOk1DxjlA+FWpIzTTdTNy7HKD0oYv23cIgov8xoh D5/nob/3HU+TAvWYdIDRR6DRThtwFZP8CAcjYsJ/aDbBfMaiKS0V7eCB6ty10bItaAt7 PoexpC+O7PDbU5lNTcENHS6vPralw05TLgrvaaVZiQue65WyXZDfcVWi9Z9lI0roEf85 pTBpOK3N6PHImE8sK/ULFMniWBAzjJhrHkyCCr6IOtTwo6DLhkquTvoB8bERjg1+BMdd +RTQ== X-Gm-Message-State: APjAAAWwSHYQnPgPBibAFzyG7X8mCqJyLp52uyKTHKqRXtyzFBqN07yX xcGQsDuDypRuGY901oLZYJmmJW8I3QLxFWj57xOcgtsVOOeD96mSbKy82iBZxKZIcopvNJLFNWo kXjWAZcQMge7XBLjG7cuLPSYJkmph8RrMCrkOXi7X X-Received: by 2002:a02:1041:: with SMTP id 62mr6480352jay.51.1578734709195; Sat, 11 Jan 2020 01:25:09 -0800 (PST) X-Received: by 2002:a02:1041:: with SMTP id 62mr6480332jay.51.1578734708922; Sat, 11 Jan 2020 01:25:08 -0800 (PST) MIME-Version: 1.0 References: <20200110214217.GA88274@google.com> <20200110230003.GB1875851@anatevka.americas.hpqcorp.net> <20200111004510.GA19291@MiWiFi-R3L-srv> In-Reply-To: <20200111004510.GA19291@MiWiFi-R3L-srv> From: Kairui Song Date: Sat, 11 Jan 2020 17:24:57 +0800 Message-ID: Subject: Re: [RFC PATCH] PCI, kdump: Clear bus master bit upon shutdown in kdump kernel To: Baoquan He Cc: Jerry Hoemann , Khalid Aziz and Shuah Khan , Bjorn Helgaas , linux-pci@vger.kernel.org, kexec@lists.infradead.org, Linux Kernel Mailing List , Deepa Dinamani , Randy Wright , Dave Young Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 11, 2020 at 8:45 AM 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 > pci_dev->current_state = PCI_D0 or PCI_D3hot Or to put it simple, I just synced the actual PM state into pci_dev->current_state using a quirk, for kdump kernel only. > 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. > Thank you for the detailed description! -- Best Regards, Kairui Song