Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1888721pxk; Sun, 13 Sep 2020 21:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0bpE18w75tiVcmcjnJ6/uGS4Nui+fhDP0zpZxNgtQfKjrkz5+wQe/sXLpvce0voxStEeI X-Received: by 2002:a17:906:3e90:: with SMTP id a16mr12086099ejj.363.1600056596988; Sun, 13 Sep 2020 21:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600056596; cv=none; d=google.com; s=arc-20160816; b=LMHpG4VClSw5tInmoCQX1uaAq5yUimJDUCXUA7YBEqcYO+jIX9xTkrUwATRB/Zc2tf emmxqmWWhh5sYShkX7SVHAdqsJMT6vK6BqdqSvtQ/0Tao0FfWkHco4Hd95EHZIRdqQEi PbMI/dou21qFR5eDixM7tKPapxG/xpdia4iHkUhtAmNnvrpRtME4JhH1gJgyU633qXze 4P3NGYK4LheWJ4L7LEtSJtiYd2AkS7SZHoS0s0KVFtpHBVyzPRb7DdvKfnhndA/ltgAP zkiDpSs5WyJ5sgJXpepDq3ryIKa5E3/sxMA2d/7eUpXLVv0rxf2uJ5adz8OZifuD0cBw RWyA== 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; bh=MZU1ODfYuGzWeWKf+0QNNSZMQJDwi34+wqYbF/r4gWw=; b=Ro0dLc8VKaTj42X20jU1ypebNYjf9sYkPBIif0NovgXs8W1m9rnT0s/r86d6tGq21A Za/y5Y/Mpe1st1s9lOKdtCcC+/GIt8BaDRhjgkCR/AIzJ2BCVeOkVKg/gTM+dpwyXpDm saQYGLpJwrlq61N7xui6kWQ0qXlCbmFWPq/B3OhYTAQrLN+OviSXg3W4aQWe66wEuMyu sof54kxhFLMz9NbIZFqFQRMJvBuaS/7fDSHr5oAarulfHgT/Z6GwbOIo5QWNqFymM3lA bm1AUTfJZ4gYMLX806N8pY6U6asJhMfMB3azhkXVn+1DBRr4jfU+6zgOU238QbIdH4m4 NNOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si812231ejk.390.2020.09.13.21.09.34; Sun, 13 Sep 2020 21:09:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726018AbgINEGf (ORCPT + 99 others); Mon, 14 Sep 2020 00:06:35 -0400 Received: from bmailout1.hostsharing.net ([83.223.95.100]:60919 "EHLO bmailout1.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgINEGf (ORCPT ); Mon, 14 Sep 2020 00:06:35 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id 68B8C3000118B; Mon, 14 Sep 2020 06:06:25 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 47DB9372AB; Mon, 14 Sep 2020 06:06:25 +0200 (CEST) Date: Mon, 14 Sep 2020 06:06:25 +0200 From: Lukas Wunner To: Tiezhu Yang Cc: Bjorn Helgaas , Konstantin Khlebnikov , Khalid Aziz , Vivek Goyal , oohall@gmail.com, rafael.j.wysocki@intel.com, Xuefeng Li , Huacai Chen , Jiaxun Yang , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2] PCI/portdrv: Only disable Bus Master on kexec reboot and connected PCI devices Message-ID: <20200914040625.GA20033@wunner.de> References: <1600028950-10644-1-git-send-email-yangtiezhu@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1600028950-10644-1-git-send-email-yangtiezhu@loongson.cn> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14, 2020 at 04:29:10AM +0800, Tiezhu Yang wrote: > --- a/drivers/pci/pcie/portdrv_pci.c > +++ b/drivers/pci/pcie/portdrv_pci.c > @@ -143,6 +144,28 @@ static void pcie_portdrv_remove(struct pci_dev *dev) > } > > pcie_port_device_remove(dev); > + pci_disable_device(dev); > +} > + > +static void pcie_portdrv_shutdown(struct pci_dev *dev) > +{ > + if (pci_bridge_d3_possible(dev)) { > + pm_runtime_forbid(&dev->dev); > + pm_runtime_get_noresume(&dev->dev); > + pm_runtime_dont_use_autosuspend(&dev->dev); > + } > + > + pcie_port_device_remove(dev); > + > + /* > + * If this is a kexec reboot, turn off Bus Master bit on the > + * device to tell it to not continue to do DMA. Don't touch > + * devices in D3cold or unknown states. > + * If it is not a kexec reboot, firmware will hit the PCI > + * devices with big hammer and stop their DMA any way. > + */ > + if (kexec_in_progress && (dev->current_state <= PCI_D3hot)) > + pci_disable_device(dev); The last portion of this function is already executed afterwards by pci_device_shutdown(). You don't need to duplicate it here: device_shutdown() dev->bus->shutdown() == pci_device_shutdown() drv->shutdown() == pcie_portdrv_shutdown() pci_disable_device() pci_disable_device() Thanks, Lukas