Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/827104/?format=api
{ "id": 827104, "url": "http://patchwork.ozlabs.org/api/patches/827104/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20171017155001.318184-1-arnd@arndb.de/", "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": "<20171017155001.318184-1-arnd@arndb.de>", "list_archive_url": null, "date": "2017-10-17T15:49:48", "name": "[v2] i40e: avoid 64-bit division where possible", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "18414ed5e10ba339602beff469d4ea14739efea1", "submitter": { "id": 30, "url": "http://patchwork.ozlabs.org/api/people/30/?format=api", "name": "Arnd Bergmann", "email": "arnd@arndb.de" }, "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/20171017155001.318184-1-arnd@arndb.de/mbox/", "series": [ { "id": 8715, "url": "http://patchwork.ozlabs.org/api/series/8715/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=8715", "date": "2017-10-17T15:49:48", "name": "[v2] i40e: avoid 64-bit division where possible", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/8715/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/827104/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/827104/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@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" ], "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.138; helo=whitealder.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\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 3yGft43VxQz9t32\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 18 Oct 2017 02:55:39 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 0925087542;\n\tTue, 17 Oct 2017 15:55:38 +0000 (UTC)", "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id owE9wZJhKiyL; Tue, 17 Oct 2017 15:55:35 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 8986287519;\n\tTue, 17 Oct 2017 15:55:35 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 227C61C0359\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 17 Oct 2017 15:55:33 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id E5B552FDC7\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 17 Oct 2017 15:55:32 +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 IDA72PA9Cn-P for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 17 Oct 2017 15:55:30 +0000 (UTC)", "from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13])\n\tby silver.osuosl.org (Postfix) with ESMTPS id AAA6F2FDA8\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 17 Oct 2017 15:55:29 +0000 (UTC)", "from wuerfel.lan ([46.223.139.202]) by mrelayeu.kundenserver.de\n\t(mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id\n\t0McFi3-1dlZhT2bW3-00JWYr; Tue, 17 Oct 2017 17:50:04 +0200" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "delayed 00:05:10 by SQLgrey-1.7.6", "From": "Arnd Bergmann <arnd@arndb.de>", "To": "Jeff Kirsher <jeffrey.t.kirsher@intel.com>", "Date": "Tue, 17 Oct 2017 17:49:48 +0200", "Message-Id": "<20171017155001.318184-1-arnd@arndb.de>", "X-Mailer": "git-send-email 2.9.0", "X-Provags-ID": "V03:K0:jJQ7nZmcSySy6bHGzi0hT+yP4/fsBP62qcbD1OxWlmZmKYqAYwA\n\tveRpJNc/oeZ2BjMtzySEXSutu7GM2NjLppykJOkdUjAgeFSUNs1V21UD7kXdmuZK4SbDZS+\n\ts31L6AQdWJe3vPxRqbz6+FiUINE+2YVfE/rpQ1tYf8K7kEJhmHEDf7MDBknguIcSwgisW4e\n\tJX5nFpy7xOzo02IK/8+3A==", "X-UI-Out-Filterresults": "notjunk:1; V01:K0:KOj1hQxrLeM=:6KFS0Ta49wrEHW7EMGV9bc\n\tBsN3dQwHT17VcLykMMXRq78cQ8w9+18ybssDJLVUR0QNCRzaSOI2hgRSfs3akH5A01/Ay/V8f\n\tfk1wXqd8YC6HTSTCP6KJYT/QmK892d89M+zGJRNjLBgeYy/h6rbsLTYRvI5apMF4DDG5dQRQz\n\t9X7ZmiM3D7dym/hohsXnlZdWo3Y4YQLvDxxxgoggwhbsnNzCfcm5Jg2Jb/I/cC7IVgO+OhO3k\n\tx68uvFK3BjQEzicWkX38HSVOYOtUwoXgAQh4Q9yDL3fCibuEfXARssjfRxq5qNp2MlHLLlz7a\n\tJlXCON2Yb/RZ/TAqfQfFKVHIIWmOYF+lXM+z7mea1px0LUwEPwmg5dd221X1DbPs5PaAbK/Zy\n\tB2zg+0laqfKImU7moj/+E2lDaqI5LxIRyUleAtXwob1U4kGDCCA1X9elNTPJ12tmXLGx4lpJn\n\t3t3AsPcWsRLO9e2kcSyKOPBArUNStJ1iwUsd2jrav25GoPzAfm98pfNY/IOQIjJOj+opaRa5S\n\tRKhGLNg1yy3yjfEvhveDgiJlsAi5Tq/5v7R3n9wzfagabQ9jswVMbr7x9gjKrSHKTWxU4e9ku\n\tvL1OkYUh76kpWzUZqNGkJ06iGPnSdaZEBUUHPEFcQoi1D9iUsg4UglHTOfxUFLLnMD18YEFbl\n\t85KgCsoQgboPCp5CF1Uc7JegpQnwYWOZ+0cbAsRWdJPIoVVuFQrs6Uv/HAYM7wAsKcCv86Q7U\n\t3T9zDUG4zhFAmFb9aEmB3F3bQ5hvkhU+g/zgcw==", "Cc": "Arnd Bergmann <arnd@arndb.de>, netdev@vger.kernel.org, Mitch Williams\n\t<mitch.a.williams@intel.com>, linux-kernel@vger.kernel.org, \n\tintel-wired-lan@lists.osuosl.org, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?=\n\t<bjorn.topel@intel.com>, Filip Sadowski <filip.sadowski@intel.com>,\n\t\"David S. Miller\" <davem@davemloft.net>", "Subject": "[Intel-wired-lan] [PATCH] [v2] i40e: avoid 64-bit division where\n\tpossible", "X-BeenThere": "intel-wired-lan@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.osuosl.org>", "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>", "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@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@osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>" }, "content": "The new bandwidth calculation caused a link error on 32-bit\narchitectures, like\n\nERROR: \"__aeabi_uldivmod\" [drivers/net/ethernet/intel/i40e/i40e.ko] undefined!\n\nThe problem is the max_tx_rate calculation that uses 64-bit integers.\nThis is not really necessary since the numbers are in MBit/s so\nthey won't be higher than 40000 for the highest support rate, and\nare guaranteed to not exceed 2^32 in future generations either.\n\nAnother patch from Alan Brady fixed the link error by adding\nmany calls to do_div(), which makes the code less efficent and\nless readable than necessary.\n\nThis changes the representation to 'u32' when dealing with MBit/s\nand uses div_u64() to convert from u64 numbers in byte/s, reverting\nparts of Alan's earlier fix that have become obsolete now.\n\nFixes: 2027d4deacb1 (\"i40e: Add support setting TC max bandwidth rates\")\nFixes: 73983b5ae011 (\"i40e: fix u64 division usage\")\nCc: Alan Brady <alan.brady@intel.com>\nSigned-off-by: Arnd Bergmann <arnd@arndb.de>\n---\n drivers/net/ethernet/intel/i40e/i40e.h | 4 +-\n drivers/net/ethernet/intel/i40e/i40e_main.c | 70 +++++++++++------------------\n 2 files changed, 27 insertions(+), 47 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex c3f13120f3ce..c7aa0c982273 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -407,7 +407,7 @@ struct i40e_channel {\n \tu8 enabled_tc;\n \tstruct i40e_aqc_vsi_properties_data info;\n \n-\tu64 max_tx_rate;\n+\tu32 max_tx_rate; /* in Mbits/s */\n \n \t/* track this channel belongs to which VSI */\n \tstruct i40e_vsi *parent_vsi;\n@@ -1101,5 +1101,5 @@ static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi)\n }\n \n int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch);\n-int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate);\n+int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u32 max_tx_rate);\n #endif /* _I40E_H_ */\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex 3ceda140170d..57682cc78508 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -5448,17 +5448,16 @@ int i40e_get_link_speed(struct i40e_vsi *vsi)\n *\n * Helper function to set BW limit for a given VSI\n **/\n-int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate)\n+int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u32 max_tx_rate)\n {\n \tstruct i40e_pf *pf = vsi->back;\n-\tu64 credits = 0;\n \tint speed = 0;\n \tint ret = 0;\n \n \tspeed = i40e_get_link_speed(vsi);\n \tif (max_tx_rate > speed) {\n \t\tdev_err(&pf->pdev->dev,\n-\t\t\t\"Invalid max tx rate %llu specified for VSI seid %d.\",\n+\t\t\t\"Invalid max tx rate %u specified for VSI seid %d.\",\n \t\t\tmax_tx_rate, seid);\n \t\treturn -EINVAL;\n \t}\n@@ -5469,13 +5468,12 @@ int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate)\n \t}\n \n \t/* Tx rate credits are in values of 50Mbps, 0 is disabled */\n-\tcredits = max_tx_rate;\n-\tdo_div(credits, I40E_BW_CREDIT_DIVISOR);\n-\tret = i40e_aq_config_vsi_bw_limit(&pf->hw, seid, credits,\n+\tret = i40e_aq_config_vsi_bw_limit(&pf->hw, seid,\n+\t\t\t\t\t max_tx_rate / I40E_BW_CREDIT_DIVISOR,\n \t\t\t\t\t I40E_MAX_BW_INACTIVE_ACCUM, NULL);\n \tif (ret)\n \t\tdev_err(&pf->pdev->dev,\n-\t\t\t\"Failed set tx rate (%llu Mbps) for vsi->seid %u, err %s aq_err %s\\n\",\n+\t\t\t\"Failed set tx rate (%u Mbps) for vsi->seid %u, err %s aq_err %s\\n\",\n \t\t\tmax_tx_rate, seid, i40e_stat_str(&pf->hw, ret),\n \t\t\ti40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status));\n \treturn ret;\n@@ -6158,17 +6156,13 @@ int i40e_create_queue_channel(struct i40e_vsi *vsi,\n \n \t/* configure VSI for BW limit */\n \tif (ch->max_tx_rate) {\n-\t\tu64 credits = ch->max_tx_rate;\n-\n \t\tif (i40e_set_bw_limit(vsi, ch->seid, ch->max_tx_rate))\n \t\t\treturn -EINVAL;\n \n-\t\tdo_div(credits, I40E_BW_CREDIT_DIVISOR);\n \t\tdev_dbg(&pf->pdev->dev,\n-\t\t\t\"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\\n\",\n+\t\t\t\"Set tx rate of %u Mbps (count of 50Mbps %u) for vsi->seid %u\\n\",\n \t\t\tch->max_tx_rate,\n-\t\t\tcredits,\n-\t\t\tch->seid);\n+\t\t\tch->max_tx_rate / I40E_BW_CREDIT_DIVISOR, ch->seid);\n \t}\n \n \t/* in case of VF, this will be main SRIOV VSI */\n@@ -6189,7 +6183,6 @@ int i40e_create_queue_channel(struct i40e_vsi *vsi,\n static int i40e_configure_queue_channels(struct i40e_vsi *vsi)\n {\n \tstruct i40e_channel *ch;\n-\tu64 max_rate = 0;\n \tint ret = 0, i;\n \n \t/* Create app vsi with the TCs. Main VSI with TC0 is already set up */\n@@ -6211,9 +6204,8 @@ static int i40e_configure_queue_channels(struct i40e_vsi *vsi)\n \t\t\t/* Bandwidth limit through tc interface is in bytes/s,\n \t\t\t * change to Mbit/s\n \t\t\t */\n-\t\t\tmax_rate = vsi->mqprio_qopt.max_rate[i];\n-\t\t\tdo_div(max_rate, I40E_BW_MBPS_DIVISOR);\n-\t\t\tch->max_tx_rate = max_rate;\n+\t\t\tch->max_tx_rate = div_u64(vsi->mqprio_qopt.max_rate[i],\n+\t\t\t\t\t\t I40E_BW_CREDIT_DIVISOR);\n \n \t\t\tlist_add_tail(&ch->list, &vsi->ch_list);\n \n@@ -6643,7 +6635,6 @@ static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi,\n \t\t\t\t struct tc_mqprio_qopt_offload *mqprio_qopt)\n {\n \tu64 sum_max_rate = 0;\n-\tu64 max_rate = 0;\n \tint i;\n \n \tif (mqprio_qopt->qopt.offset[0] != 0 ||\n@@ -6658,9 +6649,8 @@ static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi,\n \t\t\t\t\"Invalid min tx rate (greater than 0) specified\\n\");\n \t\t\treturn -EINVAL;\n \t\t}\n-\t\tmax_rate = mqprio_qopt->max_rate[i];\n-\t\tdo_div(max_rate, I40E_BW_MBPS_DIVISOR);\n-\t\tsum_max_rate += max_rate;\n+\t\tsum_max_rate += div_u64(mqprio_qopt->max_rate[i],\n+\t\t\t\t\tI40E_BW_CREDIT_DIVISOR);\n \n \t\tif (i >= mqprio_qopt->qopt.num_tc - 1)\n \t\t\tbreak;\n@@ -6804,18 +6794,14 @@ static int i40e_setup_tc(struct net_device *netdev, void *type_data)\n \n \tif (pf->flags & I40E_FLAG_TC_MQPRIO) {\n \t\tif (vsi->mqprio_qopt.max_rate[0]) {\n-\t\t\tu64 max_tx_rate = vsi->mqprio_qopt.max_rate[0];\n-\n-\t\t\tdo_div(max_tx_rate, I40E_BW_MBPS_DIVISOR);\n+\t\t\tu32 max_tx_rate = div_u64(vsi->mqprio_qopt.max_rate[0],\n+\t\t\t\t\t\t I40E_BW_CREDIT_DIVISOR);\n \t\t\tret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);\n \t\t\tif (!ret) {\n-\t\t\t\tu64 credits = max_tx_rate;\n-\n-\t\t\t\tdo_div(credits, I40E_BW_CREDIT_DIVISOR);\n \t\t\t\tdev_dbg(&vsi->back->pdev->dev,\n-\t\t\t\t\t\"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\\n\",\n+\t\t\t\t\t\"Set tx rate of %u Mbps (count of 50Mbps %u) for vsi->seid %u\\n\",\n \t\t\t\t\tmax_tx_rate,\n-\t\t\t\t\tcredits,\n+\t\t\t\t\tmax_tx_rate / I40E_BW_CREDIT_DIVISOR,\n \t\t\t\t\tvsi->seid);\n \t\t\t} else {\n \t\t\t\tneed_reset = true;\n@@ -9024,15 +9010,12 @@ static int i40e_rebuild_channels(struct i40e_vsi *vsi)\n \t\t\treturn ret;\n \t\t}\n \t\tif (ch->max_tx_rate) {\n-\t\t\tu64 credits = ch->max_tx_rate;\n-\n \t\t\tif (i40e_set_bw_limit(vsi, ch->seid,\n \t\t\t\t\t ch->max_tx_rate))\n \t\t\t\treturn -EINVAL;\n \n-\t\t\tdo_div(credits, I40E_BW_CREDIT_DIVISOR);\n \t\t\tdev_dbg(&vsi->back->pdev->dev,\n-\t\t\t\t\"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\\n\",\n+\t\t\t\t\"Set tx rate of %u Mbps (count of 50Mbps %u) for vsi->seid %u\\n\",\n \t\t\t\tch->max_tx_rate,\n \t\t\t\tch->max_tx_rate / I40E_BW_CREDIT_DIVISOR,\n \t\t\t\tch->seid);\n@@ -9314,21 +9297,18 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)\n \t}\n \n \tif (vsi->mqprio_qopt.max_rate[0]) {\n-\t\tu64 max_tx_rate = vsi->mqprio_qopt.max_rate[0];\n-\t\tu64 credits = 0;\n+\t\tu32 max_tx_rate = div_u64(vsi->mqprio_qopt.max_rate[0],\n+\t\t\t\t\t I40E_BW_CREDIT_DIVISOR);\n \n-\t\tdo_div(max_tx_rate, I40E_BW_MBPS_DIVISOR);\n \t\tret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);\n-\t\tif (ret)\n+\t\tif (!ret)\n+\t\t\tdev_dbg(&vsi->back->pdev->dev,\n+\t\t\t\t\"Set tx rate of %u Mbps (count of 50Mbps %u) for vsi->seid %u\\n\",\n+\t\t\t\tmax_tx_rate,\n+\t\t\t\tmax_tx_rate / I40E_BW_CREDIT_DIVISOR,\n+\t\t\t\tvsi->seid);\n+\t\telse\n \t\t\tgoto end_unlock;\n-\n-\t\tcredits = max_tx_rate;\n-\t\tdo_div(credits, I40E_BW_CREDIT_DIVISOR);\n-\t\tdev_dbg(&vsi->back->pdev->dev,\n-\t\t\t\"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\\n\",\n-\t\t\tmax_tx_rate,\n-\t\t\tcredits,\n-\t\t\tvsi->seid);\n \t}\n \n \tret = i40e_rebuild_cloud_filters(vsi, vsi->seid);\n", "prefixes": [ "v2" ] }