From patchwork Sat Sep 8 04:16:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 967557 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="GkcQqMQi"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 426gx34fyqz9s47 for ; Sat, 8 Sep 2018 14:16:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726354AbeIHJAx (ORCPT ); Sat, 8 Sep 2018 05:00:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:59190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbeIHJAw (ORCPT ); Sat, 8 Sep 2018 05:00:52 -0400 Received: from sinanubuntu1604.mkjiurmyylmellclgttazegk5f.bx.internal.cloudapp.net (unknown [40.76.195.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6ECCD20844; Sat, 8 Sep 2018 04:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536380196; bh=G/pW/TQwduYpkH/3kOJSxYyo5xzA7A3KkVhaB5uY804=; h=From:To:Cc:Subject:Date:From; b=GkcQqMQidE7Aug0oS3+WKLiGAiMwBAMV6X1trMQyj3mP1PjJneGn9Mw2p3gT6HdKT UiFOK+kU7feAD1faYCi/0rAZT6pfrx+R5KAdttw50Yx0VNnop7YNGGiHED4YA72BBo t0oMhslTjbeN2XpdLgDpW/QzP0e9so7bh1hVRQjQ= From: Sinan Kaya To: linux-pci@vger.kernel.org Cc: Sinan Kaya , Srinivas Pandruvada , Jiri Kosina , Benjamin Tissoires , Frank Haverkamp , "Guilherme G. Piccoli" , Arnd Bergmann , Greg Kroah-Hartman , Harish Patil , Manish Chopra , Dept-GELinuxNICDev@cavium.com, "David S. Miller" , Solarflare linux maintainers , Edward Cree , Bert Kenward , Bjorn Helgaas , Anton Vasilyev Subject: [PATCH 1/4] PCI: Expose reset_type to users of pci_reset_function() Date: Sat, 8 Sep 2018 04:16:24 +0000 Message-Id: <20180908041632.22252-1-okaya@kernel.org> X-Mailer: git-send-email 2.18.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Looking to have more control between the users of the API vs. what the API can do internally. The new reset_type tells the PCI core about the bounds of the request. Signed-off-by: Sinan Kaya --- drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +- drivers/misc/genwqe/card_base.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c | 2 +- drivers/net/ethernet/sfc/mcdi.c | 2 +- drivers/pci/pci-sysfs.c | 2 +- drivers/pci/pci.c | 4 ++-- include/linux/pci.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-ish-hid/ipc/ipc.c index bfbca7ec54ce..18312969f1b3 100644 --- a/drivers/hid/intel-ish-hid/ipc/ipc.c +++ b/drivers/hid/intel-ish-hid/ipc/ipc.c @@ -754,7 +754,7 @@ static int _ish_hw_reset(struct ishtp_device *dev) if (!pdev) return -ENODEV; - rv = pci_reset_function(pdev); + rv = pci_reset_function(pdev, PCI_RESET_ANY); if (!rv) dev->dev_state = ISHTP_DEV_RESETTING; diff --git a/drivers/misc/genwqe/card_base.c b/drivers/misc/genwqe/card_base.c index c7cd3675bcd1..cc78ef28ee38 100644 --- a/drivers/misc/genwqe/card_base.c +++ b/drivers/misc/genwqe/card_base.c @@ -201,7 +201,7 @@ static int genwqe_bus_reset(struct genwqe_dev *cd) * restored by the pci_reset_function(). */ dev_dbg(&pci_dev->dev, "[%s] pci_reset function ...\n", __func__); - rc = pci_reset_function(pci_dev); + rc = pci_reset_function(pci_dev, PCI_RESET_ANY); if (rc) { dev_err(&pci_dev->dev, "[%s] err: failed reset func (rc %d)\n", __func__, rc); diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c index d344e9d43832..bb737725f175 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c @@ -629,7 +629,7 @@ int qlcnic_fw_create_ctx(struct qlcnic_adapter *dev) int i, err, ring; if (dev->flags & QLCNIC_NEED_FLR) { - pci_reset_function(dev->pdev); + pci_reset_function(dev->pdev, PCI_RESET_ANY); dev->flags &= ~QLCNIC_NEED_FLR; } diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index dfad93fca0a6..7f95e17b8a48 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -1862,7 +1862,7 @@ int efx_mcdi_reset(struct efx_nic *efx, enum reset_type method) /* If MCDI is down, we can't handle_assertion */ if (method == RESET_TYPE_MCDI_TIMEOUT) { - rc = pci_reset_function(efx->pci_dev); + rc = pci_reset_function(efx->pci_dev, PCI_RESET_ANY); if (rc) return rc; /* Re-enable polled MCDI completion */ diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 9ecfe13157c0..9569664ec4b2 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1449,7 +1449,7 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr, return -EINVAL; pm_runtime_get_sync(dev); - result = pci_reset_function(pdev); + result = pci_reset_function(pdev, PCI_RESET_ANY); pm_runtime_put(dev); if (result < 0) return result; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 43a4b0969153..a6295f85a1bd 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4792,7 +4792,7 @@ int pci_probe_reset_function(struct pci_dev *dev) * Returns 0 if the device function was successfully reset or negative if the * device doesn't support resetting a single function. */ -int pci_reset_function(struct pci_dev *dev) +int pci_reset_function(struct pci_dev *dev, u32 reset_type) { int rc; @@ -4802,7 +4802,7 @@ int pci_reset_function(struct pci_dev *dev) pci_dev_lock(dev); pci_dev_save_and_disable(dev); - rc = __pci_reset_function_locked(dev, PCI_RESET_ANY); + rc = __pci_reset_function_locked(dev, reset_type); pci_dev_restore(dev); pci_dev_unlock(dev); diff --git a/include/linux/pci.h b/include/linux/pci.h index 6924d837c959..43d00e9e54f7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1123,7 +1123,7 @@ void pcie_print_link_status(struct pci_dev *dev); bool pcie_has_flr(struct pci_dev *dev); int pcie_flr(struct pci_dev *dev); int __pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); -int pci_reset_function(struct pci_dev *dev); +int pci_reset_function(struct pci_dev *dev, u32 reset_type); int pci_reset_function_locked(struct pci_dev *dev); int pci_try_reset_function(struct pci_dev *dev); int pci_probe_reset_slot(struct pci_slot *slot); From patchwork Sat Sep 8 04:16:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 967558 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="iV728hnl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 426gx43Nw8z9s9N for ; Sat, 8 Sep 2018 14:16:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbeIHJAx (ORCPT ); Sat, 8 Sep 2018 05:00:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:59224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbeIHJAx (ORCPT ); Sat, 8 Sep 2018 05:00:53 -0400 Received: from sinanubuntu1604.mkjiurmyylmellclgttazegk5f.bx.internal.cloudapp.net (unknown [40.76.195.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A4002086B; Sat, 8 Sep 2018 04:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536380197; bh=zOSiE7b7KkEo830vL59vmjAI9T7bPhXiIDz5tJBKX2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iV728hnlXv5xR9edpVt+iR/yOHu2V9yFnTiioDXsrLd6vzmF2INra+tUpqQkJgfMy UuKIEV+QFldhE7sI4XQJPP0lPnkD0xpr1coZDpU10K3ZxlJFXrkNPcXHTju8oJodNa 6qYUb0yyLjWH5z09aNSzP7OivhRwUsfVFuY3FGq0= From: Sinan Kaya To: linux-pci@vger.kernel.org Cc: Sinan Kaya , Bjorn Helgaas Subject: [PATCH 2/4] PCI: Expose reset_type to users of pci_reset_function_locked() Date: Sat, 8 Sep 2018 04:16:25 +0000 Message-Id: <20180908041632.22252-2-okaya@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180908041632.22252-1-okaya@kernel.org> References: <20180908041632.22252-1-okaya@kernel.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Looking to have more control between the users of the API vs. what the API can do internally. The new reset_type tells the PCI core about the bounds of the request. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 4 ++-- include/linux/pci.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a6295f85a1bd..89c45effb4f4 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4828,7 +4828,7 @@ EXPORT_SYMBOL_GPL(pci_reset_function); * Returns 0 if the device function was successfully reset or negative if the * device doesn't support resetting a single function. */ -int pci_reset_function_locked(struct pci_dev *dev) +int pci_reset_function_locked(struct pci_dev *dev, u32 reset_type) { int rc; @@ -4837,7 +4837,7 @@ int pci_reset_function_locked(struct pci_dev *dev) pci_dev_save_and_disable(dev); - rc = __pci_reset_function_locked(dev, PCI_RESET_ANY); + rc = __pci_reset_function_locked(dev, reset_type); pci_dev_restore(dev); diff --git a/include/linux/pci.h b/include/linux/pci.h index 43d00e9e54f7..fa852ebdf197 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1124,7 +1124,7 @@ bool pcie_has_flr(struct pci_dev *dev); int pcie_flr(struct pci_dev *dev); int __pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); int pci_reset_function(struct pci_dev *dev, u32 reset_type); -int pci_reset_function_locked(struct pci_dev *dev); +int pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); int pci_try_reset_function(struct pci_dev *dev); int pci_probe_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus); From patchwork Sat Sep 8 04:16:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 967559 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="pa45B/HJ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 426gx874qBz9s47 for ; Sat, 8 Sep 2018 14:16:44 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726378AbeIHJA7 (ORCPT ); Sat, 8 Sep 2018 05:00:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:59272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbeIHJA7 (ORCPT ); Sat, 8 Sep 2018 05:00:59 -0400 Received: from sinanubuntu1604.mkjiurmyylmellclgttazegk5f.bx.internal.cloudapp.net (unknown [40.76.195.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6A1320861; Sat, 8 Sep 2018 04:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536380203; bh=1Sxkngo9vAawE3YrmyUalqpqm57FriRqC929uJMvlBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pa45B/HJ4oGtW9jTsZ4taEJ7axYnarVBvX+QCXj6bWOFOEL/DScpKbm3FfG/RTYU4 BHTSOQIoGRpSZ5Q47znnUyil220PJRoWMphVY0rFrTaO0o2u3WbA2E+axQRrQHs3lK /y43m0Zx0lYUuDjHOeX5KG2mTQRDfmbFX6zKoDp4= From: Sinan Kaya To: linux-pci@vger.kernel.org Cc: Sinan Kaya , Bjorn Helgaas , Alex Williamson , Alexey Kardashevskiy , Peter Xu , "Gustavo A. R. Silva" , Eric Auger Subject: [PATCH 3/4] PCI: Expose reset type to users of pci_try_reset_function() Date: Sat, 8 Sep 2018 04:16:26 +0000 Message-Id: <20180908041632.22252-3-okaya@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180908041632.22252-1-okaya@kernel.org> References: <20180908041632.22252-1-okaya@kernel.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Looking to have more control between the users of the API vs. what the API can do internally. The new reset_type tells the PCI core about the bounds of the request. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 4 ++-- drivers/vfio/pci/vfio_pci.c | 7 ++++--- drivers/vfio/pci/vfio_pci_config.c | 4 ++-- include/linux/pci.h | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 89c45effb4f4..d319a2febe64 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4851,7 +4851,7 @@ EXPORT_SYMBOL_GPL(pci_reset_function_locked); * * Same as above, except return -EAGAIN if unable to lock device. */ -int pci_try_reset_function(struct pci_dev *dev) +int pci_try_reset_function(struct pci_dev *dev, u32 reset_type) { int rc; @@ -4862,7 +4862,7 @@ int pci_try_reset_function(struct pci_dev *dev) return -EAGAIN; pci_dev_save_and_disable(dev); - rc = __pci_reset_function_locked(dev, PCI_RESET_ANY); + rc = __pci_reset_function_locked(dev, reset_type); pci_dev_restore(dev); pci_dev_unlock(dev); diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index cddb453a1ba5..fe7ada997c51 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -228,7 +228,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev) return ret; /* If reset fails because of the device lock, fail this path entirely */ - ret = pci_try_reset_function(pdev); + ret = pci_try_reset_function(pdev, PCI_RESET_ANY); if (ret == -EAGAIN) { pci_disable_device(pdev); return ret; @@ -376,7 +376,7 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev) * Try to reset the device. The success of this is dependent on * being able to lock the device, which is not always possible. */ - if (vdev->reset_works && !pci_try_reset_function(pdev)) + if (vdev->reset_works && !pci_try_reset_function(pdev, PCI_RESET_ANY)) vdev->needs_reset = false; pci_restore_state(pdev); @@ -844,7 +844,8 @@ static long vfio_pci_ioctl(void *device_data, } else if (cmd == VFIO_DEVICE_RESET) { return vdev->reset_works ? - pci_try_reset_function(vdev->pdev) : -EINVAL; + pci_try_reset_function(vdev->pdev, PCI_RESET_ANY) : + -EINVAL; } else if (cmd == VFIO_DEVICE_GET_PCI_HOT_RESET_INFO) { struct vfio_pci_hot_reset_info hdr; diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index 115a36f6f403..0d66bac66211 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -831,7 +831,7 @@ static int vfio_exp_config_write(struct vfio_pci_device *vdev, int pos, &cap); if (!ret && (cap & PCI_EXP_DEVCAP_FLR)) - pci_try_reset_function(vdev->pdev); + pci_try_reset_function(vdev->pdev, PCI_RESET_ANY); } /* @@ -910,7 +910,7 @@ static int vfio_af_config_write(struct vfio_pci_device *vdev, int pos, &cap); if (!ret && (cap & PCI_AF_CAP_FLR) && (cap & PCI_AF_CAP_TP)) - pci_try_reset_function(vdev->pdev); + pci_try_reset_function(vdev->pdev, PCI_RESET_ANY); } return count; diff --git a/include/linux/pci.h b/include/linux/pci.h index fa852ebdf197..8652d7ac815c 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1125,7 +1125,7 @@ int pcie_flr(struct pci_dev *dev); int __pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); int pci_reset_function(struct pci_dev *dev, u32 reset_type); int pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); -int pci_try_reset_function(struct pci_dev *dev); +int pci_try_reset_function(struct pci_dev *dev, u32 reset_type); int pci_probe_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus); int pci_reset_bus(struct pci_dev *dev); From patchwork Sat Sep 8 04:16:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 967560 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="NjTdi92u"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 426gx96tznz9s9N for ; Sat, 8 Sep 2018 14:16:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726370AbeIHJBA (ORCPT ); Sat, 8 Sep 2018 05:01:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:59292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726283AbeIHJBA (ORCPT ); Sat, 8 Sep 2018 05:01:00 -0400 Received: from sinanubuntu1604.mkjiurmyylmellclgttazegk5f.bx.internal.cloudapp.net (unknown [40.76.195.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CCB3620844; Sat, 8 Sep 2018 04:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536380204; bh=WFt1YkCWihQhhEIIedqVowyeoGizttUWZEMA3xCFrew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjTdi92uoOj3HGWdCJtTUNVUWvSlevPUQh0mYSQ7moxj/+x+1B7bHvvC9RNmk2fBK gz6bCyaGZxkHnJdrb+pySQH98VoF1Xg2YZVxROhqKLtXm2ADcxh70aWkmtLgt10CTc NXVVandqCYA2MlBAqpRLOfixYSAtAwEmmgroscR0= From: Sinan Kaya To: linux-pci@vger.kernel.org Cc: Sinan Kaya , Bjorn Helgaas Subject: [PATCH 4/4] PCI: Expose reset type to users of pci_probe_reset_function() Date: Sat, 8 Sep 2018 04:16:27 +0000 Message-Id: <20180908041632.22252-4-okaya@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180908041632.22252-1-okaya@kernel.org> References: <20180908041632.22252-1-okaya@kernel.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Looking to have more control between the users of the API vs. what the API can do internally. The new reset_type tells the PCI core about the bounds of the request. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 51 ++++++++++++++++++++++++++++++--------------- drivers/pci/pci.h | 2 +- drivers/pci/probe.c | 2 +- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d319a2febe64..761c39f0b953 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4752,28 +4752,45 @@ EXPORT_SYMBOL_GPL(__pci_reset_function_locked); * Returns 0 if the device function can be reset or negative if the * device doesn't support resetting a single function. */ -int pci_probe_reset_function(struct pci_dev *dev) +int pci_probe_reset_function(struct pci_dev *dev, u32 reset_type) { - int rc; + int rc = 0; might_sleep(); - rc = pci_dev_specific_reset(dev, 1); - if (rc != -ENOTTY) - return rc; - if (pcie_has_flr(dev)) - return 0; - rc = pci_af_flr(dev, 1); - if (rc != -ENOTTY) - return rc; - rc = pci_pm_reset(dev, 1); - if (rc != -ENOTTY) - return rc; - rc = pci_dev_reset_slot_function(dev, 1); - if (rc != -ENOTTY) - return rc; + if (reset_type & PCI_RESET_DEV_SPECIFIC) { + rc = pci_dev_specific_reset(dev, 1); + if (rc != -ENOTTY) + return rc; + } + + if (reset_type & PCI_RESET_FLR) { + if (pcie_has_flr(dev)) + return 0; + rc = pci_af_flr(dev, 1); + if (rc != -ENOTTY) + return rc; + } - return pci_parent_bus_reset(dev, 1); + if (reset_type & PCI_RESET_PM) { + rc = pci_pm_reset(dev, 1); + if (rc != -ENOTTY) + return rc; + } + + if (reset_type & PCI_RESET_SLOT) { + rc = pci_dev_reset_slot_function(dev, 1); + if (rc != -ENOTTY) + return rc; + } + + if (reset_type & PCI_RESET_BUS) { + rc = pci_parent_bus_reset(dev, 1); + if (rc != -ENOTTY) + return rc; + } + + return rc; } /** diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 6e0d1528d471..0444bfa51b52 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -33,7 +33,7 @@ enum pci_mmap_api { int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vmai, enum pci_mmap_api mmap_api); -int pci_probe_reset_function(struct pci_dev *dev); +int pci_probe_reset_function(struct pci_dev *dev, u32 reset_type); int pci_bridge_secondary_bus_reset(struct pci_dev *dev); /** diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ec784009a36b..cbce5420431b 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2332,7 +2332,7 @@ static void pci_init_capabilities(struct pci_dev *dev) pcie_report_downtraining(dev); - if (pci_probe_reset_function(dev) == 0) + if (pci_probe_reset_function(dev, PCI_RESET_ANY) == 0) dev->reset_fn = 1; }