Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/612809/?format=api
{ "id": 612809, "url": "http://patchwork.ozlabs.org/api/patches/612809/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20160420183642.29050-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": "<20160420183642.29050-1-jacob.e.keller@intel.com>", "list_archive_url": null, "date": "2016-04-20T18:36:42", "name": "[v4] e1000e: don't modify SYSTIM registers during SIOCSHWTSTAMP ioctl", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8f77fc52fb712767644b868d102bbfbee4fb4cc8", "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/20160420183642.29050-1-jacob.e.keller@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/612809/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/612809/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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ozlabs.org (Postfix) with ESMTP id 3qqrFk54xdz9t0t\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Apr 2016 04:36:58 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id D8E4F95A46;\n\tWed, 20 Apr 2016 18:36:56 +0000 (UTC)", "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id i9nywHkoI7zN; Wed, 20 Apr 2016 18:36:55 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id A3FFB95843;\n\tWed, 20 Apr 2016 18:36:55 +0000 (UTC)", "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id 1B8E01C0614\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 20 Apr 2016 18:36:54 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 7614A956EB\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 20 Apr 2016 18:36:46 +0000 (UTC)", "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id MJ8OAtvkrGZx for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 20 Apr 2016 18:36:45 +0000 (UTC)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 626E59545B\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 20 Apr 2016 18:36:45 +0000 (UTC)", "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga103.fm.intel.com with ESMTP; 20 Apr 2016 11:36:44 -0700", "from jekeller-desk.amr.corp.intel.com (HELO\n\tjekeller-desk.jekeller.internal) ([134.134.3.173])\n\tby orsmga001.jf.intel.com with ESMTP; 20 Apr 2016 11:36:45 -0700" ], "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.24,510,1455004800\"; d=\"scan'208\";a=\"936649121\"", "From": "Jacob Keller <jacob.e.keller@intel.com>", "To": "Jeffrey Kirsher <jeffrey.t.kirsher@intel.com>,\n\tIntel Wired LAN <intel-wired-lan@lists.osuosl.org>", "Date": "Wed, 20 Apr 2016 11:36:42 -0700", "Message-Id": "<20160420183642.29050-1-jacob.e.keller@intel.com>", "X-Mailer": "git-send-email 2.8.1.493.g7b22612", "Subject": "[Intel-wired-lan] [PATCH v4] e1000e: don't modify SYSTIM registers\n\tduring SIOCSHWTSTAMP ioctl", "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": "The e1000e_config_hwtstamp function was incorrectly resetting the SYSTIM\nregisters every time the ioctl was being run. If you happened to be\nrunning ptp4l and lost the PTP connect (removing cable, or blocking the\nUDP traffic for example), then ptp4l will eventually perform a restart\nwhich involves re-requesting timestamp settings. In e1000e this has the\nunfortunate and incorrect result of resetting SYSTIME to the kernel\ntime. Since kernel time is usually in UTC, and PTP time is in TAI, this\nresults in the leap second being re-applied.\n\nFix this by extracting the SYSTIME reset out into its own function,\ne1000e_ptp_reset, which we call during reset to restore the hardware\nregisters. This function will (a) restart the timecounter based on the\nnew system time, (b) restore the previous PPB setting, and (c) restore\nthe previous hwtstamp settings.\n\nIn order to perform (b), I had to modify the adjfreq ptp function\npointer to store the old delta each time it is called. This also has the\nside effect of restoring the correct base timinca register correctly.\nThe driver does not need to explicitly zero the ptp_delta variable since\nthe entire adapter structure comes zero-initialized.\n\nReported-by: Brian Walsh <brian@walsh.ws>\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\nTested-by: Brian Walsh <brian@walsh.ws>\n---\n\nNotes:\n This patch conflicts with Brian's \"e1000e fix ptp time reset on newtork\n interruption\", and that patch MUST be removed from the queue before applying\n this one.\n \n - Changes since v1\n * move e1000e_init_ptp prior to reset so that PTP clock is created first\n * handle NULL ptp_clock_info gracefully.\n \n - Changes since v2\n * fix stupid compilation error\n * fix stupid null pointer check\n \n - Changes since v3\n * fix issue when using part that doesn't support hw timestamping\n * rename e1000e_ptp_reset to more apt e1000e_systim_reset\n * refactor code a little to reduce duplicate warning and improve readability\n\n drivers/net/ethernet/intel/e1000e/e1000.h | 1 +\n drivers/net/ethernet/intel/e1000e/netdev.c | 68 +++++++++++++++++++++++-------\n drivers/net/ethernet/intel/e1000e/ptp.c | 2 +\n 3 files changed, 55 insertions(+), 16 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h\nindex 010e6d61c855..ef96cd11d6d2 100644\n--- a/drivers/net/ethernet/intel/e1000e/e1000.h\n+++ b/drivers/net/ethernet/intel/e1000e/e1000.h\n@@ -347,6 +347,7 @@ struct e1000_adapter {\n \tstruct ptp_clock *ptp_clock;\n \tstruct ptp_clock_info ptp_clock_info;\n \tstruct pm_qos_request pm_qos_req;\n+\ts32 ptp_delta;\n \n \tu16 eee_advert;\n };\ndiff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c\nindex 50d2684ac146..02e28581dcad 100644\n--- a/drivers/net/ethernet/intel/e1000e/netdev.c\n+++ b/drivers/net/ethernet/intel/e1000e/netdev.c\n@@ -3580,7 +3580,6 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,\n \tbool is_l4 = false;\n \tbool is_l2 = false;\n \tu32 regval;\n-\ts32 ret_val;\n \n \tif (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))\n \t\treturn -EINVAL;\n@@ -3719,16 +3718,6 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,\n \ter32(RXSTMPH);\n \ter32(TXSTMPH);\n \n-\t/* Get and set the System Time Register SYSTIM base frequency */\n-\tret_val = e1000e_get_base_timinca(adapter, ®val);\n-\tif (ret_val)\n-\t\treturn ret_val;\n-\tew32(TIMINCA, regval);\n-\n-\t/* reset the ns time counter */\n-\ttimecounter_init(&adapter->tc, &adapter->cc,\n-\t\t\t ktime_to_ns(ktime_get_real()));\n-\n \treturn 0;\n }\n \n@@ -3884,6 +3873,53 @@ static void e1000_flush_desc_rings(struct e1000_adapter *adapter)\n \t\te1000_flush_rx_ring(adapter);\n }\n \n+/**\n+ * e1000e_systim_reset - reset the timesync registers after a hardware reset\n+ * @adapter: board private structure\n+ *\n+ * When the MAC is reset, all hardware bits for timesync will be reset to the\n+ * default values. This function will restore the settings last in place.\n+ * Since the clock SYSTIME registers are reset, we will simply restore the\n+ * cyclecounter to the kernel real clock time.\n+ **/\n+static void e1000e_systim_reset(struct e1000_adapter *adapter)\n+{\n+\tstruct ptp_clock_info *info = &adapter->ptp_clock_info;\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tunsigned long flags;\n+\tu32 timinca;\n+\ts32 ret_val;\n+\n+\tif (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))\n+\t\treturn;\n+\n+\tif (info->adjfreq) {\n+\t\t/* restore the previous ptp frequency delta */\n+\t\tret_val = info->adjfreq(info, adapter->ptp_delta);\n+\t} else {\n+\t\t/* set the default base frequency if no adjustment possible */\n+\t\tret_val = e1000e_get_base_timinca(adapter, &timinca);\n+\t\tif (!ret_val)\n+\t\t\tew32(TIMINCA, timinca);\n+\t}\n+\n+\tif (ret_val) {\n+\t\tdev_warn(&adapter->pdev->dev,\n+\t\t\t \"Failed to restore TIMINCA clock rate delta: %d\\n\",\n+\t\t\t ret_val);\n+\t\treturn;\n+\t}\n+\n+\t/* reset the systim ns time counter */\n+\tspin_lock_irqsave(&adapter->systim_lock, flags);\n+\ttimecounter_init(&adapter->tc, &adapter->cc,\n+\t\t\t ktime_to_ns(ktime_get_real()));\n+\tspin_unlock_irqrestore(&adapter->systim_lock, flags);\n+\n+\t/* restore the previous hwtstamp configuration settings */\n+\te1000e_config_hwtstamp(adapter, &adapter->hwtstamp_config);\n+}\n+\n /**\n * e1000e_reset - bring the hardware into a known good state\n *\n@@ -4063,8 +4099,8 @@ void e1000e_reset(struct e1000_adapter *adapter)\n \n \te1000e_reset_adaptive(hw);\n \n-\t/* initialize systim and reset the ns time counter */\n-\te1000e_config_hwtstamp(adapter, &adapter->hwtstamp_config);\n+\t/* restore systim and hwtstamp settings */\n+\te1000e_systim_reset(adapter);\n \n \t/* Set EEE advertisement as appropriate */\n \tif (adapter->flags2 & FLAG2_HAS_EEE) {\n@@ -7238,6 +7274,9 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t\tadapter->eeprom_vers = 0;\n \t}\n \n+\t/* init PTP hardware clock */\n+\te1000e_ptp_init(adapter);\n+\n \t/* reset the hardware with the new settings */\n \te1000e_reset(adapter);\n \n@@ -7256,9 +7295,6 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t/* carrier off reporting is important to ethtool even BEFORE open */\n \tnetif_carrier_off(netdev);\n \n-\t/* init PTP hardware clock */\n-\te1000e_ptp_init(adapter);\n-\n \te1000_print_device_info(adapter);\n \n \tif (pci_dev_run_wake(pdev))\ndiff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c\nindex e2ff3ef75d5d..2e1b17ad52a3 100644\n--- a/drivers/net/ethernet/intel/e1000e/ptp.c\n+++ b/drivers/net/ethernet/intel/e1000e/ptp.c\n@@ -79,6 +79,8 @@ static int e1000e_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta)\n \n \tew32(TIMINCA, timinca);\n \n+\tadapter->ptp_delta = delta;\n+\n \tspin_unlock_irqrestore(&adapter->systim_lock, flags);\n \n \treturn 0;\n", "prefixes": [ "v4" ] }