From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16044C43461 for ; Mon, 14 Sep 2020 06:13:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E34D8206F4 for ; Mon, 14 Sep 2020 06:13:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726120AbgINGNv (ORCPT ); Mon, 14 Sep 2020 02:13:51 -0400 Received: from mail.loongson.cn ([114.242.206.163]:47200 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726027AbgINGNv (ORCPT ); Mon, 14 Sep 2020 02:13:51 -0400 Received: from [10.130.0.155] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxv98MCl9fQh4VAA--.5455S3; Mon, 14 Sep 2020 14:13:33 +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> 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: <43683243-f8e2-c555-447a-f108740c70e8@loongson.cn> Date: Mon, 14 Sep 2020 14:13:31 +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: <20200914040625.GA20033@wunner.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf9Dxv98MCl9fQh4VAA--.5455S3 X-Coremail-Antispam: 1UD129KBjvJXoW7ur4rWryDuw1DCr1fuFyUZFb_yoW8uFykpF WDJa92yFy0qry7Xr43XFyxXF15JwsIy34Fkr18C3y3Wrs3Ar95trWrtF909wn5X3yvyFW7 Ar95trn7GrWxJFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB014x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r xl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IY64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7Mxk0xIA0c2IEe2xFo4CEbIxvr21lc2xSY4AK67AK6r47MxAIw28IcxkI7VAKI4 8JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xv wVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjx v20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20E Y4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU1uc_DUUUU 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 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. 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