Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp482660ybi; Tue, 16 Jul 2019 00:23:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4TaAmo9i7Bwgywn2EcjMDDw4lWrfWgYBbau9fpD+JbeDIiauPhBmaruemLsgfMZWt4gmS X-Received: by 2002:a63:4d05:: with SMTP id a5mr29615613pgb.19.1563261813847; Tue, 16 Jul 2019 00:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563261813; cv=none; d=google.com; s=arc-20160816; b=qXbmrhaQAq1YC4wihU1CessNo0Hk/slxeYqirGkgIPodVGVrfcIreRDrSMBzyTXCpi SSS00PSMb1qR47fzrYmfULe96SEQQuxQl0Z+FBNk9i2xrE3xXzR32jZGKgjQtVm4/WTS FXojKeMAoEH81fHM1t433sllcxnEPk9L1RvcXQKbJ75A5yBm4xMP+UHD1dHTN3xC3UJw XiiZMsM6+6c97rhsyHFkmKi6jNkcJ/55LCgD53tt6QTmf6F6ZP7CKddP4qlzadrIGW+8 Lupd9lCPw5XTaV4jQt2gRTMQNXezz15XIU7oqfU6ETQQz5nOg+mTI/X2+ZVR+aegk0mQ c2Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wWkqydLGtnRl2iY4H8dQzb2AO21e3gsgmRzAsMdJIow=; b=HCoz06fesN5zEND3zcenYgQsYy7apbujz8eA3a8W6ulgzk24kgHKnuVHKKWJ90Z1Ju 4qcf6e3MIK0NjiJD8frBVDoJTFjtoM3NgBTWqHycmT2+ue+yVy3zAQO28HFPa/jQ7Z+s q4WbdGZn4K8If74tPT/9kPCOcPuaNJRCEs7uEzc6s/b8Z2rf7Lprxjzq67qjKiDWiwwX Mbt++CtrNJiwaDB0ycvLFet/frVQ2NGQru9FQcG5W69zeHUMrjGWrplYl+CVNZh6w6W3 R/xijU3ZVGbGDXQ9p5RkYDWQBol19myy0cFuNg+6h1tJFaH/mZdAr4Ee3hgjGDHFeHbA lkpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c9si19082542pfi.143.2019.07.16.00.23.17; Tue, 16 Jul 2019 00:23:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731058AbfGPHVI (ORCPT + 99 others); Tue, 16 Jul 2019 03:21:08 -0400 Received: from mga09.intel.com ([134.134.136.24]:64897 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730443AbfGPHVF (ORCPT ); Tue, 16 Jul 2019 03:21:05 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2019 00:20:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,496,1557212400"; d="scan'208";a="194796221" Received: from pipin.fi.intel.com ([10.237.72.175]) by fmsmga002.fm.intel.com with ESMTP; 16 Jul 2019 00:20:53 -0700 From: Felipe Balbi To: Richard Cochran Cc: netdev@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, "Christopher S . Hall" , Felipe Balbi Subject: [RFC PATCH 3/5] PTP: implement PTP_EVENT_COUNT_TSTAMP ioctl Date: Tue, 16 Jul 2019 10:20:36 +0300 Message-Id: <20190716072038.8408-4-felipe.balbi@linux.intel.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190716072038.8408-1-felipe.balbi@linux.intel.com> References: <20190716072038.8408-1-felipe.balbi@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With this, we can request the underlying driver to count the number of events that have been captured. Signed-off-by: Felipe Balbi --- drivers/ptp/ptp_chardev.c | 15 +++++++++++++++ include/uapi/linux/ptp_clock.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index 18ffe449efdf..a3e163a6acdc 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -114,6 +114,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) struct system_device_crosststamp xtstamp; struct ptp_clock_info *ops = ptp->info; struct ptp_sys_offset *sysoff = NULL; + struct ptp_event_count_tstamp counttstamp; struct ptp_system_timestamp sts; struct ptp_clock_request req; struct ptp_clock_caps caps; @@ -301,6 +302,20 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) mutex_unlock(&ptp->pincfg_mux); break; + case PTP_EVENT_COUNT_TSTAMP: + if (!ops->counttstamp) + return -ENOTSUPP; + if (copy_from_user(&req.perout, (void __user *)arg, + sizeof(counttstamp))) { + err = -EFAULT; + break; + } + err = ops->counttstamp(ops, &counttstamp); + if (!err && copy_to_user((void __user *)arg, &counttstamp, + sizeof(counttstamp))) + err = -EFAULT; + break; + default: err = -ENOTTY; break; diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h index 1bc794ad957a..674db7de64f3 100644 --- a/include/uapi/linux/ptp_clock.h +++ b/include/uapi/linux/ptp_clock.h @@ -148,6 +148,8 @@ struct ptp_pin_desc { _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise) #define PTP_SYS_OFFSET_EXTENDED \ _IOWR(PTP_CLK_MAGIC, 9, struct ptp_sys_offset_extended) +#define PTP_EVENT_COUNT_TSTAMP \ + _IOWR(PTP_CLK_MAGIC, 6, struct ptp_event_count_tstamp) struct ptp_extts_event { struct ptp_clock_time t; /* Time event occured. */ -- 2.22.0