From b98c7518c5345ac5f930fd40ce9d8d2b8dc2ba06 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 18 Jun 2018 16:19:24 +0200 Subject: [PATCH 1/2] firewire: ohci: stop using get_seconds() for BUS_TIME The ohci driver uses the get_seconds() function to implement the 32-bit CSR_BUS_TIME register. This was added in 2010 commit a48777e03ad5 ("firewire: add CSR BUS_TIME support"). As get_seconds() returns a 32-bit value (on 32-bit architectures), it seems like a good fit for that register, but it is also deprecated because of the y2038/y2106 overflow problem, and should be replaced throughout the kernel with either ktime_get_real_seconds() or ktime_get_seconds(). I'm using the latter here, which uses monotonic time. This has the advantage of behaving better during concurrent settimeofday() updates or leap second adjustments and won't overflow a 32-bit integer, but the downside of using CLOCK_MONOTONIC instead of CLOCK_REALTIME is that the observed values are not related to external clocks. If we instead need UTC but can live with clock jumps or overflows, then we should use ktime_get_real_seconds() instead, retaining the existing behavior. Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/lkml/20180711124923.1205200-1-arnd@arndb.de/ Reviewed-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 522f3addb5bd..33269316f111 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1752,7 +1752,7 @@ static u32 update_bus_time(struct fw_ohci *ohci) if (unlikely(!ohci->bus_time_running)) { reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycle64Seconds); - ohci->bus_time = (lower_32_bits(get_seconds()) & ~0x7f) | + ohci->bus_time = (lower_32_bits(ktime_get_seconds()) & ~0x7f) | (cycle_time_seconds & 0x40); ohci->bus_time_running = true; } From 7807759e4ad8d46347a5d52a0910269320b81e65 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Tue, 5 Nov 2019 14:49:39 +0100 Subject: [PATCH 2/2] firewire: core: code cleanup after vm_map_pages_zero introduction Commit 22660db89262 turned fw_iso_buffer_map_vma into a one-liner. There is no need to keep this in the core-iso.c collection of buffer management functions; put it inline into the sole user, the character device file driver. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 3 ++- drivers/firewire/core-iso.c | 7 ------- drivers/firewire/core.h | 2 -- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 1da7ba18d399..719791819c24 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1694,7 +1694,8 @@ static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) if (ret < 0) goto fail; - ret = fw_iso_buffer_map_vma(&client->buffer, vma); + ret = vm_map_pages_zero(vma, client->buffer.pages, + client->buffer.page_count); if (ret < 0) goto fail; diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index df8a56a979b9..185b0b78b3d6 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -91,13 +91,6 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, } EXPORT_SYMBOL(fw_iso_buffer_init); -int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer, - struct vm_area_struct *vma) -{ - return vm_map_pages_zero(vma, buffer->pages, - buffer->page_count); -} - void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card) { diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index 0f0bed3a4bbb..4b0e4ee655a1 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h @@ -158,8 +158,6 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event); int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count); int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *card, enum dma_data_direction direction); -int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer, - struct vm_area_struct *vma); /* -topology */