get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 567106,
    "url": "http://patchwork.ozlabs.org/api/patches/567106/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1452687149-11281-3-git-send-email-christopher.s.hall@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": "<1452687149-11281-3-git-send-email-christopher.s.hall@intel.com>",
    "list_archive_url": null,
    "date": "2016-01-13T12:12:22",
    "name": "[v6,2/9] Add driver cross timestamp interface for higher precision time synchronization",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c4cd20fae7e1be631715dcdc301360427f32dd33",
    "submitter": {
        "id": 66720,
        "url": "http://patchwork.ozlabs.org/api/people/66720/?format=api",
        "name": "Hall, Christopher S",
        "email": "christopher.s.hall@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/1452687149-11281-3-git-send-email-christopher.s.hall@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/567106/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/567106/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 222BD140297\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Jan 2016 06:18:43 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 59F7C94660;\n\tWed, 13 Jan 2016 19:18:42 +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 Fq2fqRkWcTM9; Wed, 13 Jan 2016 19:18:39 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 4912293EBF;\n\tWed, 13 Jan 2016 19:18:39 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id 668711C0F8E\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 13 Jan 2016 19:18:37 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 976218C969\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 13 Jan 2016 19:18:36 +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 ODPBd9IJs6xR for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 13 Jan 2016 19:18:35 +0000 (UTC)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 6EC448C942\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 13 Jan 2016 19:18:35 +0000 (UTC)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga102.fm.intel.com with ESMTP; 13 Jan 2016 11:18:36 -0800",
            "from foofoo.jf.intel.com (HELO localhost.localdomain)\n\t([134.134.172.151])\n\tby FMSMGA003.fm.intel.com with ESMTP; 13 Jan 2016 11:18:35 -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.22,290,1449561600\"; d=\"scan'208\";a=\"632939082\"",
        "From": "\"Christopher S. Hall\" <christopher.s.hall@intel.com>",
        "To": "tglx@linutronix.de, richardcochran@gmail.com, mingo@redhat.com,\n\tjohn.stultz@linaro.org, hpa@zytor.com, jeffrey.t.kirsher@intel.com",
        "Date": "Wed, 13 Jan 2016 04:12:22 -0800",
        "Message-Id": "<1452687149-11281-3-git-send-email-christopher.s.hall@intel.com>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": "<1452687149-11281-1-git-send-email-christopher.s.hall@intel.com>",
        "References": "<1452687149-11281-1-git-send-email-christopher.s.hall@intel.com>",
        "Cc": "\"Christopher S. Hall\" <christopher.s.hall@intel.com>,\n\tkevin.b.stanton@intel.com, netdev@vger.kernel.org, x86@kernel.org,\n\tlinux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org",
        "Subject": "[Intel-wired-lan] [PATCH v6 2/9] Add driver cross timestamp\n\tinterface for higher precision time synchronization",
        "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": "ACKNOWLEDGMENT: The original correlated clock source and cross\ntimestamp code was developed by Thomas Gleixner\n<tglx@linutronix.de>. It has changed considerably and any mistakes are\nmine.\n\nThe precision with which events on multiple networked systems can be\nsynchronized using, as an example, PTP (IEEE 1588, 802.1AS) is limited\nby the precision of the cross timestamps between the system clock and\nthe device (timestamp) clock. Precision here is the degree of\nsimultaneity when capturing the cross timestamp.\n\nCurrently the PTP cross timestamp is captured in software using the\nPTP device driver ioctl PTP_SYS_OFFSET. Reads of the device clock are\ninterleaved with reads of the realtime clock. At best, the precision\nof this cross timestamp is on the order of several microseconds due to\nsoftware latencies. Sub-microsecond precision is required for\nindustrial control and some media applications. To achieve this level\nof precision hardware supported cross timestamping is needed.\n\nHardware cross timestamps are derived from simultaneously capturing\nthe device clock and the system clock. Applications use timestamps in\nnanoseconds rather than clock ticks. The device driver can scale\ndevice clock ticks to device time in nanoseconds, but cannot transform\nsystem clock ticks. Only the kernel timekeeping code can do this. The\nfunction get_device_system_crosstimestamp() allows device drivers to\nreturn a cross timestamp with system time properly scaled to\nnanoseconds.\n\nThe cross timestamps contain the realtime and monotonic raw clock\ntimes. The realtime value is needed to discipline that clock using PTP\nand the monotonic raw value is used for applications that don't\nrequire a \"real\" time, but need an unadjusted clock time.\n\nThe get_device_system_crosstimestamp() code calls back into the driver\nto ensure that the system counter is within the current timekeeping\nupdate interval. Because of possible NTP/PTP frequency adjustments,\nextrapolating a realtime clock time outside the current interval with\na potentially different scaling factor can result in a small amount of\nerror.\n\nModern Intel hardware provides an Always Running Timer (ART) which is\nexactly related to TSC through a known frequency ratio. The ART is\nrouted to devices on the system and is used to precisely and\nsimultaneously capture the device clock with the ART.\n\nSigned-off-by: Christopher S. Hall <christopher.s.hall@intel.com>\n---\n include/linux/clocksource.h | 12 ++++++++++\n include/linux/timekeeping.h | 35 ++++++++++++++++++++++++++++\n kernel/time/timekeeping.c   | 56 +++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 103 insertions(+)",
    "diff": "diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h\nindex 7784b59..4542293 100644\n--- a/include/linux/clocksource.h\n+++ b/include/linux/clocksource.h\n@@ -255,4 +255,16 @@ static inline void clocksource_probe(void) {}\n #define CLOCKSOURCE_ACPI_DECLARE(name, table_id, fn)\t\t\\\n \tACPI_DECLARE_PROBE_ENTRY(clksrc, name, table_id, 0, NULL, 0, fn)\n \n+/*\n+ * struct system_counterval_t - system counter value with the pointer to the\n+ *\tcorresponding clocksource\n+ * @cycles:\tSystem counter value\n+ * @cs:\t\tClocksource corresponding to system counter value. Used by\n+ *\ttimekeeping code to verify comparibility of two cycle values\n+ */\n+struct system_counterval_t {\n+\tcycle_t\t\t\tcycles;\n+\tstruct clocksource\t*cs;\n+};\n+\n #endif /* _LINUX_CLOCKSOURCE_H */\ndiff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h\nindex ec89d84..2651e0a 100644\n--- a/include/linux/timekeeping.h\n+++ b/include/linux/timekeeping.h\n@@ -266,6 +266,41 @@ extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);\n extern void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw,\n \t\t\t\t        struct timespec64 *ts_real);\n \n+\n+/*\n+ * struct system_device_crosststamp - system/device cross-timestamp\n+ *\t(syncronized capture)\n+ * @device:\t\tDevice time\n+ * @sys_realtime:\tRealtime simultaneous with device time\n+ * @sys_monoraw:\tMonotonic raw simultaneous with device time\n+ */\n+struct system_device_crosststamp {\n+\tktime_t device;\n+\tktime_t sys_realtime;\n+\tktime_t sys_monoraw;\n+};\n+\n+struct system_counterval_t;\n+/*\n+ * struct get_sync_device_time_cb - Provides method to capture device time\n+ *\tsynchronized with raw system counter value\n+ * @get_time:\tCallback providing synchronized capture of device time\n+ *\t\tand system counter. Returns 0 on success, < 0 on failure\n+ * @ctx:\tContext provided to callback function\n+ */\n+struct sync_device_time_cb {\n+\tint\t(*get_time)(ktime_t *device_time,\n+\t\t\t    struct system_counterval_t *system_counterval,\n+\t\t\t    void *ctx);\n+\tvoid\t *ctx;\n+};\n+\n+/*\n+ * Get cross timestamp between system clock and device clock\n+ */\n+extern int get_device_system_crosststamp(struct sync_device_time_cb *cb,\n+\t\t\t\t\t struct system_device_crosststamp *ts);\n+\n /*\n  * Persistent clock related interfaces\n  */\ndiff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c\nindex 3f127dd..84534f8 100644\n--- a/kernel/time/timekeeping.c\n+++ b/kernel/time/timekeeping.c\n@@ -901,6 +901,62 @@ EXPORT_SYMBOL(ktime_get_raw_and_real_ts64);\n #endif /* CONFIG_NTP_PPS */\n \n /**\n+ * get_device_system_crosststamp - Synchronously capture system/device timestamp\n+ * @sync_devicetime:\tCallback to get simultaneous device time and\n+ *\tsystem counter from the device driver\n+ * @xtstamp:\t\tReceives simultaneously captured system and device time\n+ *\n+ * Reads a timestamp from a device and correlates it to system time\n+ */\n+int get_device_system_crosststamp(struct sync_device_time_cb *sync_devicetime,\n+\t\t\t\t  struct system_device_crosststamp *xtstamp)\n+{\n+\tstruct timekeeper *tk = &tk_core.timekeeper;\n+\tunsigned long seq;\n+\tstruct system_counterval_t system_counterval;\n+\tktime_t base_raw;\n+\tktime_t base_real;\n+\ts64 nsec_raw;\n+\ts64 nsec_real;\n+\tint ret;\n+\n+\tdo {\n+\t\tseq = read_seqcount_begin(&tk_core.seq);\n+\t\t/*\n+\t\t * Try to synchronously capture device time and a system\n+\t\t * counter value calling back into the device driver\n+\t\t */\n+\t\tret = sync_devicetime->get_time(&xtstamp->device,\n+\t\t\t\t\t\t&system_counterval,\n+\t\t\t\t\t\tsync_devicetime->ctx);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\t/*\n+\t\t * Verify that the clocksource associated with the captured\n+\t\t * system counter value is the same as the currently installed\n+\t\t * timekeeper clocksource\n+\t\t */\n+\t\tif (tk->tkr_mono.clock != system_counterval.cs)\n+\t\t\treturn -ENODEV;\n+\n+\t\tbase_real = ktime_add(tk->tkr_mono.base,\n+\t\t\t\t      tk_core.timekeeper.offs_real);\n+\t\tbase_raw = tk->tkr_raw.base;\n+\n+\t\tnsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono,\n+\t\t\t\t\t\t     system_counterval.cycles);\n+\t\tnsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw,\n+\t\t\t\t\t\t    system_counterval.cycles);\n+\t} while (read_seqcount_retry(&tk_core.seq, seq));\n+\n+\txtstamp->sys_realtime = ktime_add_ns(base_real, nsec_real);\n+\txtstamp->sys_monoraw = ktime_add_ns(base_raw, nsec_raw);\n+\treturn 0;\n+}\n+EXPORT_SYMBOL_GPL(get_device_system_crosststamp);\n+\n+/**\n  * do_gettimeofday - Returns the time of day in a timeval\n  * @tv:\t\tpointer to the timeval to be set\n  *\n",
    "prefixes": [
        "v6",
        "2/9"
    ]
}