Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

device-dax: introduce 'struct dev_dax' typed-driver operations

In preparation for introducing seed devices the dax-bus core needs to be
able to intercept ->probe() and ->remove() operations. Towards that end
arrange for the bus and drivers to switch from raw 'struct device' driver
operations to 'struct dev_dax' typed operations.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Jason Yan <yanaijie@huawei.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Brice Goglin <Brice.Goglin@inria.fr>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jia He <justin.he@arm.com>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jason Gunthorpe <jgg@mellanox.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: kernel test robot <lkp@intel.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lkml.kernel.org/r/160106113357.30709.4541750544799737855.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dan Williams and committed by
Linus Torvalds
f11cf813 c2f3011e

+35 -19
+18
drivers/dax/bus.c
··· 135 135 return (dax_region->res.flags & IORESOURCE_DAX_STATIC) != 0; 136 136 } 137 137 138 + static int dax_bus_probe(struct device *dev) 139 + { 140 + struct dax_device_driver *dax_drv = to_dax_drv(dev->driver); 141 + struct dev_dax *dev_dax = to_dev_dax(dev); 142 + 143 + return dax_drv->probe(dev_dax); 144 + } 145 + 146 + static int dax_bus_remove(struct device *dev) 147 + { 148 + struct dax_device_driver *dax_drv = to_dax_drv(dev->driver); 149 + struct dev_dax *dev_dax = to_dev_dax(dev); 150 + 151 + return dax_drv->remove(dev_dax); 152 + } 153 + 138 154 static struct bus_type dax_bus_type = { 139 155 .name = "dax", 140 156 .uevent = dax_bus_uevent, 141 157 .match = dax_bus_match, 158 + .probe = dax_bus_probe, 159 + .remove = dax_bus_remove, 142 160 .drv_groups = dax_drv_groups, 143 161 }; 144 162
+3 -1
drivers/dax/bus.h
··· 38 38 struct device_driver drv; 39 39 struct list_head ids; 40 40 int match_always; 41 + int (*probe)(struct dev_dax *dev); 42 + int (*remove)(struct dev_dax *dev); 41 43 }; 42 44 43 45 int __dax_driver_register(struct dax_device_driver *dax_drv, ··· 50 48 void kill_dev_dax(struct dev_dax *dev_dax); 51 49 52 50 #if IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT) 53 - int dev_dax_probe(struct device *dev); 51 + int dev_dax_probe(struct dev_dax *dev_dax); 54 52 #endif 55 53 56 54 /*
+5 -7
drivers/dax/device.c
··· 392 392 kill_dev_dax(dev_dax); 393 393 } 394 394 395 - int dev_dax_probe(struct device *dev) 395 + int dev_dax_probe(struct dev_dax *dev_dax) 396 396 { 397 - struct dev_dax *dev_dax = to_dev_dax(dev); 398 397 struct dax_device *dax_dev = dev_dax->dax_dev; 399 398 struct range *range = &dev_dax->range; 399 + struct device *dev = &dev_dax->dev; 400 400 struct dev_pagemap *pgmap; 401 401 struct inode *inode; 402 402 struct cdev *cdev; ··· 446 446 } 447 447 EXPORT_SYMBOL_GPL(dev_dax_probe); 448 448 449 - static int dev_dax_remove(struct device *dev) 449 + static int dev_dax_remove(struct dev_dax *dev_dax) 450 450 { 451 451 /* all probe actions are unwound by devm */ 452 452 return 0; 453 453 } 454 454 455 455 static struct dax_device_driver device_dax_driver = { 456 - .drv = { 457 - .probe = dev_dax_probe, 458 - .remove = dev_dax_remove, 459 - }, 456 + .probe = dev_dax_probe, 457 + .remove = dev_dax_remove, 460 458 .match_always = 1, 461 459 }; 462 460
+8 -10
drivers/dax/kmem.c
··· 29 29 return range; 30 30 } 31 31 32 - int dev_dax_kmem_probe(struct device *dev) 32 + static int dev_dax_kmem_probe(struct dev_dax *dev_dax) 33 33 { 34 - struct dev_dax *dev_dax = to_dev_dax(dev); 35 34 struct range range = dax_kmem_range(dev_dax); 35 + struct device *dev = &dev_dax->dev; 36 36 struct resource *res; 37 37 char *res_name; 38 38 int numa_node; ··· 88 88 } 89 89 90 90 #ifdef CONFIG_MEMORY_HOTREMOVE 91 - static int dev_dax_kmem_remove(struct device *dev) 91 + static int dev_dax_kmem_remove(struct dev_dax *dev_dax) 92 92 { 93 - struct dev_dax *dev_dax = to_dev_dax(dev); 93 + int rc; 94 + struct device *dev = &dev_dax->dev; 94 95 struct range range = dax_kmem_range(dev_dax); 95 96 const char *res_name = dev_get_drvdata(dev); 96 - int rc; 97 97 98 98 /* 99 99 * We have one shot for removing memory, if some memory blocks were not ··· 116 116 return 0; 117 117 } 118 118 #else 119 - static int dev_dax_kmem_remove(struct device *dev) 119 + static int dev_dax_kmem_remove(struct dev_dax *dev_dax) 120 120 { 121 121 /* 122 122 * Without hotremove purposely leak the request_mem_region() for the ··· 131 131 #endif /* CONFIG_MEMORY_HOTREMOVE */ 132 132 133 133 static struct dax_device_driver device_dax_kmem_driver = { 134 - .drv = { 135 - .probe = dev_dax_kmem_probe, 136 - .remove = dev_dax_kmem_remove, 137 - }, 134 + .probe = dev_dax_kmem_probe, 135 + .remove = dev_dax_kmem_remove, 138 136 }; 139 137 140 138 static int __init dax_kmem_init(void)
+1 -1
drivers/dax/pmem/compat.c
··· 22 22 return -ENOMEM; 23 23 24 24 device_lock(&dev_dax->dev); 25 - rc = dev_dax_probe(&dev_dax->dev); 25 + rc = dev_dax_probe(dev_dax); 26 26 device_unlock(&dev_dax->dev); 27 27 28 28 devres_close_group(&dev_dax->dev, dev_dax);