Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1940543pxk; Sun, 13 Sep 2020 23:31:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnrFWDK3xG5QBBCMzjvDsqg6GVgx8D9yYTMR5pMWm6nudP922eyTdJIILIy1l8vm+af7PR X-Received: by 2002:a17:906:fb84:: with SMTP id lr4mr13802521ejb.282.1600065118360; Sun, 13 Sep 2020 23:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600065118; cv=none; d=google.com; s=arc-20160816; b=knCuiJgjCqEe+olqlTEJHhRstAT9w0UA/PEJe4G6r8VXgOLq4mq4L56LcXhsWyoepc xJp3098b3pvsZo4um0KNDWKCx6URPf9mVA+jCeEQo91AkZF+r/VUDsg+Ij+ETPkjbOLu BSpJfgSBEDBa9XQe17YQkxb9olkkOTFvknSX24Om8AmZPZ5pYCd6a7Eb5nCwgy78SY45 YOHbOdKH4AXlvz4QYLGF6bscMecvFNVTlBPq4Q+lbIRi0QBhklR+Gm7nJST0F0AmARod G4lBGVvLYVNq/PPS3OTu3z7tSel6jEzFMX+CaFqZzlZm87XS6Psng1LErTcceJ/En0AS G3gQ== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=db6vup0BgyD1TJeHS5E1xea7GWnfdjxz+SzPYEMvqEk=; b=Jvp1c1JpUgoQWDxgYdz63/o48r7d3ajasjQcBipwJ1SRmh1HHe8M9ZkEpwrXVCyzt0 oIk5p6EKv9VRo7xRokXen2YMLgGeT48Zmsh+iLUGrXAAhSWF+6oOgebW1QN6KDGhCh6K Kx2E2nHs2kBvkxROVHvuc00CsQrO22oWrTkssSLMo4/jzepKojHk/W6laEskTQge9SFq xbTQfENaUrVr7calm+HpSnJtua5v02nd0B0ps9LNsOXx+AmNqFzPZj/WBF2+OvH2OwoF a8D0HvBBP3v+xrWm3paIYkeijVy/n0KNKaONx6DjJHbQJT2IYA9TtrFLD7rlUFA3FkXi TQ5w== 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 y19si6579044edi.411.2020.09.13.23.31.35; Sun, 13 Sep 2020 23:31:58 -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 S1726042AbgINGay (ORCPT + 99 others); Mon, 14 Sep 2020 02:30:54 -0400 Received: from mail.loongson.cn ([114.242.206.163]:50928 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726003AbgINGax (ORCPT ); Mon, 14 Sep 2020 02:30:53 -0400 Received: from [10.130.0.155] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxL94FDl9feh8VAA--.5389S3; Mon, 14 Sep 2020 14:30:30 +0800 (CST) Subject: Re: [RFC PATCH v2] PCI/portdrv: Only disable Bus Master on kexec reboot and connected PCI devices To: Lukas Wunner References: <1600028950-10644-1-git-send-email-yangtiezhu@loongson.cn> <20200914040625.GA20033@wunner.de> <43683243-f8e2-c555-447a-f108740c70e8@loongson.cn> 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 From: Tiezhu Yang Message-ID: <00acf33c-b69f-061b-cac0-6dc7abd018f9@loongson.cn> Date: Mon, 14 Sep 2020 14:30:29 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <43683243-f8e2-c555-447a-f108740c70e8@loongson.cn> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf9DxL94FDl9feh8VAA--.5389S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Zw48Cr17JF4DKw4rCw1fXrb_yoW8Kr1fpF WDKa92yFy0gF17Wr17XFWxXF15JwsIy34Fkr18C3y3Wrsayas3trWrtF909a1kXrWvyFW7 Ar95tr97CFW3JFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBY14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r xl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IY64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7Mxk0xIA0c2IEe2xFo4CEbIxvr21lc2xSY4AK67AK6r47MxAIw28IcxkI7VAKI4 8JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xv wVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjx v20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20E Y4v20xvaj40_Wr1j6rW3Jr1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjkpnJUUUUU== X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/14/2020 02:13 PM, Tiezhu Yang wrote: > On 09/14/2020 12:06 PM, Lukas Wunner wrote: >> 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() > > pcie_port_device_remove() deletes pci_disable_device(dev) at the > beginning of this patch. Sorry, I misunderstood your meaning, you are right. > > > diff > > --git a/drivers/pci/pcie/portdrv_core.c > b/drivers/pci/pcie/portdrv_core.c index 50a9522..1991aca 100644 --- > a/drivers/pci/pcie/portdrv_core.c +++ > b/drivers/pci/pcie/portdrv_core.c @@ -491,7 +491,6 @@ void > pcie_port_device_remove(struct pci_dev *dev) { > device_for_each_child(&dev->dev, NULL, remove_iter); > pci_free_irq_vectors(dev); > - pci_disable_device(dev); } > >> >> Thanks, >> >> Lukas