diff options
author | Dan Williams <dan.j.williams@intel.com> | 2017-01-31 00:43:10 -0500 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2017-04-13 00:59:13 -0400 |
commit | 5f0694b300b9fb8409272c550418c22e0e57314a (patch) | |
tree | cb8a183ae4b5e33e118266dee729cb99d07ac8ab /drivers | |
parent | 762026203c0b87b1088342b664e67ca7c45fb7c4 (diff) |
device-dax: rename 'dax_dev' to 'dev_dax'
In preparation for introducing a struct dax_device type to the kernel
global type namespace, rename dax_dev to dev_dax. A 'dax_device'
instance will be a generic device-driver object for any provider of dax
functionality. A 'dev_dax' object is a device-dax-driver local /
internal instance.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dax/dax.c | 206 | ||||
-rw-r--r-- | drivers/dax/dax.h | 4 | ||||
-rw-r--r-- | drivers/dax/pmem.c | 8 |
3 files changed, 109 insertions, 109 deletions
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c index 352cc54056ce..376fdd353aea 100644 --- a/drivers/dax/dax.c +++ b/drivers/dax/dax.c | |||
@@ -57,7 +57,7 @@ struct dax_region { | |||
57 | }; | 57 | }; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * struct dax_dev - subdivision of a dax region | 60 | * struct dev_dax - instance data for a subdivision of a dax region |
61 | * @region - parent region | 61 | * @region - parent region |
62 | * @dev - device backing the character device | 62 | * @dev - device backing the character device |
63 | * @cdev - core chardev data | 63 | * @cdev - core chardev data |
@@ -66,7 +66,7 @@ struct dax_region { | |||
66 | * @num_resources - number of physical address extents in this device | 66 | * @num_resources - number of physical address extents in this device |
67 | * @res - array of physical address ranges | 67 | * @res - array of physical address ranges |
68 | */ | 68 | */ |
69 | struct dax_dev { | 69 | struct dev_dax { |
70 | struct dax_region *region; | 70 | struct dax_region *region; |
71 | struct inode *inode; | 71 | struct inode *inode; |
72 | struct device dev; | 72 | struct device dev; |
@@ -323,47 +323,47 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id, | |||
323 | } | 323 | } |
324 | EXPORT_SYMBOL_GPL(alloc_dax_region); | 324 | EXPORT_SYMBOL_GPL(alloc_dax_region); |
325 | 325 | ||
326 | static struct dax_dev *to_dax_dev(struct device *dev) | 326 | static struct dev_dax *to_dev_dax(struct device *dev) |
327 | { | 327 | { |
328 | return container_of(dev, struct dax_dev, dev); | 328 | return container_of(dev, struct dev_dax, dev); |
329 | } | 329 | } |
330 | 330 | ||
331 | static ssize_t size_show(struct device *dev, | 331 | static ssize_t size_show(struct device *dev, |
332 | struct device_attribute *attr, char *buf) | 332 | struct device_attribute *attr, char *buf) |
333 | { | 333 | { |
334 | struct dax_dev *dax_dev = to_dax_dev(dev); | 334 | struct dev_dax *dev_dax = to_dev_dax(dev); |
335 | unsigned long long size = 0; | 335 | unsigned long long size = 0; |
336 | int i; | 336 | int i; |
337 | 337 | ||
338 | for (i = 0; i < dax_dev->num_resources; i++) | 338 | for (i = 0; i < dev_dax->num_resources; i++) |
339 | size += resource_size(&dax_dev->res[i]); | 339 | size += resource_size(&dev_dax->res[i]); |
340 | 340 | ||
341 | return sprintf(buf, "%llu\n", size); | 341 | return sprintf(buf, "%llu\n", size); |
342 | } | 342 | } |
343 | static DEVICE_ATTR_RO(size); | 343 | static DEVICE_ATTR_RO(size); |
344 | 344 | ||
345 | static struct attribute *dax_device_attributes[] = { | 345 | static struct attribute *dev_dax_attributes[] = { |
346 | &dev_attr_size.attr, | 346 | &dev_attr_size.attr, |
347 | NULL, | 347 | NULL, |
348 | }; | 348 | }; |
349 | 349 | ||
350 | static const struct attribute_group dax_device_attribute_group = { | 350 | static const struct attribute_group dev_dax_attribute_group = { |
351 | .attrs = dax_device_attributes, | 351 | .attrs = dev_dax_attributes, |
352 | }; | 352 | }; |
353 | 353 | ||
354 | static const struct attribute_group *dax_attribute_groups[] = { | 354 | static const struct attribute_group *dax_attribute_groups[] = { |
355 | &dax_device_attribute_group, | 355 | &dev_dax_attribute_group, |
356 | NULL, | 356 | NULL, |
357 | }; | 357 | }; |
358 | 358 | ||
359 | static int check_vma(struct dax_dev *dax_dev, struct vm_area_struct *vma, | 359 | static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, |
360 | const char *func) | 360 | const char *func) |
361 | { | 361 | { |
362 | struct dax_region *dax_region = dax_dev->region; | 362 | struct dax_region *dax_region = dev_dax->region; |
363 | struct device *dev = &dax_dev->dev; | 363 | struct device *dev = &dev_dax->dev; |
364 | unsigned long mask; | 364 | unsigned long mask; |
365 | 365 | ||
366 | if (!dax_dev->alive) | 366 | if (!dev_dax->alive) |
367 | return -ENXIO; | 367 | return -ENXIO; |
368 | 368 | ||
369 | /* prevent private mappings from being established */ | 369 | /* prevent private mappings from being established */ |
@@ -397,23 +397,23 @@ static int check_vma(struct dax_dev *dax_dev, struct vm_area_struct *vma, | |||
397 | return 0; | 397 | return 0; |
398 | } | 398 | } |
399 | 399 | ||
400 | static phys_addr_t pgoff_to_phys(struct dax_dev *dax_dev, pgoff_t pgoff, | 400 | static phys_addr_t pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, |
401 | unsigned long size) | 401 | unsigned long size) |
402 | { | 402 | { |
403 | struct resource *res; | 403 | struct resource *res; |
404 | phys_addr_t phys; | 404 | phys_addr_t phys; |
405 | int i; | 405 | int i; |
406 | 406 | ||
407 | for (i = 0; i < dax_dev->num_resources; i++) { | 407 | for (i = 0; i < dev_dax->num_resources; i++) { |
408 | res = &dax_dev->res[i]; | 408 | res = &dev_dax->res[i]; |
409 | phys = pgoff * PAGE_SIZE + res->start; | 409 | phys = pgoff * PAGE_SIZE + res->start; |
410 | if (phys >= res->start && phys <= res->end) | 410 | if (phys >= res->start && phys <= res->end) |
411 | break; | 411 | break; |
412 | pgoff -= PHYS_PFN(resource_size(res)); | 412 | pgoff -= PHYS_PFN(resource_size(res)); |
413 | } | 413 | } |
414 | 414 | ||
415 | if (i < dax_dev->num_resources) { | 415 | if (i < dev_dax->num_resources) { |
416 | res = &dax_dev->res[i]; | 416 | res = &dev_dax->res[i]; |
417 | if (phys + size - 1 <= res->end) | 417 | if (phys + size - 1 <= res->end) |
418 | return phys; | 418 | return phys; |
419 | } | 419 | } |
@@ -421,19 +421,19 @@ static phys_addr_t pgoff_to_phys(struct dax_dev *dax_dev, pgoff_t pgoff, | |||
421 | return -1; | 421 | return -1; |
422 | } | 422 | } |
423 | 423 | ||
424 | static int __dax_dev_pte_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | 424 | static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) |
425 | { | 425 | { |
426 | struct device *dev = &dax_dev->dev; | 426 | struct device *dev = &dev_dax->dev; |
427 | struct dax_region *dax_region; | 427 | struct dax_region *dax_region; |
428 | int rc = VM_FAULT_SIGBUS; | 428 | int rc = VM_FAULT_SIGBUS; |
429 | phys_addr_t phys; | 429 | phys_addr_t phys; |
430 | pfn_t pfn; | 430 | pfn_t pfn; |
431 | unsigned int fault_size = PAGE_SIZE; | 431 | unsigned int fault_size = PAGE_SIZE; |
432 | 432 | ||
433 | if (check_vma(dax_dev, vmf->vma, __func__)) | 433 | if (check_vma(dev_dax, vmf->vma, __func__)) |
434 | return VM_FAULT_SIGBUS; | 434 | return VM_FAULT_SIGBUS; |
435 | 435 | ||
436 | dax_region = dax_dev->region; | 436 | dax_region = dev_dax->region; |
437 | if (dax_region->align > PAGE_SIZE) { | 437 | if (dax_region->align > PAGE_SIZE) { |
438 | dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n", | 438 | dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n", |
439 | __func__, dax_region->align, fault_size); | 439 | __func__, dax_region->align, fault_size); |
@@ -443,7 +443,7 @@ static int __dax_dev_pte_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | |||
443 | if (fault_size != dax_region->align) | 443 | if (fault_size != dax_region->align) |
444 | return VM_FAULT_SIGBUS; | 444 | return VM_FAULT_SIGBUS; |
445 | 445 | ||
446 | phys = pgoff_to_phys(dax_dev, vmf->pgoff, PAGE_SIZE); | 446 | phys = pgoff_to_phys(dev_dax, vmf->pgoff, PAGE_SIZE); |
447 | if (phys == -1) { | 447 | if (phys == -1) { |
448 | dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__, | 448 | dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__, |
449 | vmf->pgoff); | 449 | vmf->pgoff); |
@@ -462,20 +462,20 @@ static int __dax_dev_pte_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | |||
462 | return VM_FAULT_NOPAGE; | 462 | return VM_FAULT_NOPAGE; |
463 | } | 463 | } |
464 | 464 | ||
465 | static int __dax_dev_pmd_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | 465 | static int __dev_dax_pmd_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) |
466 | { | 466 | { |
467 | unsigned long pmd_addr = vmf->address & PMD_MASK; | 467 | unsigned long pmd_addr = vmf->address & PMD_MASK; |
468 | struct device *dev = &dax_dev->dev; | 468 | struct device *dev = &dev_dax->dev; |
469 | struct dax_region *dax_region; | 469 | struct dax_region *dax_region; |
470 | phys_addr_t phys; | 470 | phys_addr_t phys; |
471 | pgoff_t pgoff; | 471 | pgoff_t pgoff; |
472 | pfn_t pfn; | 472 | pfn_t pfn; |
473 | unsigned int fault_size = PMD_SIZE; | 473 | unsigned int fault_size = PMD_SIZE; |
474 | 474 | ||
475 | if (check_vma(dax_dev, vmf->vma, __func__)) | 475 | if (check_vma(dev_dax, vmf->vma, __func__)) |
476 | return VM_FAULT_SIGBUS; | 476 | return VM_FAULT_SIGBUS; |
477 | 477 | ||
478 | dax_region = dax_dev->region; | 478 | dax_region = dev_dax->region; |
479 | if (dax_region->align > PMD_SIZE) { | 479 | if (dax_region->align > PMD_SIZE) { |
480 | dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n", | 480 | dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n", |
481 | __func__, dax_region->align, fault_size); | 481 | __func__, dax_region->align, fault_size); |
@@ -499,7 +499,7 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | |||
499 | return VM_FAULT_SIGBUS; | 499 | return VM_FAULT_SIGBUS; |
500 | 500 | ||
501 | pgoff = linear_page_index(vmf->vma, pmd_addr); | 501 | pgoff = linear_page_index(vmf->vma, pmd_addr); |
502 | phys = pgoff_to_phys(dax_dev, pgoff, PMD_SIZE); | 502 | phys = pgoff_to_phys(dev_dax, pgoff, PMD_SIZE); |
503 | if (phys == -1) { | 503 | if (phys == -1) { |
504 | dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__, | 504 | dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__, |
505 | pgoff); | 505 | pgoff); |
@@ -513,10 +513,10 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | |||
513 | } | 513 | } |
514 | 514 | ||
515 | #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD | 515 | #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD |
516 | static int __dax_dev_pud_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | 516 | static int __dev_dax_pud_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) |
517 | { | 517 | { |
518 | unsigned long pud_addr = vmf->address & PUD_MASK; | 518 | unsigned long pud_addr = vmf->address & PUD_MASK; |
519 | struct device *dev = &dax_dev->dev; | 519 | struct device *dev = &dev_dax->dev; |
520 | struct dax_region *dax_region; | 520 | struct dax_region *dax_region; |
521 | phys_addr_t phys; | 521 | phys_addr_t phys; |
522 | pgoff_t pgoff; | 522 | pgoff_t pgoff; |
@@ -524,10 +524,10 @@ static int __dax_dev_pud_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | |||
524 | unsigned int fault_size = PUD_SIZE; | 524 | unsigned int fault_size = PUD_SIZE; |
525 | 525 | ||
526 | 526 | ||
527 | if (check_vma(dax_dev, vmf->vma, __func__)) | 527 | if (check_vma(dev_dax, vmf->vma, __func__)) |
528 | return VM_FAULT_SIGBUS; | 528 | return VM_FAULT_SIGBUS; |
529 | 529 | ||
530 | dax_region = dax_dev->region; | 530 | dax_region = dev_dax->region; |
531 | if (dax_region->align > PUD_SIZE) { | 531 | if (dax_region->align > PUD_SIZE) { |
532 | dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n", | 532 | dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n", |
533 | __func__, dax_region->align, fault_size); | 533 | __func__, dax_region->align, fault_size); |
@@ -551,7 +551,7 @@ static int __dax_dev_pud_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | |||
551 | return VM_FAULT_SIGBUS; | 551 | return VM_FAULT_SIGBUS; |
552 | 552 | ||
553 | pgoff = linear_page_index(vmf->vma, pud_addr); | 553 | pgoff = linear_page_index(vmf->vma, pud_addr); |
554 | phys = pgoff_to_phys(dax_dev, pgoff, PUD_SIZE); | 554 | phys = pgoff_to_phys(dev_dax, pgoff, PUD_SIZE); |
555 | if (phys == -1) { | 555 | if (phys == -1) { |
556 | dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__, | 556 | dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__, |
557 | pgoff); | 557 | pgoff); |
@@ -564,20 +564,20 @@ static int __dax_dev_pud_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | |||
564 | vmf->flags & FAULT_FLAG_WRITE); | 564 | vmf->flags & FAULT_FLAG_WRITE); |
565 | } | 565 | } |
566 | #else | 566 | #else |
567 | static int __dax_dev_pud_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | 567 | static int __dev_dax_pud_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) |
568 | { | 568 | { |
569 | return VM_FAULT_FALLBACK; | 569 | return VM_FAULT_FALLBACK; |
570 | } | 570 | } |
571 | #endif /* !CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ | 571 | #endif /* !CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ |
572 | 572 | ||
573 | static int dax_dev_huge_fault(struct vm_fault *vmf, | 573 | static int dev_dax_huge_fault(struct vm_fault *vmf, |
574 | enum page_entry_size pe_size) | 574 | enum page_entry_size pe_size) |
575 | { | 575 | { |
576 | int rc, id; | 576 | int rc, id; |
577 | struct file *filp = vmf->vma->vm_file; | 577 | struct file *filp = vmf->vma->vm_file; |
578 | struct dax_dev *dax_dev = filp->private_data; | 578 | struct dev_dax *dev_dax = filp->private_data; |
579 | 579 | ||
580 | dev_dbg(&dax_dev->dev, "%s: %s: %s (%#lx - %#lx) size = %d\n", __func__, | 580 | dev_dbg(&dev_dax->dev, "%s: %s: %s (%#lx - %#lx) size = %d\n", __func__, |
581 | current->comm, (vmf->flags & FAULT_FLAG_WRITE) | 581 | current->comm, (vmf->flags & FAULT_FLAG_WRITE) |
582 | ? "write" : "read", | 582 | ? "write" : "read", |
583 | vmf->vma->vm_start, vmf->vma->vm_end, pe_size); | 583 | vmf->vma->vm_start, vmf->vma->vm_end, pe_size); |
@@ -585,13 +585,13 @@ static int dax_dev_huge_fault(struct vm_fault *vmf, | |||
585 | id = srcu_read_lock(&dax_srcu); | 585 | id = srcu_read_lock(&dax_srcu); |
586 | switch (pe_size) { | 586 | switch (pe_size) { |
587 | case PE_SIZE_PTE: | 587 | case PE_SIZE_PTE: |
588 | rc = __dax_dev_pte_fault(dax_dev, vmf); | 588 | rc = __dev_dax_pte_fault(dev_dax, vmf); |
589 | break; | 589 | break; |
590 | case PE_SIZE_PMD: | 590 | case PE_SIZE_PMD: |
591 | rc = __dax_dev_pmd_fault(dax_dev, vmf); | 591 | rc = __dev_dax_pmd_fault(dev_dax, vmf); |
592 | break; | 592 | break; |
593 | case PE_SIZE_PUD: | 593 | case PE_SIZE_PUD: |
594 | rc = __dax_dev_pud_fault(dax_dev, vmf); | 594 | rc = __dev_dax_pud_fault(dev_dax, vmf); |
595 | break; | 595 | break; |
596 | default: | 596 | default: |
597 | rc = VM_FAULT_SIGBUS; | 597 | rc = VM_FAULT_SIGBUS; |
@@ -601,28 +601,28 @@ static int dax_dev_huge_fault(struct vm_fault *vmf, | |||
601 | return rc; | 601 | return rc; |
602 | } | 602 | } |
603 | 603 | ||
604 | static int dax_dev_fault(struct vm_fault *vmf) | 604 | static int dev_dax_fault(struct vm_fault *vmf) |
605 | { | 605 | { |
606 | return dax_dev_huge_fault(vmf, PE_SIZE_PTE); | 606 | return dev_dax_huge_fault(vmf, PE_SIZE_PTE); |
607 | } | 607 | } |
608 | 608 | ||
609 | static const struct vm_operations_struct dax_dev_vm_ops = { | 609 | static const struct vm_operations_struct dax_vm_ops = { |
610 | .fault = dax_dev_fault, | 610 | .fault = dev_dax_fault, |
611 | .huge_fault = dax_dev_huge_fault, | 611 | .huge_fault = dev_dax_huge_fault, |
612 | }; | 612 | }; |
613 | 613 | ||
614 | static int dax_mmap(struct file *filp, struct vm_area_struct *vma) | 614 | static int dax_mmap(struct file *filp, struct vm_area_struct *vma) |
615 | { | 615 | { |
616 | struct dax_dev *dax_dev = filp->private_data; | 616 | struct dev_dax *dev_dax = filp->private_data; |
617 | int rc; | 617 | int rc; |
618 | 618 | ||
619 | dev_dbg(&dax_dev->dev, "%s\n", __func__); | 619 | dev_dbg(&dev_dax->dev, "%s\n", __func__); |
620 | 620 | ||
621 | rc = check_vma(dax_dev, vma, __func__); | 621 | rc = check_vma(dev_dax, vma, __func__); |
622 | if (rc) | 622 | if (rc) |
623 | return rc; | 623 | return rc; |
624 | 624 | ||
625 | vma->vm_ops = &dax_dev_vm_ops; | 625 | vma->vm_ops = &dax_vm_ops; |
626 | vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; | 626 | vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; |
627 | return 0; | 627 | return 0; |
628 | } | 628 | } |
@@ -633,13 +633,13 @@ static unsigned long dax_get_unmapped_area(struct file *filp, | |||
633 | unsigned long flags) | 633 | unsigned long flags) |
634 | { | 634 | { |
635 | unsigned long off, off_end, off_align, len_align, addr_align, align; | 635 | unsigned long off, off_end, off_align, len_align, addr_align, align; |
636 | struct dax_dev *dax_dev = filp ? filp->private_data : NULL; | 636 | struct dev_dax *dev_dax = filp ? filp->private_data : NULL; |
637 | struct dax_region *dax_region; | 637 | struct dax_region *dax_region; |
638 | 638 | ||
639 | if (!dax_dev || addr) | 639 | if (!dev_dax || addr) |
640 | goto out; | 640 | goto out; |
641 | 641 | ||
642 | dax_region = dax_dev->region; | 642 | dax_region = dev_dax->region; |
643 | align = dax_region->align; | 643 | align = dax_region->align; |
644 | off = pgoff << PAGE_SHIFT; | 644 | off = pgoff << PAGE_SHIFT; |
645 | off_end = off + len; | 645 | off_end = off + len; |
@@ -664,14 +664,14 @@ static unsigned long dax_get_unmapped_area(struct file *filp, | |||
664 | 664 | ||
665 | static int dax_open(struct inode *inode, struct file *filp) | 665 | static int dax_open(struct inode *inode, struct file *filp) |
666 | { | 666 | { |
667 | struct dax_dev *dax_dev; | 667 | struct dev_dax *dev_dax; |
668 | 668 | ||
669 | dax_dev = container_of(inode->i_cdev, struct dax_dev, cdev); | 669 | dev_dax = container_of(inode->i_cdev, struct dev_dax, cdev); |
670 | dev_dbg(&dax_dev->dev, "%s\n", __func__); | 670 | dev_dbg(&dev_dax->dev, "%s\n", __func__); |
671 | inode->i_mapping = dax_dev->inode->i_mapping; | 671 | inode->i_mapping = dev_dax->inode->i_mapping; |
672 | inode->i_mapping->host = dax_dev->inode; | 672 | inode->i_mapping->host = dev_dax->inode; |
673 | filp->f_mapping = inode->i_mapping; | 673 | filp->f_mapping = inode->i_mapping; |
674 | filp->private_data = dax_dev; | 674 | filp->private_data = dev_dax; |
675 | inode->i_flags = S_DAX; | 675 | inode->i_flags = S_DAX; |
676 | 676 | ||
677 | return 0; | 677 | return 0; |
@@ -679,9 +679,9 @@ static int dax_open(struct inode *inode, struct file *filp) | |||
679 | 679 | ||
680 | static int dax_release(struct inode *inode, struct file *filp) | 680 | static int dax_release(struct inode *inode, struct file *filp) |
681 | { | 681 | { |
682 | struct dax_dev *dax_dev = filp->private_data; | 682 | struct dev_dax *dev_dax = filp->private_data; |
683 | 683 | ||
684 | dev_dbg(&dax_dev->dev, "%s\n", __func__); | 684 | dev_dbg(&dev_dax->dev, "%s\n", __func__); |
685 | return 0; | 685 | return 0; |
686 | } | 686 | } |
687 | 687 | ||
@@ -694,55 +694,55 @@ static const struct file_operations dax_fops = { | |||
694 | .mmap = dax_mmap, | 694 | .mmap = dax_mmap, |
695 | }; | 695 | }; |
696 | 696 | ||
697 | static void dax_dev_release(struct device *dev) | 697 | static void dev_dax_release(struct device *dev) |
698 | { | 698 | { |
699 | struct dax_dev *dax_dev = to_dax_dev(dev); | 699 | struct dev_dax *dev_dax = to_dev_dax(dev); |
700 | struct dax_region *dax_region = dax_dev->region; | 700 | struct dax_region *dax_region = dev_dax->region; |
701 | 701 | ||
702 | ida_simple_remove(&dax_region->ida, dax_dev->id); | 702 | ida_simple_remove(&dax_region->ida, dev_dax->id); |
703 | ida_simple_remove(&dax_minor_ida, MINOR(dev->devt)); | 703 | ida_simple_remove(&dax_minor_ida, MINOR(dev->devt)); |
704 | dax_region_put(dax_region); | 704 | dax_region_put(dax_region); |
705 | iput(dax_dev->inode); | 705 | iput(dev_dax->inode); |
706 | kfree(dax_dev); | 706 | kfree(dev_dax); |
707 | } | 707 | } |
708 | 708 | ||
709 | static void kill_dax_dev(struct dax_dev *dax_dev) | 709 | static void kill_dev_dax(struct dev_dax *dev_dax) |
710 | { | 710 | { |
711 | /* | 711 | /* |
712 | * Note, rcu is not protecting the liveness of dax_dev, rcu is | 712 | * Note, rcu is not protecting the liveness of dev_dax, rcu is |
713 | * ensuring that any fault handlers that might have seen | 713 | * ensuring that any fault handlers that might have seen |
714 | * dax_dev->alive == true, have completed. Any fault handlers | 714 | * dev_dax->alive == true, have completed. Any fault handlers |
715 | * that start after synchronize_srcu() has started will abort | 715 | * that start after synchronize_srcu() has started will abort |
716 | * upon seeing dax_dev->alive == false. | 716 | * upon seeing dev_dax->alive == false. |
717 | */ | 717 | */ |
718 | dax_dev->alive = false; | 718 | dev_dax->alive = false; |
719 | synchronize_srcu(&dax_srcu); | 719 | synchronize_srcu(&dax_srcu); |
720 | unmap_mapping_range(dax_dev->inode->i_mapping, 0, 0, 1); | 720 | unmap_mapping_range(dev_dax->inode->i_mapping, 0, 0, 1); |
721 | } | 721 | } |
722 | 722 | ||
723 | static void unregister_dax_dev(void *dev) | 723 | static void unregister_dev_dax(void *dev) |
724 | { | 724 | { |
725 | struct dax_dev *dax_dev = to_dax_dev(dev); | 725 | struct dev_dax *dev_dax = to_dev_dax(dev); |
726 | 726 | ||
727 | dev_dbg(dev, "%s\n", __func__); | 727 | dev_dbg(dev, "%s\n", __func__); |
728 | 728 | ||
729 | kill_dax_dev(dax_dev); | 729 | kill_dev_dax(dev_dax); |
730 | cdev_device_del(&dax_dev->cdev, dev); | 730 | cdev_device_del(&dev_dax->cdev, dev); |
731 | put_device(dev); | 731 | put_device(dev); |
732 | } | 732 | } |
733 | 733 | ||
734 | struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region, | 734 | struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, |
735 | struct resource *res, int count) | 735 | struct resource *res, int count) |
736 | { | 736 | { |
737 | struct device *parent = dax_region->dev; | 737 | struct device *parent = dax_region->dev; |
738 | struct dax_dev *dax_dev; | 738 | struct dev_dax *dev_dax; |
739 | int rc = 0, minor, i; | 739 | int rc = 0, minor, i; |
740 | struct device *dev; | 740 | struct device *dev; |
741 | struct cdev *cdev; | 741 | struct cdev *cdev; |
742 | dev_t dev_t; | 742 | dev_t dev_t; |
743 | 743 | ||
744 | dax_dev = kzalloc(sizeof(*dax_dev) + sizeof(*res) * count, GFP_KERNEL); | 744 | dev_dax = kzalloc(sizeof(*dev_dax) + sizeof(*res) * count, GFP_KERNEL); |
745 | if (!dax_dev) | 745 | if (!dev_dax) |
746 | return ERR_PTR(-ENOMEM); | 746 | return ERR_PTR(-ENOMEM); |
747 | 747 | ||
748 | for (i = 0; i < count; i++) { | 748 | for (i = 0; i < count; i++) { |
@@ -752,16 +752,16 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region, | |||
752 | rc = -EINVAL; | 752 | rc = -EINVAL; |
753 | break; | 753 | break; |
754 | } | 754 | } |
755 | dax_dev->res[i].start = res[i].start; | 755 | dev_dax->res[i].start = res[i].start; |
756 | dax_dev->res[i].end = res[i].end; | 756 | dev_dax->res[i].end = res[i].end; |
757 | } | 757 | } |
758 | 758 | ||
759 | if (i < count) | 759 | if (i < count) |
760 | goto err_id; | 760 | goto err_id; |
761 | 761 | ||
762 | dax_dev->id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL); | 762 | dev_dax->id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL); |
763 | if (dax_dev->id < 0) { | 763 | if (dev_dax->id < 0) { |
764 | rc = dax_dev->id; | 764 | rc = dev_dax->id; |
765 | goto err_id; | 765 | goto err_id; |
766 | } | 766 | } |
767 | 767 | ||
@@ -772,55 +772,55 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region, | |||
772 | } | 772 | } |
773 | 773 | ||
774 | dev_t = MKDEV(MAJOR(dax_devt), minor); | 774 | dev_t = MKDEV(MAJOR(dax_devt), minor); |
775 | dev = &dax_dev->dev; | 775 | dev = &dev_dax->dev; |
776 | dax_dev->inode = dax_inode_get(&dax_dev->cdev, dev_t); | 776 | dev_dax->inode = dax_inode_get(&dev_dax->cdev, dev_t); |
777 | if (!dax_dev->inode) { | 777 | if (!dev_dax->inode) { |
778 | rc = -ENOMEM; | 778 | rc = -ENOMEM; |
779 | goto err_inode; | 779 | goto err_inode; |
780 | } | 780 | } |
781 | 781 | ||
782 | /* from here on we're committed to teardown via dax_dev_release() */ | 782 | /* from here on we're committed to teardown via dev_dax_release() */ |
783 | device_initialize(dev); | 783 | device_initialize(dev); |
784 | 784 | ||
785 | cdev = &dax_dev->cdev; | 785 | cdev = &dev_dax->cdev; |
786 | cdev_init(cdev, &dax_fops); | 786 | cdev_init(cdev, &dax_fops); |
787 | cdev->owner = parent->driver->owner; | 787 | cdev->owner = parent->driver->owner; |
788 | 788 | ||
789 | dax_dev->num_resources = count; | 789 | dev_dax->num_resources = count; |
790 | dax_dev->alive = true; | 790 | dev_dax->alive = true; |
791 | dax_dev->region = dax_region; | 791 | dev_dax->region = dax_region; |
792 | kref_get(&dax_region->kref); | 792 | kref_get(&dax_region->kref); |
793 | 793 | ||
794 | dev->devt = dev_t; | 794 | dev->devt = dev_t; |
795 | dev->class = dax_class; | 795 | dev->class = dax_class; |
796 | dev->parent = parent; | 796 | dev->parent = parent; |
797 | dev->groups = dax_attribute_groups; | 797 | dev->groups = dax_attribute_groups; |
798 | dev->release = dax_dev_release; | 798 | dev->release = dev_dax_release; |
799 | dev_set_name(dev, "dax%d.%d", dax_region->id, dax_dev->id); | 799 | dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id); |
800 | 800 | ||
801 | rc = cdev_device_add(cdev, dev); | 801 | rc = cdev_device_add(cdev, dev); |
802 | if (rc) { | 802 | if (rc) { |
803 | kill_dax_dev(dax_dev); | 803 | kill_dev_dax(dev_dax); |
804 | put_device(dev); | 804 | put_device(dev); |
805 | return ERR_PTR(rc); | 805 | return ERR_PTR(rc); |
806 | } | 806 | } |
807 | 807 | ||
808 | rc = devm_add_action_or_reset(dax_region->dev, unregister_dax_dev, dev); | 808 | rc = devm_add_action_or_reset(dax_region->dev, unregister_dev_dax, dev); |
809 | if (rc) | 809 | if (rc) |
810 | return ERR_PTR(rc); | 810 | return ERR_PTR(rc); |
811 | 811 | ||
812 | return dax_dev; | 812 | return dev_dax; |
813 | 813 | ||
814 | err_inode: | 814 | err_inode: |
815 | ida_simple_remove(&dax_minor_ida, minor); | 815 | ida_simple_remove(&dax_minor_ida, minor); |
816 | err_minor: | 816 | err_minor: |
817 | ida_simple_remove(&dax_region->ida, dax_dev->id); | 817 | ida_simple_remove(&dax_region->ida, dev_dax->id); |
818 | err_id: | 818 | err_id: |
819 | kfree(dax_dev); | 819 | kfree(dev_dax); |
820 | 820 | ||
821 | return ERR_PTR(rc); | 821 | return ERR_PTR(rc); |
822 | } | 822 | } |
823 | EXPORT_SYMBOL_GPL(devm_create_dax_dev); | 823 | EXPORT_SYMBOL_GPL(devm_create_dev_dax); |
824 | 824 | ||
825 | static int __init dax_init(void) | 825 | static int __init dax_init(void) |
826 | { | 826 | { |
diff --git a/drivers/dax/dax.h b/drivers/dax/dax.h index ddd829ab58c0..ea176d875d60 100644 --- a/drivers/dax/dax.h +++ b/drivers/dax/dax.h | |||
@@ -13,13 +13,13 @@ | |||
13 | #ifndef __DAX_H__ | 13 | #ifndef __DAX_H__ |
14 | #define __DAX_H__ | 14 | #define __DAX_H__ |
15 | struct device; | 15 | struct device; |
16 | struct dax_dev; | 16 | struct dev_dax; |
17 | struct resource; | 17 | struct resource; |
18 | struct dax_region; | 18 | struct dax_region; |
19 | void dax_region_put(struct dax_region *dax_region); | 19 | void dax_region_put(struct dax_region *dax_region); |
20 | struct dax_region *alloc_dax_region(struct device *parent, | 20 | struct dax_region *alloc_dax_region(struct device *parent, |
21 | int region_id, struct resource *res, unsigned int align, | 21 | int region_id, struct resource *res, unsigned int align, |
22 | void *addr, unsigned long flags); | 22 | void *addr, unsigned long flags); |
23 | struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region, | 23 | struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, |
24 | struct resource *res, int count); | 24 | struct resource *res, int count); |
25 | #endif /* __DAX_H__ */ | 25 | #endif /* __DAX_H__ */ |
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c index 033f49b31fdc..2c736fc4508b 100644 --- a/drivers/dax/pmem.c +++ b/drivers/dax/pmem.c | |||
@@ -61,8 +61,8 @@ static int dax_pmem_probe(struct device *dev) | |||
61 | int rc; | 61 | int rc; |
62 | void *addr; | 62 | void *addr; |
63 | struct resource res; | 63 | struct resource res; |
64 | struct dax_dev *dax_dev; | ||
65 | struct nd_pfn_sb *pfn_sb; | 64 | struct nd_pfn_sb *pfn_sb; |
65 | struct dev_dax *dev_dax; | ||
66 | struct dax_pmem *dax_pmem; | 66 | struct dax_pmem *dax_pmem; |
67 | struct nd_region *nd_region; | 67 | struct nd_region *nd_region; |
68 | struct nd_namespace_io *nsio; | 68 | struct nd_namespace_io *nsio; |
@@ -130,12 +130,12 @@ static int dax_pmem_probe(struct device *dev) | |||
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | 131 | ||
132 | /* TODO: support for subdividing a dax region... */ | 132 | /* TODO: support for subdividing a dax region... */ |
133 | dax_dev = devm_create_dax_dev(dax_region, &res, 1); | 133 | dev_dax = devm_create_dev_dax(dax_region, &res, 1); |
134 | 134 | ||
135 | /* child dax_dev instances now own the lifetime of the dax_region */ | 135 | /* child dev_dax instances now own the lifetime of the dax_region */ |
136 | dax_region_put(dax_region); | 136 | dax_region_put(dax_region); |
137 | 137 | ||
138 | return PTR_ERR_OR_ZERO(dax_dev); | 138 | return PTR_ERR_OR_ZERO(dev_dax); |
139 | } | 139 | } |
140 | 140 | ||
141 | static struct nd_device_driver dax_pmem_driver = { | 141 | static struct nd_device_driver dax_pmem_driver = { |