get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/714712/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 714712,
    "url": "http://patchwork.ozlabs.org/api/patches/714712/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170112235942.5767-1-jacob.e.keller@intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170112235942.5767-1-jacob.e.keller@intel.com>",
    "list_archive_url": null,
    "date": "2017-01-12T23:59:38",
    "name": "[1/5] fm10k: use a BITMAP for flags to avoid race conditions",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f35ae85d8705ce54d0c4ea89141e00de8470c58b",
    "submitter": {
        "id": 9784,
        "url": "http://patchwork.ozlabs.org/api/people/9784/?format=api",
        "name": "Jacob Keller",
        "email": "jacob.e.keller@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170112235942.5767-1-jacob.e.keller@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/714712/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/714712/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@lists.osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Received": [
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3v02n757xhz9t0G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 13 Jan 2017 10:59:55 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 1126F84728;\n\tThu, 12 Jan 2017 23:59:54 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 7rWrLXC8xaLY; Thu, 12 Jan 2017 23:59:50 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 1115587813;\n\tThu, 12 Jan 2017 23:59:50 +0000 (UTC)",
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id E7F6B1BFF71\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Jan 2017 23:59:48 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id E2E662E122\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Jan 2017 23:59:48 +0000 (UTC)",
            "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id lB5kCVLiQkby for <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Jan 2017 23:59:44 +0000 (UTC)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby silver.osuosl.org (Postfix) with ESMTPS id C3A4F268F4\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Jan 2017 23:59:44 +0000 (UTC)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga101.fm.intel.com with ESMTP; 12 Jan 2017 15:59:44 -0800",
            "from jekeller-desk.amr.corp.intel.com ([10.166.35.174])\n\tby fmsmga001.fm.intel.com with ESMTP; 12 Jan 2017 15:59:44 -0800"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.33,220,1477983600\"; d=\"scan'208\";\n\ta=\"1093430199\"",
        "From": "Jacob Keller <jacob.e.keller@intel.com>",
        "To": "Intel Wired LAN <intel-wired-lan@lists.osuosl.org>",
        "Date": "Thu, 12 Jan 2017 15:59:38 -0800",
        "Message-Id": "<20170112235942.5767-1-jacob.e.keller@intel.com>",
        "X-Mailer": "git-send-email 2.11.0.403.g196674b8396b",
        "Subject": "[Intel-wired-lan] [PATCH 1/5] fm10k: use a BITMAP for flags to\n\tavoid race conditions",
        "X-BeenThere": "intel-wired-lan@lists.osuosl.org",
        "X-Mailman-Version": "2.1.18-1",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.lists.osuosl.org>",
        "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>",
        "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@lists.osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>"
    },
    "content": "Replace bitwise operators and #defines with a BITMAP and enumeration\nvalues. This is similar to how we handle the \"state\" values as well.\n\nThis has two distinct advantages over the old method. First, we ensure\ncorrectness of operations which are currently problematic due to race\nconditions. Suppose that two kernel threads are running, such as the\nwatchdog and an ethtool ioctl, and both modify flags. We'll say that the\nwatchdog is CPU A, and the ethtool ioctl is CPU B.\n\nCPU A sets FLAG_1, which can be seen as\n  CPU A read FLAGS\n  CPU A write FLAGS | FLAG_1\n\nCPU B sets FLAG_2, which can be seen as\n  CPU B read FLAGS\n  CPU A write FLAGS | FLAG_2\n\nHowever, \"|=\" and \"&=\" operators are not actually atomic. So this could\nbe ordered like the following:\n\nCPU A read FLAGS -> variable\nCPU B read FLAGS -> variable\nCPU A write FLAGS (variable | FLAG_1)\nCPU B write FLAGS (variable | FLAG_2)\n\nNotice how the 2nd write from CPU B could actually undo the write from\nCPU A because it isn't guaranteed that the |= operation is atomic.\n\nIn practice the race windows for most flag writes is incredibly narrow\nso it is not easy to isolate issues. However, the more flags we have,\nthe more likely they will cause problems. Additionally, if such\na problem were to arise, it would be incredibly difficult to track down.\n\nSecond, there is an additional advantage beyond code correctness. We can\nnow automatically size the BITMAP if more flags were added, so that we\ndo not need to remember that flags is u32 and thus if we added too many\nflags we would over-run the variable. This is not a likely occurrence\nfor fm10k driver, but this patch can serve as an example for other\ndrivers which have many more flags.\n\nThis particular change does have a bit of trouble converting some of the\nidioms previously used with the #defines for flags. Specifically, when\nconverting FM10K_FLAG_RSS_FIELD_IPV[46]_UDP flags. This whole operation\nwas actually quite problematic, because we actually stored flags\nseparately. This could more easily show the problem of the above\nre-ordering issue.\n\nThis is really difficult to test whether atomics make a difference in\npractical scenarios, but you can ensure that basic functionality remains\nthe same. This patch has a lot of code coverage, but most of it is\nrelatively simple.\n\nWhile we are modifying these files, update their copyright year.\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\n---\n drivers/net/ethernet/intel/fm10k/fm10k.h         | 27 ++++++++---\n drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 62 ++++++++++++++++--------\n drivers/net/ethernet/intel/fm10k/fm10k_main.c    |  6 +--\n drivers/net/ethernet/intel/fm10k/fm10k_netdev.c  |  4 +-\n drivers/net/ethernet/intel/fm10k/fm10k_pci.c     | 31 ++++++------\n 5 files changed, 82 insertions(+), 48 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/fm10k/fm10k.h b/drivers/net/ethernet/intel/fm10k/fm10k.h\nindex 52b979443cde..d6db1c48d4dc 100644\n--- a/drivers/net/ethernet/intel/fm10k/fm10k.h\n+++ b/drivers/net/ethernet/intel/fm10k/fm10k.h\n@@ -1,5 +1,5 @@\n /* Intel(R) Ethernet Switch Host Interface Driver\n- * Copyright(c) 2013 - 2016 Intel Corporation.\n+ * Copyright(c) 2013 - 2017 Intel Corporation.\n  *\n  * This program is free software; you can redistribute it and/or modify it\n  * under the terms and conditions of the GNU General Public License,\n@@ -249,6 +249,23 @@ struct fm10k_udp_port {\n /* one work queue for entire driver */\n extern struct workqueue_struct *fm10k_workqueue;\n \n+/* The following enumeration contains flags which indicate or enable modified\n+ * driver behaviors. To avoid race conditions, the flags are stored in\n+ * a BITMAP in the fm10k_intfc structure. The BITMAP should be accessed using\n+ * atomic *_bit() operations.\n+ */\n+enum fm10k_flags_t {\n+\tFM10K_FLAG_RESET_REQUESTED,\n+\tFM10K_FLAG_RSS_FIELD_IPV4_UDP,\n+\tFM10K_FLAG_RSS_FIELD_IPV6_UDP,\n+\tFM10K_FLAG_SWPRI_CONFIG,\n+\t/* __FM10K_FLAGS_SIZE__ is used to calculate the size of\n+\t * interface->flags and must be the last value in this\n+\t * enumeration.\n+\t */\n+\t__FM10K_FLAGS_SIZE__\n+};\n+\n struct fm10k_intfc {\n \tunsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];\n \tstruct net_device *netdev;\n@@ -256,11 +273,9 @@ struct fm10k_intfc {\n \tstruct pci_dev *pdev;\n \tunsigned long state;\n \n-\tu32 flags;\n-#define FM10K_FLAG_RESET_REQUESTED\t\t(u32)(BIT(0))\n-#define FM10K_FLAG_RSS_FIELD_IPV4_UDP\t\t(u32)(BIT(1))\n-#define FM10K_FLAG_RSS_FIELD_IPV6_UDP\t\t(u32)(BIT(2))\n-#define FM10K_FLAG_SWPRI_CONFIG\t\t\t(u32)(BIT(3))\n+\t/* Access flag values using atomic *_bit() operations */\n+\tDECLARE_BITMAP(flags, __FM10K_FLAGS_SIZE__);\n+\n \tint xcast_mode;\n \n \t/* Tx fast path data */\ndiff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c\nindex 0c84fef750f4..557966749174 100644\n--- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c\n+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c\n@@ -1,5 +1,5 @@\n /* Intel(R) Ethernet Switch Host Interface Driver\n- * Copyright(c) 2013 - 2016 Intel Corporation.\n+ * Copyright(c) 2013 - 2017 Intel Corporation.\n  *\n  * This program is free software; you can redistribute it and/or modify it\n  * under the terms and conditions of the GNU General Public License,\n@@ -716,7 +716,8 @@ static int fm10k_get_rss_hash_opts(struct fm10k_intfc *interface,\n \t\tcmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;\n \t\t/* fall through */\n \tcase UDP_V4_FLOW:\n-\t\tif (interface->flags & FM10K_FLAG_RSS_FIELD_IPV4_UDP)\n+\t\tif (test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,\n+\t\t\t     interface->flags))\n \t\t\tcmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;\n \t\t/* fall through */\n \tcase SCTP_V4_FLOW:\n@@ -732,7 +733,8 @@ static int fm10k_get_rss_hash_opts(struct fm10k_intfc *interface,\n \t\tcmd->data |= RXH_IP_SRC | RXH_IP_DST;\n \t\tbreak;\n \tcase UDP_V6_FLOW:\n-\t\tif (interface->flags & FM10K_FLAG_RSS_FIELD_IPV6_UDP)\n+\t\tif (test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,\n+\t\t\t     interface->flags))\n \t\t\tcmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;\n \t\tcmd->data |= RXH_IP_SRC | RXH_IP_DST;\n \t\tbreak;\n@@ -764,12 +766,13 @@ static int fm10k_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,\n \treturn ret;\n }\n \n-#define UDP_RSS_FLAGS (FM10K_FLAG_RSS_FIELD_IPV4_UDP | \\\n-\t\t       FM10K_FLAG_RSS_FIELD_IPV6_UDP)\n static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,\n \t\t\t\t  struct ethtool_rxnfc *nfc)\n {\n-\tu32 flags = interface->flags;\n+\tint rss_ipv4_udp = test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,\n+\t\t\t\t    interface->flags);\n+\tint rss_ipv6_udp = test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,\n+\t\t\t\t    interface->flags);\n \n \t/* RSS does not support anything other than hashing\n \t * to queues on src and dst IPs and ports\n@@ -793,10 +796,12 @@ static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,\n \t\t\treturn -EINVAL;\n \t\tswitch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {\n \t\tcase 0:\n-\t\t\tflags &= ~FM10K_FLAG_RSS_FIELD_IPV4_UDP;\n+\t\t\tclear_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,\n+\t\t\t\t  interface->flags);\n \t\t\tbreak;\n \t\tcase (RXH_L4_B_0_1 | RXH_L4_B_2_3):\n-\t\t\tflags |= FM10K_FLAG_RSS_FIELD_IPV4_UDP;\n+\t\t\tset_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,\n+\t\t\t\tinterface->flags);\n \t\t\tbreak;\n \t\tdefault:\n \t\t\treturn -EINVAL;\n@@ -808,10 +813,12 @@ static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,\n \t\t\treturn -EINVAL;\n \t\tswitch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {\n \t\tcase 0:\n-\t\t\tflags &= ~FM10K_FLAG_RSS_FIELD_IPV6_UDP;\n+\t\t\tclear_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,\n+\t\t\t\t  interface->flags);\n \t\t\tbreak;\n \t\tcase (RXH_L4_B_0_1 | RXH_L4_B_2_3):\n-\t\t\tflags |= FM10K_FLAG_RSS_FIELD_IPV6_UDP;\n+\t\t\tset_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,\n+\t\t\t\tinterface->flags);\n \t\t\tbreak;\n \t\tdefault:\n \t\t\treturn -EINVAL;\n@@ -835,28 +842,41 @@ static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,\n \t\treturn -EINVAL;\n \t}\n \n-\t/* if we changed something we need to update flags */\n-\tif (flags != interface->flags) {\n+\t/* If something changed we need to update the MRQC register. Note that\n+\t * test_bit() is guaranteed to return strictly 0 or 1, so testing for\n+\t * equality is safe.\n+\t */\n+\tif ((rss_ipv4_udp != test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,\n+\t\t\t\t      interface->flags)) ||\n+\t    (rss_ipv6_udp != test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,\n+\t\t\t\t      interface->flags))) {\n \t\tstruct fm10k_hw *hw = &interface->hw;\n+\t\tbool warn = false;\n \t\tu32 mrqc;\n \n-\t\tif ((flags & UDP_RSS_FLAGS) &&\n-\t\t    !(interface->flags & UDP_RSS_FLAGS))\n-\t\t\tnetif_warn(interface, drv, interface->netdev,\n-\t\t\t\t   \"enabling UDP RSS: fragmented packets may arrive out of order to the stack above\\n\");\n-\n-\t\tinterface->flags = flags;\n-\n \t\t/* Perform hash on these packet types */\n \t\tmrqc = FM10K_MRQC_IPV4 |\n \t\t       FM10K_MRQC_TCP_IPV4 |\n \t\t       FM10K_MRQC_IPV6 |\n \t\t       FM10K_MRQC_TCP_IPV6;\n \n-\t\tif (flags & FM10K_FLAG_RSS_FIELD_IPV4_UDP)\n+\t\tif (test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,\n+\t\t\t     interface->flags)) {\n \t\t\tmrqc |= FM10K_MRQC_UDP_IPV4;\n-\t\tif (flags & FM10K_FLAG_RSS_FIELD_IPV6_UDP)\n+\t\t\twarn = true;\n+\t\t}\n+\t\tif (test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,\n+\t\t\t     interface->flags)) {\n \t\t\tmrqc |= FM10K_MRQC_UDP_IPV6;\n+\t\t\twarn = true;\n+\t\t}\n+\n+\t\t/* If we enable UDP RSS display a warning that this may cause\n+\t\t * fragmented UDP packets to arrive out of order.\n+\t\t */\n+\t\tif (warn)\n+\t\t\tnetif_warn(interface, drv, interface->netdev,\n+\t\t\t\t   \"enabling UDP RSS: fragmented packets may arrive out of order to the stack above\\n\");\n \n \t\tfm10k_write_reg(hw, FM10K_MRQC(0), mrqc);\n \t}\ndiff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c\nindex 5bb233a9614c..f9612a6b8524 100644\n--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c\n+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c\n@@ -1,5 +1,5 @@\n /* Intel(R) Ethernet Switch Host Interface Driver\n- * Copyright(c) 2013 - 2016 Intel Corporation.\n+ * Copyright(c) 2013 - 2017 Intel Corporation.\n  *\n  * This program is free software; you can redistribute it and/or modify it\n  * under the terms and conditions of the GNU General Public License,\n@@ -34,7 +34,7 @@ const char fm10k_driver_version[] = DRV_VERSION;\n char fm10k_driver_name[] = \"fm10k\";\n static const char fm10k_driver_string[] = DRV_SUMMARY;\n static const char fm10k_copyright[] =\n-\t\"Copyright (c) 2013 - 2016 Intel Corporation.\";\n+\t\"Copyright(c) 2013 - 2017 Intel Corporation.\";\n \n MODULE_AUTHOR(\"Intel Corporation, <linux.nics@intel.com>\");\n MODULE_DESCRIPTION(DRV_SUMMARY);\n@@ -1193,7 +1193,7 @@ void fm10k_tx_timeout_reset(struct fm10k_intfc *interface)\n \t/* Do the reset outside of interrupt context */\n \tif (!test_bit(__FM10K_DOWN, &interface->state)) {\n \t\tinterface->tx_timeout_count++;\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n \t\tfm10k_service_event_schedule(interface);\n \t}\n }\ndiff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c\nindex 01db688cf539..0d220f1ab5d0 100644\n--- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c\n+++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c\n@@ -1,5 +1,5 @@\n /* Intel(R) Ethernet Switch Host Interface Driver\n- * Copyright(c) 2013 - 2016 Intel Corporation.\n+ * Copyright(c) 2013 - 2017 Intel Corporation.\n  *\n  * This program is free software; you can redistribute it and/or modify it\n  * under the terms and conditions of the GNU General Public License,\n@@ -1207,7 +1207,7 @@ int fm10k_setup_tc(struct net_device *dev, u8 tc)\n \t\tgoto err_open;\n \n \t/* flag to indicate SWPRI has yet to be updated */\n-\tinterface->flags |= FM10K_FLAG_SWPRI_CONFIG;\n+\tset_bit(FM10K_FLAG_SWPRI_CONFIG, interface->flags);\n \n \treturn 0;\n err_open:\ndiff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c\nindex e372a5823480..8fe4f861e195 100644\n--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c\n+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c\n@@ -1,5 +1,5 @@\n /* Intel(R) Ethernet Switch Host Interface Driver\n- * Copyright(c) 2013 - 2016 Intel Corporation.\n+ * Copyright(c) 2013 - 2017 Intel Corporation.\n  *\n  * This program is free software; you can redistribute it and/or modify it\n  * under the terms and conditions of the GNU General Public License,\n@@ -136,7 +136,7 @@ static void fm10k_detach_subtask(struct fm10k_intfc *interface)\n \tif (~value) {\n \t\tinterface->hw.hw_addr = interface->uc_addr;\n \t\tnetif_device_attach(netdev);\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n \t\tnetdev_warn(netdev, \"PCIe link restored, device now attached\\n\");\n \t\treturn;\n \t}\n@@ -272,11 +272,10 @@ static void fm10k_reinit(struct fm10k_intfc *interface)\n \n static void fm10k_reset_subtask(struct fm10k_intfc *interface)\n {\n-\tif (!(interface->flags & FM10K_FLAG_RESET_REQUESTED))\n+\tif (!test_and_clear_bit(FM10K_FLAG_RESET_REQUESTED,\n+\t\t\t\tinterface->flags))\n \t\treturn;\n \n-\tinterface->flags &= ~FM10K_FLAG_RESET_REQUESTED;\n-\n \tnetdev_err(interface->netdev, \"Reset interface\\n\");\n \n \tfm10k_reinit(interface);\n@@ -295,7 +294,7 @@ static void fm10k_configure_swpri_map(struct fm10k_intfc *interface)\n \tint i;\n \n \t/* clear flag indicating update is needed */\n-\tinterface->flags &= ~FM10K_FLAG_SWPRI_CONFIG;\n+\tclear_bit(FM10K_FLAG_SWPRI_CONFIG, interface->flags);\n \n \t/* these registers are only available on the PF */\n \tif (hw->mac.type != fm10k_mac_pf)\n@@ -323,7 +322,7 @@ static void fm10k_watchdog_update_host_state(struct fm10k_intfc *interface)\n \t\tclear_bit(__FM10K_LINK_DOWN, &interface->state);\n \t}\n \n-\tif (interface->flags & FM10K_FLAG_SWPRI_CONFIG) {\n+\tif (test_bit(FM10K_FLAG_SWPRI_CONFIG, interface->flags)) {\n \t\tif (rtnl_trylock()) {\n \t\t\tfm10k_configure_swpri_map(interface);\n \t\t\trtnl_unlock();\n@@ -335,7 +334,7 @@ static void fm10k_watchdog_update_host_state(struct fm10k_intfc *interface)\n \n \terr = hw->mac.ops.get_host_state(hw, &interface->host_ready);\n \tif (err && time_is_before_jiffies(interface->last_reset))\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n \n \t/* free the lock */\n \tfm10k_mbx_unlock(interface);\n@@ -522,7 +521,7 @@ static void fm10k_watchdog_flush_tx(struct fm10k_intfc *interface)\n \t * controller to flush Tx.\n \t */\n \tif (some_tx_pending)\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n }\n \n /**\n@@ -863,9 +862,9 @@ static void fm10k_configure_dglort(struct fm10k_intfc *interface)\n \t       FM10K_MRQC_IPV6 |\n \t       FM10K_MRQC_TCP_IPV6;\n \n-\tif (interface->flags & FM10K_FLAG_RSS_FIELD_IPV4_UDP)\n+\tif (test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP, interface->flags))\n \t\tmrqc |= FM10K_MRQC_UDP_IPV4;\n-\tif (interface->flags & FM10K_FLAG_RSS_FIELD_IPV6_UDP)\n+\tif (test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP, interface->flags))\n \t\tmrqc |= FM10K_MRQC_UDP_IPV6;\n \n \tfm10k_write_reg(hw, FM10K_MRQC(0), mrqc);\n@@ -1167,7 +1166,7 @@ static irqreturn_t fm10k_msix_mbx_pf(int __always_unused irq, void *data)\n \t}\n \n \tif (err == FM10K_ERR_RESET_REQUESTED)\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n \n \t/* if switch toggled state we should reset GLORTs */\n \tif (eicr & FM10K_EICR_SWITCHNOTREADY) {\n@@ -1246,12 +1245,12 @@ static s32 fm10k_mbx_mac_addr(struct fm10k_hw *hw, u32 **results,\n \t/* MAC was changed so we need reset */\n \tif (is_valid_ether_addr(hw->mac.perm_addr) &&\n \t    !ether_addr_equal(hw->mac.perm_addr, hw->mac.addr))\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n \n \t/* VLAN override was changed, or default VLAN changed */\n \tif ((vlan_override != hw->mac.vlan_override) ||\n \t    (default_vid != hw->mac.default_vid))\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n \n \treturn 0;\n }\n@@ -1356,7 +1355,7 @@ static s32 fm10k_lport_map(struct fm10k_hw *hw, u32 **results,\n \n \t/* we need to reset if port count was just updated */\n \tif (dglort_map != hw->mac.dglort_map)\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n \n \treturn 0;\n }\n@@ -1395,7 +1394,7 @@ static s32 fm10k_update_pvid(struct fm10k_hw *hw, u32 **results,\n \n \t/* we need to reset if default VLAN was just updated */\n \tif (pvid != hw->mac.default_vid)\n-\t\tinterface->flags |= FM10K_FLAG_RESET_REQUESTED;\n+\t\tset_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);\n \n \thw->mac.default_vid = pvid;\n \n",
    "prefixes": [
        "1/5"
    ]
}