From patchwork Tue Dec 12 06:40:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 10106355 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DFE616032B for ; Tue, 12 Dec 2017 06:41:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D29A729AA4 for ; Tue, 12 Dec 2017 06:41:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C760829ABA; Tue, 12 Dec 2017 06:41:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 551E129AA4 for ; Tue, 12 Dec 2017 06:41:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751871AbdLLGlN (ORCPT ); Tue, 12 Dec 2017 01:41:13 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36650 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750955AbdLLGlM (ORCPT ); Tue, 12 Dec 2017 01:41:12 -0500 Received: by mail-wr0-f193.google.com with SMTP id v105so19913372wrc.3; Mon, 11 Dec 2017 22:41:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=OCT69MCxqHdddk47au6frtMbyEdjuZ5WKyKWGo1vxC4=; b=OJjxvq8/RO1jia0Ct+nV0SK5V+hBwhZoPtn/5IprQ2fZjFE4ufNnGHk5sKd2vLKKSH a+I9NP899OcF4bgYOeut7nrvHp6DTA4rdOGmnFwU4doQ8z6WWDIX+urw0Lv6ms1SRVkP yJR9jq+7ADm3vpNNZPTKABYwEyfue+7UM906ASfG11EsYcC6DjvALzAjDVl0qlL/3m67 v5hpm23zYCFhRe3DsFwjbrZVua5xawLXIL7ZBIaqjUrcQPTgrnhS6YCFUOTAjkxsWgse +uEv91KxjcJTa3NbSSk24qPDVs6K6RfQgspAT48AJD7TfdaCI/fP+rQRKz9zbf+zyfgs /ohw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=OCT69MCxqHdddk47au6frtMbyEdjuZ5WKyKWGo1vxC4=; b=ScgDEkUoLBMLyoDMHhqFpxNV1tyq7tW7XV1fWLRe95LTD/kIGD0tMly4vIJkaUd9Pz 6pMyColDNJp44OB1ZpC9kl7sYS7diFb2cl7E8TUW9K5BKIjozq8VdYiu34nzzOIW0QAr isgRfC5W23hlObAxnlM9A/qf6iMDiLa/mhHl2jvDJT/bt+rPigq2K4f3UVU5YnAoEhoE GyjVunu8aMPjzafTBGlP1AXl2mRvDX+xjUo16jC5zl7AoqMm2gjtM3azoq1Em3ZKit18 r+vyB+Dg5xneELpYeh5PL3BA03a6rwsTuiGiYzzPCtd7IuBngoMmgA5VFM3Znqtza31a 3Shw== X-Gm-Message-State: AKGB3mIsfrs/hgzT9Md0GXLXBnEXGMkFhMJjHeV8Jo89nx6Wo1r1UOQr qSJc/888BALjOrev1J8d2qdsBA== X-Google-Smtp-Source: ACJfBov4YpHtQGZ1cEWreawemKN4pbb2C6QJMFWdzOU3l+355MdDWj4OloMXGRIXD5M8o0hcBa3KxA== X-Received: by 10.223.139.73 with SMTP id v9mr2615995wra.77.1513060870778; Mon, 11 Dec 2017 22:41:10 -0800 (PST) Received: from ?IPv6:2003:ea:8bc0:e400:986e:3ed1:f25:ce7? (p200300EA8BC0E400986E3ED10F250CE7.dip0.t-ipconnect.de. [2003:ea:8bc0:e400:986e:3ed1:f25:ce7]) by smtp.googlemail.com with ESMTPSA id 56sm20894567wrx.73.2017.12.11.22.41.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 22:41:10 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v2 1/3] PCI: Add pcim_set_mwi(), a device-managed pci_set_mwi() To: Realtek linux nic maintainers , Bjorn Helgaas , David Miller Cc: "netdev@vger.kernel.org" , "linux-pci@vger.kernel.org" References: <36fa928b-e974-c023-de3e-c2bd05f53df2@gmail.com> Message-ID: Date: Tue, 12 Dec 2017 07:40:56 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <36fa928b-e974-c023-de3e-c2bd05f53df2@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add pcim_set_mwi(), a device-managed version of pci_set_mwi(). First user is the Realtek r8169 driver. Signed-off-by: Heiner Kallweit Acked-by: Bjorn Helgaas --- v2: - Reorder calls - Adjust and commit message --- drivers/pci/pci.c | 25 +++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 4a7c6864f..764ca7b88 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1458,6 +1458,7 @@ struct pci_devres { unsigned int pinned:1; unsigned int orig_intx:1; unsigned int restore_intx:1; + unsigned int mwi:1; u32 region_mask; }; @@ -1476,6 +1477,9 @@ static void pcim_release(struct device *gendev, void *res) if (this->region_mask & (1 << i)) pci_release_region(dev, i); + if (this->mwi) + pci_clear_mwi(dev); + if (this->restore_intx) pci_intx(dev, this->orig_intx); @@ -3760,6 +3764,27 @@ int pci_set_mwi(struct pci_dev *dev) } EXPORT_SYMBOL(pci_set_mwi); +/** + * pcim_set_mwi - a device-managed pci_set_mwi() + * @dev: the PCI device for which MWI is enabled + * + * Managed pci_set_mwi(). + * + * RETURNS: An appropriate -ERRNO error value on error, or zero for success. + */ +int pcim_set_mwi(struct pci_dev *dev) +{ + struct pci_devres *dr; + + dr = find_pci_dr(dev); + if (!dr) + return -ENOMEM; + + dr->mwi = 1; + return pci_set_mwi(dev); +} +EXPORT_SYMBOL(pcim_set_mwi); + /** * pci_try_set_mwi - enables memory-write-invalidate PCI transaction * @dev: the PCI device for which MWI is enabled diff --git a/include/linux/pci.h b/include/linux/pci.h index 978aad784..0a7ac863a 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1064,6 +1064,7 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); int pci_set_cacheline_size(struct pci_dev *dev); #define HAVE_PCI_SET_MWI int __must_check pci_set_mwi(struct pci_dev *dev); +int __must_check pcim_set_mwi(struct pci_dev *dev); int pci_try_set_mwi(struct pci_dev *dev); void pci_clear_mwi(struct pci_dev *dev); void pci_intx(struct pci_dev *dev, int enable);