Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/611258/?format=api
{ "id": 611258, "url": "http://patchwork.ozlabs.org/api/patches/611258/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20160415224127.4172-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": "<20160415224127.4172-1-jacob.e.keller@intel.com>", "list_archive_url": null, "date": "2016-04-15T22:41:27", "name": "[v3] e1000e: don't modify SYSTIM registers during SIOCSHWTSTAMP ioctl", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "5a9698773af9bb08e69593b227e77a7cdba5dd05", "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/20160415224127.4172-1-jacob.e.keller@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/611258/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/611258/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\tby ozlabs.org (Postfix) with ESMTP id 3qmswK331Sz9t3Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 16 Apr 2016 08:41:36 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id B3A9EC0413;\n\tFri, 15 Apr 2016 22:41:35 +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 GBADHtDAJ3IP; Fri, 15 Apr 2016 22:41:34 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 71EFFC0403;\n\tFri, 15 Apr 2016 22:41:34 +0000 (UTC)", "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 36DD21C116E\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 15 Apr 2016 22:41:33 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 2F949C0404\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 15 Apr 2016 22:41:33 +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 XQtH4CLLkhnt for <intel-wired-lan@lists.osuosl.org>;\n\tFri, 15 Apr 2016 22:41:32 +0000 (UTC)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 7AC77C0403\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 15 Apr 2016 22:41:32 +0000 (UTC)", "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga102.jf.intel.com with ESMTP; 15 Apr 2016 15:41:31 -0700", "from jekeller-desk.amr.corp.intel.com (HELO\n\tjekeller-desk.jekeller.internal) ([134.134.3.173])\n\tby orsmga003.jf.intel.com with ESMTP; 15 Apr 2016 15:41:31 -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,489,1455004800\"; d=\"scan'208\";a=\"785922231\"", "From": "Jacob Keller <jacob.e.keller@intel.com>", "To": "Intel Wired LAN <intel-wired-lan@lists.osuosl.org>,\n\tBrian Walsh <brian@walsh.ws>", "Date": "Fri, 15 Apr 2016 15:41:27 -0700", "Message-Id": "<20160415224127.4172-1-jacob.e.keller@intel.com>", "X-Mailer": "git-send-email 2.8.1.369.geae769a", "Subject": "[Intel-wired-lan] [PATCH v3] 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>\n---\n\n3rd time's a charm? This time I verified it should compile and run now,\nwithout crashes, and without compilation errors.\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 (who WROTE THIS CODE?!?!??!! ;)\n\n drivers/net/ethernet/intel/e1000e/e1000.h | 1 +\n drivers/net/ethernet/intel/e1000e/netdev.c | 65 ++++++++++++++++++++++--------\n drivers/net/ethernet/intel/e1000e/ptp.c | 2 +\n 3 files changed, 52 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..a272ad9f8029 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@@ -3885,6 +3874,50 @@ static void e1000_flush_desc_rings(struct e1000_adapter *adapter)\n }\n \n /**\n+ * e1000e_ptp_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_ptp_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 (info->adjfreq) {\n+\t\t/* restore the previous ptp frequency delta */\n+\t\tret_val = info->adjfreq(info, adapter->ptp_delta);\n+\t\tif (ret_val)\n+\t\t\tdev_warn(&adapter->pdev->dev,\n+\t\t\t\t \"Failed to restore TIMINCA clock rate delta: %d\\n\",\n+\t\t\t\t ret_val);\n+\t} else {\n+\t\tret_val = e1000e_get_base_timinca(adapter, &timinca);\n+\t\tif (ret_val)\n+\t\t\tdev_warn(&adapter->pdev->dev,\n+\t\t\t\t \"Failed to set default TIMINCA clock rate: %d\\n\",\n+\t\t\t\t ret_val);\n+\t\telse\n+\t\t\tew32(TIMINCA, timinca);\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 * This function boots the hardware and enables some settings that\n@@ -4063,8 +4096,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_ptp_reset(adapter);\n \n \t/* Set EEE advertisement as appropriate */\n \tif (adapter->flags2 & FLAG2_HAS_EEE) {\n@@ -7238,6 +7271,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 +7292,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": [ "v3" ] }