]> www.infradead.org Git - users/dwmw2/vmclock.git/commitdiff
Update to v6 posting
authorDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 29 Apr 2025 16:49:36 +0000 (09:49 -0700)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 29 Apr 2025 16:49:36 +0000 (09:49 -0700)
ptp_vmclock.c

index 65536b2c20d96ae06d7f7ceff271346a0a1221bc..267a49cc7d1df93c853bc858ac0e6992a76638a2 100644 (file)
@@ -53,8 +53,8 @@ struct vmclock_state {
 #define VMCLOCK_MIN_SIZE offsetof(struct vmclock_abi, pad)
 
 #define VMCLOCK_FIELD_PRESENT(_c, _f)                    \
-       le32_to_cpu((_c)->size) >= (offsetof(struct vmclock_abi, _f) +  \
-                                   sizeof((_c)->_f))
+       (le32_to_cpu((_c)->size) >= (offsetof(struct vmclock_abi, _f) + \
+                                    sizeof((_c)->_f)))
 
 /*
  * Multiply a 64-bit count by a 64-bit tick 'period' in units of seconds >> 64
@@ -157,6 +157,10 @@ static int vmclock_get_crosststamp(struct vmclock_state *st,
                if (!tai_adjust(st->clk, &tspec->tv_sec))
                        return -EINVAL;
 
+               /*
+                * This pairs with a write barrier in the hypervisor
+                * which populates this structure.
+                */
                virt_rmb();
                if (seq == le32_to_cpu(st->clk->seq_count))
                        break;
@@ -193,7 +197,7 @@ static int vmclock_get_crosststamp_kvmclock(struct vmclock_state *st,
                                            struct timespec64 *tspec)
 {
        struct pvclock_vcpu_time_info *pvti = this_cpu_pvti();
-       unsigned pvti_ver;
+       unsigned int pvti_ver;
        int ret;
 
        preempt_disable_notrace();
@@ -263,6 +267,7 @@ static int ptp_vmclock_getcrosststamp(struct ptp_clock_info *ptp,
         */
        if (ret == -ENODEV) {
                struct system_time_snapshot systime_snapshot;
+
                ktime_get_snapshot(&systime_snapshot);
 
                if (systime_snapshot.cs_id == CSID_X86_TSC ||
@@ -349,7 +354,8 @@ static struct ptp_clock *vmclock_ptp_register(struct device *dev,
                return NULL;
        }
 
-       st->sys_cs_id = st->cs_id = cs_id;
+       st->sys_cs_id = cs_id;
+       st->cs_id = cs_id;
        st->ptp_clock_info = ptp_vmclock_info;
        strscpy(st->ptp_clock_info.name, st->name, sizeof(st->ptp_clock_info.name));
 
@@ -365,14 +371,14 @@ static int vmclock_miscdev_mmap(struct file *fp, struct vm_area_struct *vma)
                return -EROFS;
 
        if (vma->vm_end - vma->vm_start != PAGE_SIZE || vma->vm_pgoff)
-               return -EINVAL;
+               return -EINVAL;
 
-        if (io_remap_pfn_range(vma, vma->vm_start,
+       if (io_remap_pfn_range(vma, vma->vm_start,
                               st->res.start >> PAGE_SHIFT, PAGE_SIZE,
-                               vma->vm_page_prot))
-                return -EAGAIN;
+                              vma->vm_page_prot))
+               return -EAGAIN;
 
-        return 0;
+       return 0;
 }
 
 static ssize_t vmclock_miscdev_read(struct file *fp, char __user *buf,
@@ -393,11 +399,13 @@ static ssize_t vmclock_miscdev_read(struct file *fp, char __user *buf,
 
        while (1) {
                seq = le32_to_cpu(st->clk->seq_count) & ~1U;
+               /* Pairs with hypervisor wmb */
                virt_rmb();
 
                if (copy_to_user(buf, ((char *)st->clk) + *ppos, count))
                        return -EFAULT;
 
+               /* Pairs with hypervisor wmb */
                virt_rmb();
                if (seq == le32_to_cpu(st->clk->seq_count))
                        break;
@@ -411,8 +419,8 @@ static ssize_t vmclock_miscdev_read(struct file *fp, char __user *buf,
 }
 
 static const struct file_operations vmclock_miscdev_fops = {
-        .mmap = vmclock_miscdev_mmap,
-        .read = vmclock_miscdev_read,
+       .mmap = vmclock_miscdev_mmap,
+       .read = vmclock_miscdev_read,
 };
 
 /* module operations */
@@ -435,7 +443,7 @@ static acpi_status vmclock_acpi_resources(struct acpi_resource *ares, void *data
 {
        struct vmclock_state *st = data;
        struct resource_win win;
-       struct resource *res = &(win.res);
+       struct resource *res = &win.res;
 
        if (ares->type == ACPI_RESOURCE_TYPE_END_TAG)
                return AE_OK;
@@ -444,7 +452,7 @@ static acpi_status vmclock_acpi_resources(struct acpi_resource *ares, void *data
        if (resource_type(&st->res) == IORESOURCE_MEM)
                return AE_ERROR;
 
-        if (acpi_dev_resource_memory(ares, res) ||
+       if (acpi_dev_resource_memory(ares, res) ||
            acpi_dev_resource_address_space(ares, &win)) {
 
                if (resource_type(res) != IORESOURCE_MEM ||
@@ -494,7 +502,7 @@ static int vmclock_probe(struct platform_device *pdev)
        struct vmclock_state *st;
        int ret;
 
-       st = devm_kzalloc(dev, sizeof (*st), GFP_KERNEL);
+       st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL);
        if (!st)
                return -ENOMEM;
 
@@ -612,4 +620,4 @@ module_platform_driver(vmclock_platform_driver)
 
 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
 MODULE_DESCRIPTION("PTP clock using VMCLOCK");
-MODULE_LICENSE("GPL v2");
+MODULE_LICENSE("GPL");