Skip to contentSkip to conversation

xen/pcifront: Remove usage of struct timeval

PATCH Applied Tina Ruchandani 6 participants 11 messages May 19, 2015 – Jun 8, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/pcifront: Remove usage of struct timeval

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

--
Changes in v2:
- Use monotonic time (ktime_get_ns()) instead of real time since we only care about elapsed delta here.
- Use macro ktime_get_ns() instead of getting ktime_t and converting it to ns.

---
 drivers/pci/xen-pcifront.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/xen-pcifront.c +3 -5
index 7cfd2db..c4796c8 100644
@@ -20,6 +20,7 @@
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,6 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 	evtchn_port_t port = pdev->evtchn;
 	unsigned irq = pdev->irq;
 	s64 ns, ns_timeout;
-	struct timeval tv;
 
 	spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +132,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 	 * (in the latter case we end up continually re-executing poll() with a
 	 * timeout in the past). 1s difference gives plenty of slack for error.
 	 */
-	do_gettimeofday(&tv);
-	ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+	ns_timeout = ktime_get_ns() + 2 * (s64)NSEC_PER_SEC;
 
 	xen_clear_irq_pending(irq);
 
@@ -141,8 +140,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 			(unsigned long *)&pdev->sh_info->flags)) {
 		xen_poll_irq_timeout(irq, jiffies + 3*HZ);
 		xen_clear_irq_pending(irq);
-		do_gettimeofday(&tv);
-		ns = timeval_to_ns(&tv);
+		ns = ktime_get_ns();
 		if (ns > ns_timeout) {
 			dev_err(&pdev->xdev->dev,
 				"pciback not responding!!!\n");
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Tina Ruchandani

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Quoted 50 lines

--
Changes in v2:
- Use monotonic time (ktime_get_ns()) instead of real time since we only care about elapsed delta here.
- Use macro ktime_get_ns() instead of getting ktime_t and converting it to ns.

---
  drivers/pci/xen-pcifront.c | 8 +++-----
  1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/xen-pcifront.c +3 -5
index 7cfd2db..c4796c8 100644
@@ -20,6 +20,7 @@
  #include <linux/workqueue.h>
  #include <linux/bitops.h>
  #include <linux/time.h>
+#include <linux/ktime.h>
  #include <xen/platform_pci.h>
 
  #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,6 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
  	evtchn_port_t port = pdev->evtchn;
  	unsigned irq = pdev->irq;
  	s64 ns, ns_timeout;
-	struct timeval tv;
 
  	spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +132,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
  	 * (in the latter case we end up continually re-executing poll() with a
  	 * timeout in the past). 1s difference gives plenty of slack for error.
  	 */
-	do_gettimeofday(&tv);
-	ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+	ns_timeout = ktime_get_ns() + 2 * (s64)NSEC_PER_SEC;
 
  	xen_clear_irq_pending(irq);
 
@@ -141,8 +140,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
  			(unsigned long *)&pdev->sh_info->flags)) {
  		xen_poll_irq_timeout(irq, jiffies + 3*HZ);
  		xen_clear_irq_pending(irq);
-		do_gettimeofday(&tv);
-		ns = timeval_to_ns(&tv);
+		ns = ktime_get_ns();
  		if (ns > ns_timeout) {
  			dev_err(&pdev->xdev->dev,
  				"pciback not responding!!!\n");
Reviewed-by on v2 1/1
#2 lore raw
In reply to Tina Ruchandani
Quoted 9 lines · Tina Ruchandani

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Quoted 50 lines

--
Changes in v2:
- Use monotonic time (ktime_get_ns()) instead of real time since we only care about elapsed delta here.
- Use macro ktime_get_ns() instead of getting ktime_t and converting it to ns.

---
  drivers/pci/xen-pcifront.c | 8 +++-----
  1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/xen-pcifront.c +3 -5
index 7cfd2db..c4796c8 100644
@@ -20,6 +20,7 @@
  #include <linux/workqueue.h>
  #include <linux/bitops.h>
  #include <linux/time.h>
+#include <linux/ktime.h>
  #include <xen/platform_pci.h>
 
  #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,6 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
  	evtchn_port_t port = pdev->evtchn;
  	unsigned irq = pdev->irq;
  	s64 ns, ns_timeout;
-	struct timeval tv;
 
  	spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +132,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
  	 * (in the latter case we end up continually re-executing poll() with a
  	 * timeout in the past). 1s difference gives plenty of slack for error.
  	 */
-	do_gettimeofday(&tv);
-	ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+	ns_timeout = ktime_get_ns() + 2 * (s64)NSEC_PER_SEC;
 
  	xen_clear_irq_pending(irq);
 
@@ -141,8 +140,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
  			(unsigned long *)&pdev->sh_info->flags)) {
  		xen_poll_irq_timeout(irq, jiffies + 3*HZ);
  		xen_clear_irq_pending(irq);
-		do_gettimeofday(&tv);
-		ns = timeval_to_ns(&tv);
+		ns = ktime_get_ns();
  		if (ns > ns_timeout) {
  			dev_err(&pdev->xdev->dev,
  				"pciback not responding!!!\n");
Reviewed-by on v2 1/1
#3 lore raw
In reply to Tina Ruchandani
Quoted 10 lines · On Tuesday 19 May 2015 11:38:09 Tina Ruchandani wrote:

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Reviewed-by on v2 1/1
#4 lore raw
In reply to Tina Ruchandani
Quoted 10 lines · On Tuesday 19 May 2015 11:38:09 Tina Ruchandani wrote:

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

maintainer Acked-by on v2 1/1
#5 lore raw
In reply to Tina Ruchandani
Quoted 9 lines · Tina Ruchandani

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

This isn't PCI-related, so I expect Konrad, Boris, or David will merge this.

Quoted 53 lines

--
Changes in v2:
- Use monotonic time (ktime_get_ns()) instead of real time since we only care about elapsed delta here.
- Use macro ktime_get_ns() instead of getting ktime_t and converting it to ns.

---
 drivers/pci/xen-pcifront.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/xen-pcifront.c +3 -6
index 7cfd2db..c4796c8 100644
@@ -20,6 +20,7 @@
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,6 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
        evtchn_port_t port = pdev->evtchn;
        unsigned irq = pdev->irq;
        s64 ns, ns_timeout;
-       struct timeval tv;
 
        spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +132,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
         * (in the latter case we end up continually re-executing poll() with a
         * timeout in the past). 1s difference gives plenty of slack for error.
         */
-       do_gettimeofday(&tv);
-       ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+       ns_timeout = ktime_get_ns() + 2 * (s64)NSEC_PER_SEC;
 
        xen_clear_irq_pending(irq);
 
@@ -141,8 +140,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
                        (unsigned long *)&pdev->sh_info->flags)) {
                xen_poll_irq_timeout(irq, jiffies + 3*HZ);
                xen_clear_irq_pending(irq);
-               do_gettimeofday(&tv);
-               ns = timeval_to_ns(&tv);
+               ns = ktime_get_ns();
                if (ns > ns_timeout) {
                        dev_err(&pdev->xdev->dev,
                                "pciback not responding!!!\n");
--

2.2.0.rc0.207.ga3a616c

#6 lore raw
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Tina Ruchandani

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Quoted 6 lines
Quoted 2 lines

This isn't PCI-related, so I expect Konrad, Boris, or David will merge this.

OK. Thanks.

Quoted 54 lines
Quoted 54 lines

--
Changes in v2:
- Use monotonic time (ktime_get_ns()) instead of real time since we only care about elapsed delta here.
- Use macro ktime_get_ns() instead of getting ktime_t and converting it to ns.

---
 drivers/pci/xen-pcifront.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/xen-pcifront.c +3 -6
index 7cfd2db..c4796c8 100644
@@ -20,6 +20,7 @@
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,6 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
        evtchn_port_t port = pdev->evtchn;
        unsigned irq = pdev->irq;
        s64 ns, ns_timeout;
-       struct timeval tv;
 
        spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +132,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
         * (in the latter case we end up continually re-executing poll() with a
         * timeout in the past). 1s difference gives plenty of slack for error.
         */
-       do_gettimeofday(&tv);
-       ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+       ns_timeout = ktime_get_ns() + 2 * (s64)NSEC_PER_SEC;
 
        xen_clear_irq_pending(irq);
 
@@ -141,8 +140,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
                        (unsigned long *)&pdev->sh_info->flags)) {
                xen_poll_irq_timeout(irq, jiffies + 3*HZ);
                xen_clear_irq_pending(irq);
-               do_gettimeofday(&tv);
-               ns = timeval_to_ns(&tv);
+               ns = ktime_get_ns();
                if (ns > ns_timeout) {
                        dev_err(&pdev->xdev->dev,
                                "pciback not responding!!!\n");
--

2.2.0.rc0.207.ga3a616c

#7 lore raw
In reply to Bjorn Helgaas
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Tina Ruchandani

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Quoted 6 lines
Quoted 2 lines

This isn't PCI-related, so I expect Konrad, Boris, or David will merge this.

OK. Thanks.

Quoted 54 lines
Quoted 54 lines

--
Changes in v2:
- Use monotonic time (ktime_get_ns()) instead of real time since we only care about elapsed delta here.
- Use macro ktime_get_ns() instead of getting ktime_t and converting it to ns.

---
 drivers/pci/xen-pcifront.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/xen-pcifront.c +3 -6
index 7cfd2db..c4796c8 100644
@@ -20,6 +20,7 @@
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,6 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
        evtchn_port_t port = pdev->evtchn;
        unsigned irq = pdev->irq;
        s64 ns, ns_timeout;
-       struct timeval tv;
 
        spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +132,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
         * (in the latter case we end up continually re-executing poll() with a
         * timeout in the past). 1s difference gives plenty of slack for error.
         */
-       do_gettimeofday(&tv);
-       ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+       ns_timeout = ktime_get_ns() + 2 * (s64)NSEC_PER_SEC;
 
        xen_clear_irq_pending(irq);
 
@@ -141,8 +140,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
                        (unsigned long *)&pdev->sh_info->flags)) {
                xen_poll_irq_timeout(irq, jiffies + 3*HZ);
                xen_clear_irq_pending(irq);
-               do_gettimeofday(&tv);
-               ns = timeval_to_ns(&tv);
+               ns = ktime_get_ns();
                if (ns > ns_timeout) {
                        dev_err(&pdev->xdev->dev,
                                "pciback not responding!!!\n");
--

2.2.0.rc0.207.ga3a616c

maintainer Acked-by on v2 1/1
#8 lore raw
In reply to Tina Ruchandani
Quoted 9 lines · Tina Ruchandani

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

This isn't PCI-related, so I expect Konrad, Boris, or David will merge this.

Quoted 53 lines

--
Changes in v2:
- Use monotonic time (ktime_get_ns()) instead of real time since we only care about elapsed delta here.
- Use macro ktime_get_ns() instead of getting ktime_t and converting it to ns.

---
 drivers/pci/xen-pcifront.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/xen-pcifront.c +3 -6
index 7cfd2db..c4796c8 100644
@@ -20,6 +20,7 @@
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,6 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
        evtchn_port_t port = pdev->evtchn;
        unsigned irq = pdev->irq;
        s64 ns, ns_timeout;
-       struct timeval tv;
 
        spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +132,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
         * (in the latter case we end up continually re-executing poll() with a
         * timeout in the past). 1s difference gives plenty of slack for error.
         */
-       do_gettimeofday(&tv);
-       ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+       ns_timeout = ktime_get_ns() + 2 * (s64)NSEC_PER_SEC;
 
        xen_clear_irq_pending(irq);
 
@@ -141,8 +140,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
                        (unsigned long *)&pdev->sh_info->flags)) {
                xen_poll_irq_timeout(irq, jiffies + 3*HZ);
                xen_clear_irq_pending(irq);
-               do_gettimeofday(&tv);
-               ns = timeval_to_ns(&tv);
+               ns = ktime_get_ns();
                if (ns > ns_timeout) {
                        dev_err(&pdev->xdev->dev,
                                "pciback not responding!!!\n");
--

2.2.0.rc0.207.ga3a616c

Applied
#9 lore raw
In reply to Tina Ruchandani
Quoted 6 lines · Tina Ruchandani

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Applied to for-linus-4.2, thanks.

"This patch" is a bit redundant in a commit message so I tweaked it to read:

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. Replace struct timeval with 64-bit ktime_t which is 2038 safe. This is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Quoted 3 lines

--

Use 3 hyphens as a separator here.

Quoted 1 line

Changes in v2:

David

Applied
#10 lore raw
In reply to Tina Ruchandani
Quoted 6 lines · Tina Ruchandani

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. This patch replaces struct timeval with 64-bit ktime_t which is 2038 safe. The patch is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Applied to for-linus-4.2, thanks.

"This patch" is a bit redundant in a commit message so I tweaked it to read:

struct timeval uses a 32-bit field for representing seconds, which will overflow in the year 2038 and beyond. Replace struct timeval with 64-bit ktime_t which is 2038 safe. This is part of a larger effort to remove instances of 32-bit timekeeping variables (timeval, time_t and timespec) from the kernel.

Quoted 3 lines

--

Use 3 hyphens as a separator here.

Quoted 1 line

Changes in v2:

David