Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1933536pxk; Sun, 13 Sep 2020 23:14:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6fTjomPf2kV40WXC4YPAd0Hb7sis9LPkTN5gAHJi+940MHsSFB4cVcASFCfz6lK7d6rn2 X-Received: by 2002:aa7:de82:: with SMTP id j2mr16345809edv.3.1600064084193; Sun, 13 Sep 2020 23:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600064084; cv=none; d=google.com; s=arc-20160816; b=tBSKIw8TuVN73k2rVgwRRLCFazXvu9rh2hamOO4b/mWhVmEnKStgsZEZ2sRrsn/w59 H8+44BFmnFyoeYK4e7LwiYOcKZ99igQ+aQwf/WB90i+7wijMGf4hfOzcwXIU0yFW3lnk xdSoHzmfn6ZqCyDeRZw8X9eMOz9iSJLCXPFI6EF/DDcw4IBLUDlRKEEvtKJbED5R7l8S AARIufZLTAL/taRoHr9eD5FuFFnecxWVAiRfAA8nSaCOY0z9bM8/vZijiB7TtC3MzoKa 0bsutEjCwZL6SxTLsKMJ2monFlEW1ed8PTfUC4+IBUKE1aH6FbrSOvJ5pcbiMfbaQjhO y3WQ== 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=8VoE7V13wIl7qWrdCcmmQoE5K9R1EjyzZDmFpk2+GOk=; b=JYl56JBJ+38eViDB+PkAasZVsnB8SkIeeJS7KFi+VQMrwyVRGdFrRQchSfqYrUUhai oNHa7c5QNbU7HwARHPM3HxuLIBEBKIqROf72UMeyWfYmcHZ/KRA4LzclN6XJen4M5trr JoKlg9TQkRTFFjdhlbVSW2+MSk7gMGpH3m9lkOzN2U2B6FqxhHsyDKIas/usOVTsXQxy 4ZMZGeUT6fOqv0gpdQj3mD+lGVCP0LZPkQvrjw/q/pKxz0IkFeWHSZpiuBNstFKg/JTI 2688zHgv5HlwcjsaO49U4tSvvEDWw16yIZ5azcCvRF6n+oqEX2iF2YM92eu91jxaGdmY M7dw== 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 gw6si6530564ejb.240.2020.09.13.23.14.21; Sun, 13 Sep 2020 23:14:44 -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 S1726109AbgINGNv (ORCPT + 99 others); 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