diff options
129 files changed, 1463 insertions, 538 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 205d3977ac46..297e610c9163 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -7730,6 +7730,7 @@ Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ | |||
7730 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git | 7730 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git |
7731 | S: Supported | 7731 | S: Supported |
7732 | F: drivers/nvdimm/* | 7732 | F: drivers/nvdimm/* |
7733 | F: drivers/acpi/nfit/* | ||
7733 | F: include/linux/nd.h | 7734 | F: include/linux/nd.h |
7734 | F: include/linux/libnvdimm.h | 7735 | F: include/linux/libnvdimm.h |
7735 | F: include/uapi/linux/ndctl.h | 7736 | F: include/uapi/linux/ndctl.h |
@@ -7741,7 +7742,6 @@ Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ | |||
7741 | S: Supported | 7742 | S: Supported |
7742 | F: drivers/nvdimm/blk.c | 7743 | F: drivers/nvdimm/blk.c |
7743 | F: drivers/nvdimm/region_devs.c | 7744 | F: drivers/nvdimm/region_devs.c |
7744 | F: drivers/acpi/nfit* | ||
7745 | 7745 | ||
7746 | LIBNVDIMM BTT: BLOCK TRANSLATION TABLE | 7746 | LIBNVDIMM BTT: BLOCK TRANSLATION TABLE |
7747 | M: Vishal Verma <vishal.l.verma@intel.com> | 7747 | M: Vishal Verma <vishal.l.verma@intel.com> |
@@ -10868,6 +10868,14 @@ L: linux-scsi@vger.kernel.org | |||
10868 | S: Supported | 10868 | S: Supported |
10869 | F: drivers/scsi/qedf/ | 10869 | F: drivers/scsi/qedf/ |
10870 | 10870 | ||
10871 | QLOGIC QL4xxx RDMA DRIVER | ||
10872 | M: Ram Amrani <Ram.Amrani@cavium.com> | ||
10873 | M: Ariel Elior <Ariel.Elior@cavium.com> | ||
10874 | L: linux-rdma@vger.kernel.org | ||
10875 | S: Supported | ||
10876 | F: drivers/infiniband/hw/qedr/ | ||
10877 | F: include/uapi/rdma/qedr-abi.h | ||
10878 | |||
10871 | QNX4 FILESYSTEM | 10879 | QNX4 FILESYSTEM |
10872 | M: Anders Larsen <al@alarsen.net> | 10880 | M: Anders Larsen <al@alarsen.net> |
10873 | W: http://www.alarsen.net/linux/qnx4fs/ | 10881 | W: http://www.alarsen.net/linux/qnx4fs/ |
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h index d69bebf697e7..74504b154256 100644 --- a/arch/arm/include/asm/cacheflush.h +++ b/arch/arm/include/asm/cacheflush.h | |||
@@ -116,7 +116,7 @@ struct cpu_cache_fns { | |||
116 | void (*dma_unmap_area)(const void *, size_t, int); | 116 | void (*dma_unmap_area)(const void *, size_t, int); |
117 | 117 | ||
118 | void (*dma_flush_range)(const void *, const void *); | 118 | void (*dma_flush_range)(const void *, const void *); |
119 | }; | 119 | } __no_randomize_layout; |
120 | 120 | ||
121 | /* | 121 | /* |
122 | * Select the calling method | 122 | * Select the calling method |
diff --git a/arch/blackfin/kernel/flat.c b/arch/blackfin/kernel/flat.c index d29ab6a2e909..8ebc54daaa8e 100644 --- a/arch/blackfin/kernel/flat.c +++ b/arch/blackfin/kernel/flat.c | |||
@@ -32,7 +32,7 @@ unsigned long bfin_get_addr_from_rp(u32 *ptr, | |||
32 | break; | 32 | break; |
33 | 33 | ||
34 | case FLAT_BFIN_RELOC_TYPE_32_BIT: | 34 | case FLAT_BFIN_RELOC_TYPE_32_BIT: |
35 | pr_debug("*ptr = %lx", get_unaligned(ptr)); | 35 | pr_debug("*ptr = %x", get_unaligned(ptr)); |
36 | val = get_unaligned(ptr); | 36 | val = get_unaligned(ptr); |
37 | break; | 37 | break; |
38 | 38 | ||
@@ -77,7 +77,7 @@ void bfin_put_addr_at_rp(u32 *ptr, u32 addr, u32 relval) | |||
77 | 77 | ||
78 | case FLAT_BFIN_RELOC_TYPE_32_BIT: | 78 | case FLAT_BFIN_RELOC_TYPE_32_BIT: |
79 | put_unaligned(addr, ptr); | 79 | put_unaligned(addr, ptr); |
80 | pr_debug("new ptr =%lx", get_unaligned(ptr)); | 80 | pr_debug("new ptr =%x", get_unaligned(ptr)); |
81 | break; | 81 | break; |
82 | } | 82 | } |
83 | } | 83 | } |
diff --git a/arch/sparc/include/asm/trap_block.h b/arch/sparc/include/asm/trap_block.h index ec9c04de3664..ff05992dae7a 100644 --- a/arch/sparc/include/asm/trap_block.h +++ b/arch/sparc/include/asm/trap_block.h | |||
@@ -54,6 +54,7 @@ extern struct trap_per_cpu trap_block[NR_CPUS]; | |||
54 | void init_cur_cpu_trap(struct thread_info *); | 54 | void init_cur_cpu_trap(struct thread_info *); |
55 | void setup_tba(void); | 55 | void setup_tba(void); |
56 | extern int ncpus_probed; | 56 | extern int ncpus_probed; |
57 | extern u64 cpu_mondo_counter[NR_CPUS]; | ||
57 | 58 | ||
58 | unsigned long real_hard_smp_processor_id(void); | 59 | unsigned long real_hard_smp_processor_id(void); |
59 | 60 | ||
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index 24f21c726dfa..f10e2f712394 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c | |||
@@ -673,12 +673,14 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist, | |||
673 | static int dma_4v_supported(struct device *dev, u64 device_mask) | 673 | static int dma_4v_supported(struct device *dev, u64 device_mask) |
674 | { | 674 | { |
675 | struct iommu *iommu = dev->archdata.iommu; | 675 | struct iommu *iommu = dev->archdata.iommu; |
676 | u64 dma_addr_mask; | 676 | u64 dma_addr_mask = iommu->dma_addr_mask; |
677 | 677 | ||
678 | if (device_mask > DMA_BIT_MASK(32) && iommu->atu) | 678 | if (device_mask > DMA_BIT_MASK(32)) { |
679 | dma_addr_mask = iommu->atu->dma_addr_mask; | 679 | if (iommu->atu) |
680 | else | 680 | dma_addr_mask = iommu->atu->dma_addr_mask; |
681 | dma_addr_mask = iommu->dma_addr_mask; | 681 | else |
682 | return 0; | ||
683 | } | ||
682 | 684 | ||
683 | if ((device_mask & dma_addr_mask) == dma_addr_mask) | 685 | if ((device_mask & dma_addr_mask) == dma_addr_mask) |
684 | return 1; | 686 | return 1; |
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index fdf31040a7dc..3218bc43302e 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c | |||
@@ -622,22 +622,48 @@ retry: | |||
622 | } | 622 | } |
623 | } | 623 | } |
624 | 624 | ||
625 | /* Multi-cpu list version. */ | 625 | #define CPU_MONDO_COUNTER(cpuid) (cpu_mondo_counter[cpuid]) |
626 | #define MONDO_USEC_WAIT_MIN 2 | ||
627 | #define MONDO_USEC_WAIT_MAX 100 | ||
628 | #define MONDO_RETRY_LIMIT 500000 | ||
629 | |||
630 | /* Multi-cpu list version. | ||
631 | * | ||
632 | * Deliver xcalls to 'cnt' number of cpus in 'cpu_list'. | ||
633 | * Sometimes not all cpus receive the mondo, requiring us to re-send | ||
634 | * the mondo until all cpus have received, or cpus are truly stuck | ||
635 | * unable to receive mondo, and we timeout. | ||
636 | * Occasionally a target cpu strand is borrowed briefly by hypervisor to | ||
637 | * perform guest service, such as PCIe error handling. Consider the | ||
638 | * service time, 1 second overall wait is reasonable for 1 cpu. | ||
639 | * Here two in-between mondo check wait time are defined: 2 usec for | ||
640 | * single cpu quick turn around and up to 100usec for large cpu count. | ||
641 | * Deliver mondo to large number of cpus could take longer, we adjusts | ||
642 | * the retry count as long as target cpus are making forward progress. | ||
643 | */ | ||
626 | static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) | 644 | static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) |
627 | { | 645 | { |
628 | int retries, this_cpu, prev_sent, i, saw_cpu_error; | 646 | int this_cpu, tot_cpus, prev_sent, i, rem; |
647 | int usec_wait, retries, tot_retries; | ||
648 | u16 first_cpu = 0xffff; | ||
649 | unsigned long xc_rcvd = 0; | ||
629 | unsigned long status; | 650 | unsigned long status; |
651 | int ecpuerror_id = 0; | ||
652 | int enocpu_id = 0; | ||
630 | u16 *cpu_list; | 653 | u16 *cpu_list; |
654 | u16 cpu; | ||
631 | 655 | ||
632 | this_cpu = smp_processor_id(); | 656 | this_cpu = smp_processor_id(); |
633 | |||
634 | cpu_list = __va(tb->cpu_list_pa); | 657 | cpu_list = __va(tb->cpu_list_pa); |
635 | 658 | usec_wait = cnt * MONDO_USEC_WAIT_MIN; | |
636 | saw_cpu_error = 0; | 659 | if (usec_wait > MONDO_USEC_WAIT_MAX) |
637 | retries = 0; | 660 | usec_wait = MONDO_USEC_WAIT_MAX; |
661 | retries = tot_retries = 0; | ||
662 | tot_cpus = cnt; | ||
638 | prev_sent = 0; | 663 | prev_sent = 0; |
664 | |||
639 | do { | 665 | do { |
640 | int forward_progress, n_sent; | 666 | int n_sent, mondo_delivered, target_cpu_busy; |
641 | 667 | ||
642 | status = sun4v_cpu_mondo_send(cnt, | 668 | status = sun4v_cpu_mondo_send(cnt, |
643 | tb->cpu_list_pa, | 669 | tb->cpu_list_pa, |
@@ -645,94 +671,113 @@ static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) | |||
645 | 671 | ||
646 | /* HV_EOK means all cpus received the xcall, we're done. */ | 672 | /* HV_EOK means all cpus received the xcall, we're done. */ |
647 | if (likely(status == HV_EOK)) | 673 | if (likely(status == HV_EOK)) |
648 | break; | 674 | goto xcall_done; |
675 | |||
676 | /* If not these non-fatal errors, panic */ | ||
677 | if (unlikely((status != HV_EWOULDBLOCK) && | ||
678 | (status != HV_ECPUERROR) && | ||
679 | (status != HV_ENOCPU))) | ||
680 | goto fatal_errors; | ||
649 | 681 | ||
650 | /* First, see if we made any forward progress. | 682 | /* First, see if we made any forward progress. |
651 | * | 683 | * |
684 | * Go through the cpu_list, count the target cpus that have | ||
685 | * received our mondo (n_sent), and those that did not (rem). | ||
686 | * Re-pack cpu_list with the cpus remain to be retried in the | ||
687 | * front - this simplifies tracking the truly stalled cpus. | ||
688 | * | ||
652 | * The hypervisor indicates successful sends by setting | 689 | * The hypervisor indicates successful sends by setting |
653 | * cpu list entries to the value 0xffff. | 690 | * cpu list entries to the value 0xffff. |
691 | * | ||
692 | * EWOULDBLOCK means some target cpus did not receive the | ||
693 | * mondo and retry usually helps. | ||
694 | * | ||
695 | * ECPUERROR means at least one target cpu is in error state, | ||
696 | * it's usually safe to skip the faulty cpu and retry. | ||
697 | * | ||
698 | * ENOCPU means one of the target cpu doesn't belong to the | ||
699 | * domain, perhaps offlined which is unexpected, but not | ||
700 | * fatal and it's okay to skip the offlined cpu. | ||
654 | */ | 701 | */ |
702 | rem = 0; | ||
655 | n_sent = 0; | 703 | n_sent = 0; |
656 | for (i = 0; i < cnt; i++) { | 704 | for (i = 0; i < cnt; i++) { |
657 | if (likely(cpu_list[i] == 0xffff)) | 705 | cpu = cpu_list[i]; |
706 | if (likely(cpu == 0xffff)) { | ||
658 | n_sent++; | 707 | n_sent++; |
708 | } else if ((status == HV_ECPUERROR) && | ||
709 | (sun4v_cpu_state(cpu) == HV_CPU_STATE_ERROR)) { | ||
710 | ecpuerror_id = cpu + 1; | ||
711 | } else if (status == HV_ENOCPU && !cpu_online(cpu)) { | ||
712 | enocpu_id = cpu + 1; | ||
713 | } else { | ||
714 | cpu_list[rem++] = cpu; | ||
715 | } | ||
659 | } | 716 | } |
660 | 717 | ||
661 | forward_progress = 0; | 718 | /* No cpu remained, we're done. */ |
662 | if (n_sent > prev_sent) | 719 | if (rem == 0) |
663 | forward_progress = 1; | 720 | break; |
664 | 721 | ||
665 | prev_sent = n_sent; | 722 | /* Otherwise, update the cpu count for retry. */ |
723 | cnt = rem; | ||
666 | 724 | ||
667 | /* If we get a HV_ECPUERROR, then one or more of the cpus | 725 | /* Record the overall number of mondos received by the |
668 | * in the list are in error state. Use the cpu_state() | 726 | * first of the remaining cpus. |
669 | * hypervisor call to find out which cpus are in error state. | ||
670 | */ | 727 | */ |
671 | if (unlikely(status == HV_ECPUERROR)) { | 728 | if (first_cpu != cpu_list[0]) { |
672 | for (i = 0; i < cnt; i++) { | 729 | first_cpu = cpu_list[0]; |
673 | long err; | 730 | xc_rcvd = CPU_MONDO_COUNTER(first_cpu); |
674 | u16 cpu; | 731 | } |
675 | 732 | ||
676 | cpu = cpu_list[i]; | 733 | /* Was any mondo delivered successfully? */ |
677 | if (cpu == 0xffff) | 734 | mondo_delivered = (n_sent > prev_sent); |
678 | continue; | 735 | prev_sent = n_sent; |
679 | 736 | ||
680 | err = sun4v_cpu_state(cpu); | 737 | /* or, was any target cpu busy processing other mondos? */ |
681 | if (err == HV_CPU_STATE_ERROR) { | 738 | target_cpu_busy = (xc_rcvd < CPU_MONDO_COUNTER(first_cpu)); |
682 | saw_cpu_error = (cpu + 1); | 739 | xc_rcvd = CPU_MONDO_COUNTER(first_cpu); |
683 | cpu_list[i] = 0xffff; | ||
684 | } | ||
685 | } | ||
686 | } else if (unlikely(status != HV_EWOULDBLOCK)) | ||
687 | goto fatal_mondo_error; | ||
688 | 740 | ||
689 | /* Don't bother rewriting the CPU list, just leave the | 741 | /* Retry count is for no progress. If we're making progress, |
690 | * 0xffff and non-0xffff entries in there and the | 742 | * reset the retry count. |
691 | * hypervisor will do the right thing. | ||
692 | * | ||
693 | * Only advance timeout state if we didn't make any | ||
694 | * forward progress. | ||
695 | */ | 743 | */ |
696 | if (unlikely(!forward_progress)) { | 744 | if (likely(mondo_delivered || target_cpu_busy)) { |
697 | if (unlikely(++retries > 10000)) | 745 | tot_retries += retries; |
698 | goto fatal_mondo_timeout; | 746 | retries = 0; |
699 | 747 | } else if (unlikely(retries > MONDO_RETRY_LIMIT)) { | |
700 | /* Delay a little bit to let other cpus catch up | 748 | goto fatal_mondo_timeout; |
701 | * on their cpu mondo queue work. | ||
702 | */ | ||
703 | udelay(2 * cnt); | ||
704 | } | 749 | } |
705 | } while (1); | ||
706 | 750 | ||
707 | if (unlikely(saw_cpu_error)) | 751 | /* Delay a little bit to let other cpus catch up on |
708 | goto fatal_mondo_cpu_error; | 752 | * their cpu mondo queue work. |
753 | */ | ||
754 | if (!mondo_delivered) | ||
755 | udelay(usec_wait); | ||
709 | 756 | ||
710 | return; | 757 | retries++; |
758 | } while (1); | ||
711 | 759 | ||
712 | fatal_mondo_cpu_error: | 760 | xcall_done: |
713 | printk(KERN_CRIT "CPU[%d]: SUN4V mondo cpu error, some target cpus " | 761 | if (unlikely(ecpuerror_id > 0)) { |
714 | "(including %d) were in error state\n", | 762 | pr_crit("CPU[%d]: SUN4V mondo cpu error, target cpu(%d) was in error state\n", |
715 | this_cpu, saw_cpu_error - 1); | 763 | this_cpu, ecpuerror_id - 1); |
764 | } else if (unlikely(enocpu_id > 0)) { | ||
765 | pr_crit("CPU[%d]: SUN4V mondo cpu error, target cpu(%d) does not belong to the domain\n", | ||
766 | this_cpu, enocpu_id - 1); | ||
767 | } | ||
716 | return; | 768 | return; |
717 | 769 | ||
770 | fatal_errors: | ||
771 | /* fatal errors include bad alignment, etc */ | ||
772 | pr_crit("CPU[%d]: Args were cnt(%d) cpulist_pa(%lx) mondo_block_pa(%lx)\n", | ||
773 | this_cpu, tot_cpus, tb->cpu_list_pa, tb->cpu_mondo_block_pa); | ||
774 | panic("Unexpected SUN4V mondo error %lu\n", status); | ||
775 | |||
718 | fatal_mondo_timeout: | 776 | fatal_mondo_timeout: |
719 | printk(KERN_CRIT "CPU[%d]: SUN4V mondo timeout, no forward " | 777 | /* some cpus being non-responsive to the cpu mondo */ |
720 | " progress after %d retries.\n", | 778 | pr_crit("CPU[%d]: SUN4V mondo timeout, cpu(%d) made no forward progress after %d retries. Total target cpus(%d).\n", |
721 | this_cpu, retries); | 779 | this_cpu, first_cpu, (tot_retries + retries), tot_cpus); |
722 | goto dump_cpu_list_and_out; | 780 | panic("SUN4V mondo timeout panic\n"); |
723 | |||
724 | fatal_mondo_error: | ||
725 | printk(KERN_CRIT "CPU[%d]: Unexpected SUN4V mondo error %lu\n", | ||
726 | this_cpu, status); | ||
727 | printk(KERN_CRIT "CPU[%d]: Args were cnt(%d) cpulist_pa(%lx) " | ||
728 | "mondo_block_pa(%lx)\n", | ||
729 | this_cpu, cnt, tb->cpu_list_pa, tb->cpu_mondo_block_pa); | ||
730 | |||
731 | dump_cpu_list_and_out: | ||
732 | printk(KERN_CRIT "CPU[%d]: CPU list [ ", this_cpu); | ||
733 | for (i = 0; i < cnt; i++) | ||
734 | printk("%u ", cpu_list[i]); | ||
735 | printk("]\n"); | ||
736 | } | 781 | } |
737 | 782 | ||
738 | static void (*xcall_deliver_impl)(struct trap_per_cpu *, int); | 783 | static void (*xcall_deliver_impl)(struct trap_per_cpu *, int); |
diff --git a/arch/sparc/kernel/sun4v_ivec.S b/arch/sparc/kernel/sun4v_ivec.S index 559bc5e9c199..34631995859a 100644 --- a/arch/sparc/kernel/sun4v_ivec.S +++ b/arch/sparc/kernel/sun4v_ivec.S | |||
@@ -26,6 +26,21 @@ sun4v_cpu_mondo: | |||
26 | ldxa [%g0] ASI_SCRATCHPAD, %g4 | 26 | ldxa [%g0] ASI_SCRATCHPAD, %g4 |
27 | sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4 | 27 | sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4 |
28 | 28 | ||
29 | /* Get smp_processor_id() into %g3 */ | ||
30 | sethi %hi(trap_block), %g5 | ||
31 | or %g5, %lo(trap_block), %g5 | ||
32 | sub %g4, %g5, %g3 | ||
33 | srlx %g3, TRAP_BLOCK_SZ_SHIFT, %g3 | ||
34 | |||
35 | /* Increment cpu_mondo_counter[smp_processor_id()] */ | ||
36 | sethi %hi(cpu_mondo_counter), %g5 | ||
37 | or %g5, %lo(cpu_mondo_counter), %g5 | ||
38 | sllx %g3, 3, %g3 | ||
39 | add %g5, %g3, %g5 | ||
40 | ldx [%g5], %g3 | ||
41 | add %g3, 1, %g3 | ||
42 | stx %g3, [%g5] | ||
43 | |||
29 | /* Get CPU mondo queue base phys address into %g7. */ | 44 | /* Get CPU mondo queue base phys address into %g7. */ |
30 | ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7 | 45 | ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7 |
31 | 46 | ||
diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c index 196ee5eb4d48..ad31af1dd726 100644 --- a/arch/sparc/kernel/traps_64.c +++ b/arch/sparc/kernel/traps_64.c | |||
@@ -2733,6 +2733,7 @@ void do_getpsr(struct pt_regs *regs) | |||
2733 | } | 2733 | } |
2734 | } | 2734 | } |
2735 | 2735 | ||
2736 | u64 cpu_mondo_counter[NR_CPUS] = {0}; | ||
2736 | struct trap_per_cpu trap_block[NR_CPUS]; | 2737 | struct trap_per_cpu trap_block[NR_CPUS]; |
2737 | EXPORT_SYMBOL(trap_block); | 2738 | EXPORT_SYMBOL(trap_block); |
2738 | 2739 | ||
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h index cb976bab6299..9ffc36bfe4cd 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h | |||
@@ -84,7 +84,7 @@ struct pv_init_ops { | |||
84 | */ | 84 | */ |
85 | unsigned (*patch)(u8 type, u16 clobber, void *insnbuf, | 85 | unsigned (*patch)(u8 type, u16 clobber, void *insnbuf, |
86 | unsigned long addr, unsigned len); | 86 | unsigned long addr, unsigned len); |
87 | }; | 87 | } __no_randomize_layout; |
88 | 88 | ||
89 | 89 | ||
90 | struct pv_lazy_ops { | 90 | struct pv_lazy_ops { |
@@ -92,12 +92,12 @@ struct pv_lazy_ops { | |||
92 | void (*enter)(void); | 92 | void (*enter)(void); |
93 | void (*leave)(void); | 93 | void (*leave)(void); |
94 | void (*flush)(void); | 94 | void (*flush)(void); |
95 | }; | 95 | } __no_randomize_layout; |
96 | 96 | ||
97 | struct pv_time_ops { | 97 | struct pv_time_ops { |
98 | unsigned long long (*sched_clock)(void); | 98 | unsigned long long (*sched_clock)(void); |
99 | unsigned long long (*steal_clock)(int cpu); | 99 | unsigned long long (*steal_clock)(int cpu); |
100 | }; | 100 | } __no_randomize_layout; |
101 | 101 | ||
102 | struct pv_cpu_ops { | 102 | struct pv_cpu_ops { |
103 | /* hooks for various privileged instructions */ | 103 | /* hooks for various privileged instructions */ |
@@ -176,7 +176,7 @@ struct pv_cpu_ops { | |||
176 | 176 | ||
177 | void (*start_context_switch)(struct task_struct *prev); | 177 | void (*start_context_switch)(struct task_struct *prev); |
178 | void (*end_context_switch)(struct task_struct *next); | 178 | void (*end_context_switch)(struct task_struct *next); |
179 | }; | 179 | } __no_randomize_layout; |
180 | 180 | ||
181 | struct pv_irq_ops { | 181 | struct pv_irq_ops { |
182 | /* | 182 | /* |
@@ -199,7 +199,7 @@ struct pv_irq_ops { | |||
199 | #ifdef CONFIG_X86_64 | 199 | #ifdef CONFIG_X86_64 |
200 | void (*adjust_exception_frame)(void); | 200 | void (*adjust_exception_frame)(void); |
201 | #endif | 201 | #endif |
202 | }; | 202 | } __no_randomize_layout; |
203 | 203 | ||
204 | struct pv_mmu_ops { | 204 | struct pv_mmu_ops { |
205 | unsigned long (*read_cr2)(void); | 205 | unsigned long (*read_cr2)(void); |
@@ -305,7 +305,7 @@ struct pv_mmu_ops { | |||
305 | an mfn. We can tell which is which from the index. */ | 305 | an mfn. We can tell which is which from the index. */ |
306 | void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx, | 306 | void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx, |
307 | phys_addr_t phys, pgprot_t flags); | 307 | phys_addr_t phys, pgprot_t flags); |
308 | }; | 308 | } __no_randomize_layout; |
309 | 309 | ||
310 | struct arch_spinlock; | 310 | struct arch_spinlock; |
311 | #ifdef CONFIG_SMP | 311 | #ifdef CONFIG_SMP |
@@ -322,7 +322,7 @@ struct pv_lock_ops { | |||
322 | void (*kick)(int cpu); | 322 | void (*kick)(int cpu); |
323 | 323 | ||
324 | struct paravirt_callee_save vcpu_is_preempted; | 324 | struct paravirt_callee_save vcpu_is_preempted; |
325 | }; | 325 | } __no_randomize_layout; |
326 | 326 | ||
327 | /* This contains all the paravirt structures: we get a convenient | 327 | /* This contains all the paravirt structures: we get a convenient |
328 | * number for each function using the offset which we use to indicate | 328 | * number for each function using the offset which we use to indicate |
@@ -334,7 +334,7 @@ struct paravirt_patch_template { | |||
334 | struct pv_irq_ops pv_irq_ops; | 334 | struct pv_irq_ops pv_irq_ops; |
335 | struct pv_mmu_ops pv_mmu_ops; | 335 | struct pv_mmu_ops pv_mmu_ops; |
336 | struct pv_lock_ops pv_lock_ops; | 336 | struct pv_lock_ops pv_lock_ops; |
337 | }; | 337 | } __no_randomize_layout; |
338 | 338 | ||
339 | extern struct pv_info pv_info; | 339 | extern struct pv_info pv_info; |
340 | extern struct pv_init_ops pv_init_ops; | 340 | extern struct pv_init_ops pv_init_ops; |
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 6a79547e8ee0..028245e1c42b 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -129,7 +129,7 @@ struct cpuinfo_x86 { | |||
129 | /* Index into per_cpu list: */ | 129 | /* Index into per_cpu list: */ |
130 | u16 cpu_index; | 130 | u16 cpu_index; |
131 | u32 microcode; | 131 | u32 microcode; |
132 | }; | 132 | } __randomize_layout; |
133 | 133 | ||
134 | struct cpuid_regs { | 134 | struct cpuid_regs { |
135 | u32 eax, ebx, ecx, edx; | 135 | u32 eax, ebx, ecx, edx; |
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index b75b734ee73a..19182d091587 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c | |||
@@ -3160,6 +3160,8 @@ static struct acpi_driver acpi_nfit_driver = { | |||
3160 | 3160 | ||
3161 | static __init int nfit_init(void) | 3161 | static __init int nfit_init(void) |
3162 | { | 3162 | { |
3163 | int ret; | ||
3164 | |||
3163 | BUILD_BUG_ON(sizeof(struct acpi_table_nfit) != 40); | 3165 | BUILD_BUG_ON(sizeof(struct acpi_table_nfit) != 40); |
3164 | BUILD_BUG_ON(sizeof(struct acpi_nfit_system_address) != 56); | 3166 | BUILD_BUG_ON(sizeof(struct acpi_nfit_system_address) != 56); |
3165 | BUILD_BUG_ON(sizeof(struct acpi_nfit_memory_map) != 48); | 3167 | BUILD_BUG_ON(sizeof(struct acpi_nfit_memory_map) != 48); |
@@ -3187,8 +3189,14 @@ static __init int nfit_init(void) | |||
3187 | return -ENOMEM; | 3189 | return -ENOMEM; |
3188 | 3190 | ||
3189 | nfit_mce_register(); | 3191 | nfit_mce_register(); |
3192 | ret = acpi_bus_register_driver(&acpi_nfit_driver); | ||
3193 | if (ret) { | ||
3194 | nfit_mce_unregister(); | ||
3195 | destroy_workqueue(nfit_wq); | ||
3196 | } | ||
3197 | |||
3198 | return ret; | ||
3190 | 3199 | ||
3191 | return acpi_bus_register_driver(&acpi_nfit_driver); | ||
3192 | } | 3200 | } |
3193 | 3201 | ||
3194 | static __exit void nfit_exit(void) | 3202 | static __exit void nfit_exit(void) |
diff --git a/drivers/base/regmap/regmap-w1.c b/drivers/base/regmap/regmap-w1.c index 5f04e7bf063e..e6c64b0be5b2 100644 --- a/drivers/base/regmap/regmap-w1.c +++ b/drivers/base/regmap/regmap-w1.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Register map access API - W1 (1-Wire) support | 2 | * Register map access API - W1 (1-Wire) support |
3 | * | 3 | * |
4 | * Copyright (C) 2017 OAO Radioavionica | 4 | * Copyright (c) 2017 Radioavionica Corporation |
5 | * Author: Alex A. Mihaylov <minimumlaw@rambler.ru> | 5 | * Author: Alex A. Mihaylov <minimumlaw@rambler.ru> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/regmap.h> | 12 | #include <linux/regmap.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include "../../w1/w1.h" | 14 | #include <linux/w1.h> |
15 | 15 | ||
16 | #include "internal.h" | 16 | #include "internal.h" |
17 | 17 | ||
diff --git a/drivers/dax/device-dax.h b/drivers/dax/device-dax.h index fdcd9769ffde..688b051750bd 100644 --- a/drivers/dax/device-dax.h +++ b/drivers/dax/device-dax.h | |||
@@ -21,5 +21,5 @@ 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 dev_dax *devm_create_dev_dax(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 | int id, struct resource *res, int count); |
25 | #endif /* __DEVICE_DAX_H__ */ | 25 | #endif /* __DEVICE_DAX_H__ */ |
diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 12943d19bfc4..e9f3b3e4bbf4 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c | |||
@@ -529,7 +529,8 @@ static void dev_dax_release(struct device *dev) | |||
529 | struct dax_region *dax_region = dev_dax->region; | 529 | struct dax_region *dax_region = dev_dax->region; |
530 | struct dax_device *dax_dev = dev_dax->dax_dev; | 530 | struct dax_device *dax_dev = dev_dax->dax_dev; |
531 | 531 | ||
532 | ida_simple_remove(&dax_region->ida, dev_dax->id); | 532 | if (dev_dax->id >= 0) |
533 | ida_simple_remove(&dax_region->ida, dev_dax->id); | ||
533 | dax_region_put(dax_region); | 534 | dax_region_put(dax_region); |
534 | put_dax(dax_dev); | 535 | put_dax(dax_dev); |
535 | kfree(dev_dax); | 536 | kfree(dev_dax); |
@@ -559,7 +560,7 @@ static void unregister_dev_dax(void *dev) | |||
559 | } | 560 | } |
560 | 561 | ||
561 | struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | 562 | struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, |
562 | struct resource *res, int count) | 563 | int id, struct resource *res, int count) |
563 | { | 564 | { |
564 | struct device *parent = dax_region->dev; | 565 | struct device *parent = dax_region->dev; |
565 | struct dax_device *dax_dev; | 566 | struct dax_device *dax_dev; |
@@ -567,7 +568,10 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
567 | struct inode *inode; | 568 | struct inode *inode; |
568 | struct device *dev; | 569 | struct device *dev; |
569 | struct cdev *cdev; | 570 | struct cdev *cdev; |
570 | int rc = 0, i; | 571 | int rc, i; |
572 | |||
573 | if (!count) | ||
574 | return ERR_PTR(-EINVAL); | ||
571 | 575 | ||
572 | dev_dax = kzalloc(sizeof(*dev_dax) + sizeof(*res) * count, GFP_KERNEL); | 576 | dev_dax = kzalloc(sizeof(*dev_dax) + sizeof(*res) * count, GFP_KERNEL); |
573 | if (!dev_dax) | 577 | if (!dev_dax) |
@@ -587,10 +591,16 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
587 | if (i < count) | 591 | if (i < count) |
588 | goto err_id; | 592 | goto err_id; |
589 | 593 | ||
590 | dev_dax->id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL); | 594 | if (id < 0) { |
591 | if (dev_dax->id < 0) { | 595 | id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL); |
592 | rc = dev_dax->id; | 596 | dev_dax->id = id; |
593 | goto err_id; | 597 | if (id < 0) { |
598 | rc = id; | ||
599 | goto err_id; | ||
600 | } | ||
601 | } else { | ||
602 | /* region provider owns @id lifetime */ | ||
603 | dev_dax->id = -1; | ||
594 | } | 604 | } |
595 | 605 | ||
596 | /* | 606 | /* |
@@ -598,8 +608,10 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
598 | * device outside of mmap of the resulting character device. | 608 | * device outside of mmap of the resulting character device. |
599 | */ | 609 | */ |
600 | dax_dev = alloc_dax(dev_dax, NULL, NULL); | 610 | dax_dev = alloc_dax(dev_dax, NULL, NULL); |
601 | if (!dax_dev) | 611 | if (!dax_dev) { |
612 | rc = -ENOMEM; | ||
602 | goto err_dax; | 613 | goto err_dax; |
614 | } | ||
603 | 615 | ||
604 | /* from here on we're committed to teardown via dax_dev_release() */ | 616 | /* from here on we're committed to teardown via dax_dev_release() */ |
605 | dev = &dev_dax->dev; | 617 | dev = &dev_dax->dev; |
@@ -620,7 +632,7 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
620 | dev->parent = parent; | 632 | dev->parent = parent; |
621 | dev->groups = dax_attribute_groups; | 633 | dev->groups = dax_attribute_groups; |
622 | dev->release = dev_dax_release; | 634 | dev->release = dev_dax_release; |
623 | dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id); | 635 | dev_set_name(dev, "dax%d.%d", dax_region->id, id); |
624 | 636 | ||
625 | rc = cdev_device_add(cdev, dev); | 637 | rc = cdev_device_add(cdev, dev); |
626 | if (rc) { | 638 | if (rc) { |
@@ -636,7 +648,8 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
636 | return dev_dax; | 648 | return dev_dax; |
637 | 649 | ||
638 | err_dax: | 650 | err_dax: |
639 | ida_simple_remove(&dax_region->ida, dev_dax->id); | 651 | if (dev_dax->id >= 0) |
652 | ida_simple_remove(&dax_region->ida, dev_dax->id); | ||
640 | err_id: | 653 | err_id: |
641 | kfree(dev_dax); | 654 | kfree(dev_dax); |
642 | 655 | ||
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c index 9f2a0b4fd801..8d8c852ba8f2 100644 --- a/drivers/dax/pmem.c +++ b/drivers/dax/pmem.c | |||
@@ -58,13 +58,12 @@ static void dax_pmem_percpu_kill(void *data) | |||
58 | 58 | ||
59 | static int dax_pmem_probe(struct device *dev) | 59 | static int dax_pmem_probe(struct device *dev) |
60 | { | 60 | { |
61 | int rc; | ||
62 | void *addr; | 61 | void *addr; |
63 | struct resource res; | 62 | struct resource res; |
63 | int rc, id, region_id; | ||
64 | struct nd_pfn_sb *pfn_sb; | 64 | struct nd_pfn_sb *pfn_sb; |
65 | struct dev_dax *dev_dax; | 65 | struct dev_dax *dev_dax; |
66 | struct dax_pmem *dax_pmem; | 66 | struct dax_pmem *dax_pmem; |
67 | struct nd_region *nd_region; | ||
68 | struct nd_namespace_io *nsio; | 67 | struct nd_namespace_io *nsio; |
69 | struct dax_region *dax_region; | 68 | struct dax_region *dax_region; |
70 | struct nd_namespace_common *ndns; | 69 | struct nd_namespace_common *ndns; |
@@ -123,14 +122,17 @@ static int dax_pmem_probe(struct device *dev) | |||
123 | /* adjust the dax_region resource to the start of data */ | 122 | /* adjust the dax_region resource to the start of data */ |
124 | res.start += le64_to_cpu(pfn_sb->dataoff); | 123 | res.start += le64_to_cpu(pfn_sb->dataoff); |
125 | 124 | ||
126 | nd_region = to_nd_region(dev->parent); | 125 | rc = sscanf(dev_name(&ndns->dev), "namespace%d.%d", ®ion_id, &id); |
127 | dax_region = alloc_dax_region(dev, nd_region->id, &res, | 126 | if (rc != 2) |
127 | return -EINVAL; | ||
128 | |||
129 | dax_region = alloc_dax_region(dev, region_id, &res, | ||
128 | le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP); | 130 | le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP); |
129 | if (!dax_region) | 131 | if (!dax_region) |
130 | return -ENOMEM; | 132 | return -ENOMEM; |
131 | 133 | ||
132 | /* TODO: support for subdividing a dax region... */ | 134 | /* TODO: support for subdividing a dax region... */ |
133 | dev_dax = devm_create_dev_dax(dax_region, &res, 1); | 135 | dev_dax = devm_create_dev_dax(dax_region, id, &res, 1); |
134 | 136 | ||
135 | /* child dev_dax instances now own the lifetime of the dax_region */ | 137 | /* child dev_dax instances now own the lifetime of the dax_region */ |
136 | dax_region_put(dax_region); | 138 | dax_region_put(dax_region); |
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 41b39464ded8..501e16a9227d 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c | |||
@@ -2732,6 +2732,9 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) | |||
2732 | hidpp_battery_props, | 2732 | hidpp_battery_props, |
2733 | sizeof(hidpp_battery_props), | 2733 | sizeof(hidpp_battery_props), |
2734 | GFP_KERNEL); | 2734 | GFP_KERNEL); |
2735 | if (!battery_props) | ||
2736 | return -ENOMEM; | ||
2737 | |||
2735 | num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2; | 2738 | num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2; |
2736 | 2739 | ||
2737 | if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) | 2740 | if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) |
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index f3e35e7a189d..aff20f4b6d97 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
@@ -620,16 +620,6 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
620 | return 0; | 620 | return 0; |
621 | } | 621 | } |
622 | 622 | ||
623 | static int mt_touch_input_mapped(struct hid_device *hdev, struct hid_input *hi, | ||
624 | struct hid_field *field, struct hid_usage *usage, | ||
625 | unsigned long **bit, int *max) | ||
626 | { | ||
627 | if (usage->type == EV_KEY || usage->type == EV_ABS) | ||
628 | set_bit(usage->type, hi->input->evbit); | ||
629 | |||
630 | return -1; | ||
631 | } | ||
632 | |||
633 | static int mt_compute_slot(struct mt_device *td, struct input_dev *input) | 623 | static int mt_compute_slot(struct mt_device *td, struct input_dev *input) |
634 | { | 624 | { |
635 | __s32 quirks = td->mtclass.quirks; | 625 | __s32 quirks = td->mtclass.quirks; |
@@ -969,8 +959,10 @@ static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |||
969 | return 0; | 959 | return 0; |
970 | 960 | ||
971 | if (field->application == HID_DG_TOUCHSCREEN || | 961 | if (field->application == HID_DG_TOUCHSCREEN || |
972 | field->application == HID_DG_TOUCHPAD) | 962 | field->application == HID_DG_TOUCHPAD) { |
973 | return mt_touch_input_mapped(hdev, hi, field, usage, bit, max); | 963 | /* We own these mappings, tell hid-input to ignore them */ |
964 | return -1; | ||
965 | } | ||
974 | 966 | ||
975 | /* let hid-core decide for the others */ | 967 | /* let hid-core decide for the others */ |
976 | return 0; | 968 | return 0; |
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index a6cb379a4ebc..01236cef7bfb 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c | |||
@@ -268,6 +268,7 @@ int rdma_translate_ip(const struct sockaddr *addr, | |||
268 | return ret; | 268 | return ret; |
269 | 269 | ||
270 | ret = rdma_copy_addr(dev_addr, dev, NULL); | 270 | ret = rdma_copy_addr(dev_addr, dev, NULL); |
271 | dev_addr->bound_dev_if = dev->ifindex; | ||
271 | if (vlan_id) | 272 | if (vlan_id) |
272 | *vlan_id = rdma_vlan_dev_vlan_id(dev); | 273 | *vlan_id = rdma_vlan_dev_vlan_id(dev); |
273 | dev_put(dev); | 274 | dev_put(dev); |
@@ -280,6 +281,7 @@ int rdma_translate_ip(const struct sockaddr *addr, | |||
280 | &((const struct sockaddr_in6 *)addr)->sin6_addr, | 281 | &((const struct sockaddr_in6 *)addr)->sin6_addr, |
281 | dev, 1)) { | 282 | dev, 1)) { |
282 | ret = rdma_copy_addr(dev_addr, dev, NULL); | 283 | ret = rdma_copy_addr(dev_addr, dev, NULL); |
284 | dev_addr->bound_dev_if = dev->ifindex; | ||
283 | if (vlan_id) | 285 | if (vlan_id) |
284 | *vlan_id = rdma_vlan_dev_vlan_id(dev); | 286 | *vlan_id = rdma_vlan_dev_vlan_id(dev); |
285 | break; | 287 | break; |
@@ -405,10 +407,10 @@ static int addr4_resolve(struct sockaddr_in *src_in, | |||
405 | fl4.saddr = src_ip; | 407 | fl4.saddr = src_ip; |
406 | fl4.flowi4_oif = addr->bound_dev_if; | 408 | fl4.flowi4_oif = addr->bound_dev_if; |
407 | rt = ip_route_output_key(addr->net, &fl4); | 409 | rt = ip_route_output_key(addr->net, &fl4); |
408 | if (IS_ERR(rt)) { | 410 | ret = PTR_ERR_OR_ZERO(rt); |
409 | ret = PTR_ERR(rt); | 411 | if (ret) |
410 | goto out; | 412 | return ret; |
411 | } | 413 | |
412 | src_in->sin_family = AF_INET; | 414 | src_in->sin_family = AF_INET; |
413 | src_in->sin_addr.s_addr = fl4.saddr; | 415 | src_in->sin_addr.s_addr = fl4.saddr; |
414 | 416 | ||
@@ -423,8 +425,6 @@ static int addr4_resolve(struct sockaddr_in *src_in, | |||
423 | 425 | ||
424 | *prt = rt; | 426 | *prt = rt; |
425 | return 0; | 427 | return 0; |
426 | out: | ||
427 | return ret; | ||
428 | } | 428 | } |
429 | 429 | ||
430 | #if IS_ENABLED(CONFIG_IPV6) | 430 | #if IS_ENABLED(CONFIG_IPV6) |
@@ -509,6 +509,11 @@ static int addr_resolve(struct sockaddr *src_in, | |||
509 | struct dst_entry *dst; | 509 | struct dst_entry *dst; |
510 | int ret; | 510 | int ret; |
511 | 511 | ||
512 | if (!addr->net) { | ||
513 | pr_warn_ratelimited("%s: missing namespace\n", __func__); | ||
514 | return -EINVAL; | ||
515 | } | ||
516 | |||
512 | if (src_in->sa_family == AF_INET) { | 517 | if (src_in->sa_family == AF_INET) { |
513 | struct rtable *rt = NULL; | 518 | struct rtable *rt = NULL; |
514 | const struct sockaddr_in *dst_in4 = | 519 | const struct sockaddr_in *dst_in4 = |
@@ -522,8 +527,12 @@ static int addr_resolve(struct sockaddr *src_in, | |||
522 | if (resolve_neigh) | 527 | if (resolve_neigh) |
523 | ret = addr_resolve_neigh(&rt->dst, dst_in, addr, seq); | 528 | ret = addr_resolve_neigh(&rt->dst, dst_in, addr, seq); |
524 | 529 | ||
525 | ndev = rt->dst.dev; | 530 | if (addr->bound_dev_if) { |
526 | dev_hold(ndev); | 531 | ndev = dev_get_by_index(addr->net, addr->bound_dev_if); |
532 | } else { | ||
533 | ndev = rt->dst.dev; | ||
534 | dev_hold(ndev); | ||
535 | } | ||
527 | 536 | ||
528 | ip_rt_put(rt); | 537 | ip_rt_put(rt); |
529 | } else { | 538 | } else { |
@@ -539,14 +548,27 @@ static int addr_resolve(struct sockaddr *src_in, | |||
539 | if (resolve_neigh) | 548 | if (resolve_neigh) |
540 | ret = addr_resolve_neigh(dst, dst_in, addr, seq); | 549 | ret = addr_resolve_neigh(dst, dst_in, addr, seq); |
541 | 550 | ||
542 | ndev = dst->dev; | 551 | if (addr->bound_dev_if) { |
543 | dev_hold(ndev); | 552 | ndev = dev_get_by_index(addr->net, addr->bound_dev_if); |
553 | } else { | ||
554 | ndev = dst->dev; | ||
555 | dev_hold(ndev); | ||
556 | } | ||
544 | 557 | ||
545 | dst_release(dst); | 558 | dst_release(dst); |
546 | } | 559 | } |
547 | 560 | ||
548 | addr->bound_dev_if = ndev->ifindex; | 561 | if (ndev->flags & IFF_LOOPBACK) { |
549 | addr->net = dev_net(ndev); | 562 | ret = rdma_translate_ip(dst_in, addr, NULL); |
563 | /* | ||
564 | * Put the loopback device and get the translated | ||
565 | * device instead. | ||
566 | */ | ||
567 | dev_put(ndev); | ||
568 | ndev = dev_get_by_index(addr->net, addr->bound_dev_if); | ||
569 | } else { | ||
570 | addr->bound_dev_if = ndev->ifindex; | ||
571 | } | ||
550 | dev_put(ndev); | 572 | dev_put(ndev); |
551 | 573 | ||
552 | return ret; | 574 | return ret; |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 31bb82d8ecd7..11aff923b633 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -623,22 +623,11 @@ static inline int cma_validate_port(struct ib_device *device, u8 port, | |||
623 | if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) | 623 | if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) |
624 | return ret; | 624 | return ret; |
625 | 625 | ||
626 | if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) { | 626 | if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) |
627 | ndev = dev_get_by_index(&init_net, bound_if_index); | 627 | ndev = dev_get_by_index(&init_net, bound_if_index); |
628 | if (ndev && ndev->flags & IFF_LOOPBACK) { | 628 | else |
629 | pr_info("detected loopback device\n"); | ||
630 | dev_put(ndev); | ||
631 | |||
632 | if (!device->get_netdev) | ||
633 | return -EOPNOTSUPP; | ||
634 | |||
635 | ndev = device->get_netdev(device, port); | ||
636 | if (!ndev) | ||
637 | return -ENODEV; | ||
638 | } | ||
639 | } else { | ||
640 | gid_type = IB_GID_TYPE_IB; | 629 | gid_type = IB_GID_TYPE_IB; |
641 | } | 630 | |
642 | 631 | ||
643 | ret = ib_find_cached_gid_by_port(device, gid, gid_type, port, | 632 | ret = ib_find_cached_gid_by_port(device, gid, gid_type, port, |
644 | ndev, NULL); | 633 | ndev, NULL); |
@@ -2569,21 +2558,6 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv) | |||
2569 | goto err2; | 2558 | goto err2; |
2570 | } | 2559 | } |
2571 | 2560 | ||
2572 | if (ndev->flags & IFF_LOOPBACK) { | ||
2573 | dev_put(ndev); | ||
2574 | if (!id_priv->id.device->get_netdev) { | ||
2575 | ret = -EOPNOTSUPP; | ||
2576 | goto err2; | ||
2577 | } | ||
2578 | |||
2579 | ndev = id_priv->id.device->get_netdev(id_priv->id.device, | ||
2580 | id_priv->id.port_num); | ||
2581 | if (!ndev) { | ||
2582 | ret = -ENODEV; | ||
2583 | goto err2; | ||
2584 | } | ||
2585 | } | ||
2586 | |||
2587 | supported_gids = roce_gid_type_mask_support(id_priv->id.device, | 2561 | supported_gids = roce_gid_type_mask_support(id_priv->id.device, |
2588 | id_priv->id.port_num); | 2562 | id_priv->id.port_num); |
2589 | gid_type = cma_route_gid_type(addr->dev_addr.network, | 2563 | gid_type = cma_route_gid_type(addr->dev_addr.network, |
diff --git a/drivers/infiniband/core/roce_gid_mgmt.c b/drivers/infiniband/core/roce_gid_mgmt.c index db958d3207ef..94a9eefb3cfc 100644 --- a/drivers/infiniband/core/roce_gid_mgmt.c +++ b/drivers/infiniband/core/roce_gid_mgmt.c | |||
@@ -42,6 +42,8 @@ | |||
42 | #include <rdma/ib_cache.h> | 42 | #include <rdma/ib_cache.h> |
43 | #include <rdma/ib_addr.h> | 43 | #include <rdma/ib_addr.h> |
44 | 44 | ||
45 | static struct workqueue_struct *gid_cache_wq; | ||
46 | |||
45 | enum gid_op_type { | 47 | enum gid_op_type { |
46 | GID_DEL = 0, | 48 | GID_DEL = 0, |
47 | GID_ADD | 49 | GID_ADD |
@@ -560,7 +562,7 @@ static int netdevice_queue_work(struct netdev_event_work_cmd *cmds, | |||
560 | } | 562 | } |
561 | INIT_WORK(&ndev_work->work, netdevice_event_work_handler); | 563 | INIT_WORK(&ndev_work->work, netdevice_event_work_handler); |
562 | 564 | ||
563 | queue_work(ib_wq, &ndev_work->work); | 565 | queue_work(gid_cache_wq, &ndev_work->work); |
564 | 566 | ||
565 | return NOTIFY_DONE; | 567 | return NOTIFY_DONE; |
566 | } | 568 | } |
@@ -693,7 +695,7 @@ static int addr_event(struct notifier_block *this, unsigned long event, | |||
693 | dev_hold(ndev); | 695 | dev_hold(ndev); |
694 | work->gid_attr.ndev = ndev; | 696 | work->gid_attr.ndev = ndev; |
695 | 697 | ||
696 | queue_work(ib_wq, &work->work); | 698 | queue_work(gid_cache_wq, &work->work); |
697 | 699 | ||
698 | return NOTIFY_DONE; | 700 | return NOTIFY_DONE; |
699 | } | 701 | } |
@@ -740,6 +742,10 @@ static struct notifier_block nb_inet6addr = { | |||
740 | 742 | ||
741 | int __init roce_gid_mgmt_init(void) | 743 | int __init roce_gid_mgmt_init(void) |
742 | { | 744 | { |
745 | gid_cache_wq = alloc_ordered_workqueue("gid-cache-wq", 0); | ||
746 | if (!gid_cache_wq) | ||
747 | return -ENOMEM; | ||
748 | |||
743 | register_inetaddr_notifier(&nb_inetaddr); | 749 | register_inetaddr_notifier(&nb_inetaddr); |
744 | if (IS_ENABLED(CONFIG_IPV6)) | 750 | if (IS_ENABLED(CONFIG_IPV6)) |
745 | register_inet6addr_notifier(&nb_inet6addr); | 751 | register_inet6addr_notifier(&nb_inet6addr); |
@@ -764,4 +770,5 @@ void __exit roce_gid_mgmt_cleanup(void) | |||
764 | * ib-core is removed, all physical devices have been removed, | 770 | * ib-core is removed, all physical devices have been removed, |
765 | * so no issue with remaining hardware contexts. | 771 | * so no issue with remaining hardware contexts. |
766 | */ | 772 | */ |
773 | destroy_workqueue(gid_cache_wq); | ||
767 | } | 774 | } |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 8ba9bfb073d1..3f55d18a3791 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -2005,28 +2005,13 @@ static int modify_qp(struct ib_uverbs_file *file, | |||
2005 | rdma_ah_set_port_num(&attr->alt_ah_attr, | 2005 | rdma_ah_set_port_num(&attr->alt_ah_attr, |
2006 | cmd->base.alt_dest.port_num); | 2006 | cmd->base.alt_dest.port_num); |
2007 | 2007 | ||
2008 | if (qp->real_qp == qp) { | 2008 | ret = ib_modify_qp_with_udata(qp, attr, |
2009 | if (cmd->base.attr_mask & IB_QP_AV) { | 2009 | modify_qp_mask(qp->qp_type, |
2010 | ret = ib_resolve_eth_dmac(qp->device, &attr->ah_attr); | 2010 | cmd->base.attr_mask), |
2011 | if (ret) | 2011 | udata); |
2012 | goto release_qp; | ||
2013 | } | ||
2014 | ret = ib_security_modify_qp(qp, | ||
2015 | attr, | ||
2016 | modify_qp_mask(qp->qp_type, | ||
2017 | cmd->base.attr_mask), | ||
2018 | udata); | ||
2019 | } else { | ||
2020 | ret = ib_security_modify_qp(qp, | ||
2021 | attr, | ||
2022 | modify_qp_mask(qp->qp_type, | ||
2023 | cmd->base.attr_mask), | ||
2024 | NULL); | ||
2025 | } | ||
2026 | 2012 | ||
2027 | release_qp: | 2013 | release_qp: |
2028 | uobj_put_obj_read(qp); | 2014 | uobj_put_obj_read(qp); |
2029 | |||
2030 | out: | 2015 | out: |
2031 | kfree(attr); | 2016 | kfree(attr); |
2032 | 2017 | ||
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index c973a83c898b..fb98ed67d5bc 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c | |||
@@ -452,6 +452,19 @@ int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr, | |||
452 | } | 452 | } |
453 | EXPORT_SYMBOL(ib_get_gids_from_rdma_hdr); | 453 | EXPORT_SYMBOL(ib_get_gids_from_rdma_hdr); |
454 | 454 | ||
455 | /* | ||
456 | * This function creates ah from the incoming packet. | ||
457 | * Incoming packet has dgid of the receiver node on which this code is | ||
458 | * getting executed and, sgid contains the GID of the sender. | ||
459 | * | ||
460 | * When resolving mac address of destination, the arrived dgid is used | ||
461 | * as sgid and, sgid is used as dgid because sgid contains destinations | ||
462 | * GID whom to respond to. | ||
463 | * | ||
464 | * This is why when calling rdma_addr_find_l2_eth_by_grh() function, the | ||
465 | * position of arguments dgid and sgid do not match the order of the | ||
466 | * parameters. | ||
467 | */ | ||
455 | int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, | 468 | int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, |
456 | const struct ib_wc *wc, const struct ib_grh *grh, | 469 | const struct ib_wc *wc, const struct ib_grh *grh, |
457 | struct rdma_ah_attr *ah_attr) | 470 | struct rdma_ah_attr *ah_attr) |
@@ -507,11 +520,6 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, | |||
507 | } | 520 | } |
508 | 521 | ||
509 | resolved_dev = dev_get_by_index(&init_net, if_index); | 522 | resolved_dev = dev_get_by_index(&init_net, if_index); |
510 | if (resolved_dev->flags & IFF_LOOPBACK) { | ||
511 | dev_put(resolved_dev); | ||
512 | resolved_dev = idev; | ||
513 | dev_hold(resolved_dev); | ||
514 | } | ||
515 | rcu_read_lock(); | 523 | rcu_read_lock(); |
516 | if (resolved_dev != idev && !rdma_is_upper_dev_rcu(idev, | 524 | if (resolved_dev != idev && !rdma_is_upper_dev_rcu(idev, |
517 | resolved_dev)) | 525 | resolved_dev)) |
@@ -887,6 +895,7 @@ static const struct { | |||
887 | } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = { | 895 | } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = { |
888 | [IB_QPS_RESET] = { | 896 | [IB_QPS_RESET] = { |
889 | [IB_QPS_RESET] = { .valid = 1 }, | 897 | [IB_QPS_RESET] = { .valid = 1 }, |
898 | [IB_QPS_ERR] = { .valid = 1 }, | ||
890 | [IB_QPS_INIT] = { | 899 | [IB_QPS_INIT] = { |
891 | .valid = 1, | 900 | .valid = 1, |
892 | .req_param = { | 901 | .req_param = { |
@@ -1268,20 +1277,36 @@ out: | |||
1268 | } | 1277 | } |
1269 | EXPORT_SYMBOL(ib_resolve_eth_dmac); | 1278 | EXPORT_SYMBOL(ib_resolve_eth_dmac); |
1270 | 1279 | ||
1271 | int ib_modify_qp(struct ib_qp *qp, | 1280 | /** |
1272 | struct ib_qp_attr *qp_attr, | 1281 | * ib_modify_qp_with_udata - Modifies the attributes for the specified QP. |
1273 | int qp_attr_mask) | 1282 | * @qp: The QP to modify. |
1283 | * @attr: On input, specifies the QP attributes to modify. On output, | ||
1284 | * the current values of selected QP attributes are returned. | ||
1285 | * @attr_mask: A bit-mask used to specify which attributes of the QP | ||
1286 | * are being modified. | ||
1287 | * @udata: pointer to user's input output buffer information | ||
1288 | * are being modified. | ||
1289 | * It returns 0 on success and returns appropriate error code on error. | ||
1290 | */ | ||
1291 | int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr, | ||
1292 | int attr_mask, struct ib_udata *udata) | ||
1274 | { | 1293 | { |
1294 | int ret; | ||
1275 | 1295 | ||
1276 | if (qp_attr_mask & IB_QP_AV) { | 1296 | if (attr_mask & IB_QP_AV) { |
1277 | int ret; | 1297 | ret = ib_resolve_eth_dmac(qp->device, &attr->ah_attr); |
1278 | |||
1279 | ret = ib_resolve_eth_dmac(qp->device, &qp_attr->ah_attr); | ||
1280 | if (ret) | 1298 | if (ret) |
1281 | return ret; | 1299 | return ret; |
1282 | } | 1300 | } |
1301 | return ib_security_modify_qp(qp, attr, attr_mask, udata); | ||
1302 | } | ||
1303 | EXPORT_SYMBOL(ib_modify_qp_with_udata); | ||
1283 | 1304 | ||
1284 | return ib_security_modify_qp(qp->real_qp, qp_attr, qp_attr_mask, NULL); | 1305 | int ib_modify_qp(struct ib_qp *qp, |
1306 | struct ib_qp_attr *qp_attr, | ||
1307 | int qp_attr_mask) | ||
1308 | { | ||
1309 | return ib_modify_qp_with_udata(qp, qp_attr, qp_attr_mask, NULL); | ||
1285 | } | 1310 | } |
1286 | EXPORT_SYMBOL(ib_modify_qp); | 1311 | EXPORT_SYMBOL(ib_modify_qp); |
1287 | 1312 | ||
diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c index 2ba00b89df6a..94b54850ec75 100644 --- a/drivers/infiniband/hw/hfi1/chip.c +++ b/drivers/infiniband/hw/hfi1/chip.c | |||
@@ -12847,7 +12847,12 @@ static void remap_intr(struct hfi1_devdata *dd, int isrc, int msix_intr) | |||
12847 | /* clear from the handled mask of the general interrupt */ | 12847 | /* clear from the handled mask of the general interrupt */ |
12848 | m = isrc / 64; | 12848 | m = isrc / 64; |
12849 | n = isrc % 64; | 12849 | n = isrc % 64; |
12850 | dd->gi_mask[m] &= ~((u64)1 << n); | 12850 | if (likely(m < CCE_NUM_INT_CSRS)) { |
12851 | dd->gi_mask[m] &= ~((u64)1 << n); | ||
12852 | } else { | ||
12853 | dd_dev_err(dd, "remap interrupt err\n"); | ||
12854 | return; | ||
12855 | } | ||
12851 | 12856 | ||
12852 | /* direct the chip source to the given MSI-X interrupt */ | 12857 | /* direct the chip source to the given MSI-X interrupt */ |
12853 | m = isrc / 8; | 12858 | m = isrc / 8; |
diff --git a/drivers/infiniband/hw/hfi1/qp.c b/drivers/infiniband/hw/hfi1/qp.c index 650305cc0373..1a7af9f60c13 100644 --- a/drivers/infiniband/hw/hfi1/qp.c +++ b/drivers/infiniband/hw/hfi1/qp.c | |||
@@ -647,18 +647,17 @@ void qp_iter_print(struct seq_file *s, struct qp_iter *iter) | |||
647 | qp->pid); | 647 | qp->pid); |
648 | } | 648 | } |
649 | 649 | ||
650 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, | 650 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp) |
651 | gfp_t gfp) | ||
652 | { | 651 | { |
653 | struct hfi1_qp_priv *priv; | 652 | struct hfi1_qp_priv *priv; |
654 | 653 | ||
655 | priv = kzalloc_node(sizeof(*priv), gfp, rdi->dparms.node); | 654 | priv = kzalloc_node(sizeof(*priv), GFP_KERNEL, rdi->dparms.node); |
656 | if (!priv) | 655 | if (!priv) |
657 | return ERR_PTR(-ENOMEM); | 656 | return ERR_PTR(-ENOMEM); |
658 | 657 | ||
659 | priv->owner = qp; | 658 | priv->owner = qp; |
660 | 659 | ||
661 | priv->s_ahg = kzalloc_node(sizeof(*priv->s_ahg), gfp, | 660 | priv->s_ahg = kzalloc_node(sizeof(*priv->s_ahg), GFP_KERNEL, |
662 | rdi->dparms.node); | 661 | rdi->dparms.node); |
663 | if (!priv->s_ahg) { | 662 | if (!priv->s_ahg) { |
664 | kfree(priv); | 663 | kfree(priv); |
diff --git a/drivers/infiniband/hw/hfi1/qp.h b/drivers/infiniband/hw/hfi1/qp.h index 1eb9cd7b8c19..6fe542b6a927 100644 --- a/drivers/infiniband/hw/hfi1/qp.h +++ b/drivers/infiniband/hw/hfi1/qp.h | |||
@@ -123,8 +123,7 @@ void hfi1_migrate_qp(struct rvt_qp *qp); | |||
123 | /* | 123 | /* |
124 | * Functions provided by hfi1 driver for rdmavt to use | 124 | * Functions provided by hfi1 driver for rdmavt to use |
125 | */ | 125 | */ |
126 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, | 126 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
127 | gfp_t gfp); | ||
128 | void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); | 127 | void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
129 | unsigned free_all_qps(struct rvt_dev_info *rdi); | 128 | unsigned free_all_qps(struct rvt_dev_info *rdi); |
130 | void notify_qp_reset(struct rvt_qp *qp); | 129 | void notify_qp_reset(struct rvt_qp *qp); |
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c index 37d5d29597a4..23fad6d96944 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c | |||
@@ -228,14 +228,14 @@ int hns_roce_v1_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
228 | switch (wr->opcode) { | 228 | switch (wr->opcode) { |
229 | case IB_WR_RDMA_READ: | 229 | case IB_WR_RDMA_READ: |
230 | ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_READ; | 230 | ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_READ; |
231 | set_raddr_seg(wqe, atomic_wr(wr)->remote_addr, | 231 | set_raddr_seg(wqe, rdma_wr(wr)->remote_addr, |
232 | atomic_wr(wr)->rkey); | 232 | rdma_wr(wr)->rkey); |
233 | break; | 233 | break; |
234 | case IB_WR_RDMA_WRITE: | 234 | case IB_WR_RDMA_WRITE: |
235 | case IB_WR_RDMA_WRITE_WITH_IMM: | 235 | case IB_WR_RDMA_WRITE_WITH_IMM: |
236 | ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_WRITE; | 236 | ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_WRITE; |
237 | set_raddr_seg(wqe, atomic_wr(wr)->remote_addr, | 237 | set_raddr_seg(wqe, rdma_wr(wr)->remote_addr, |
238 | atomic_wr(wr)->rkey); | 238 | rdma_wr(wr)->rkey); |
239 | break; | 239 | break; |
240 | case IB_WR_SEND: | 240 | case IB_WR_SEND: |
241 | case IB_WR_SEND_WITH_INV: | 241 | case IB_WR_SEND_WITH_INV: |
@@ -661,9 +661,11 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) | |||
661 | union ib_gid dgid; | 661 | union ib_gid dgid; |
662 | u64 subnet_prefix; | 662 | u64 subnet_prefix; |
663 | int attr_mask = 0; | 663 | int attr_mask = 0; |
664 | int i; | 664 | int i, j; |
665 | int ret; | 665 | int ret; |
666 | u8 queue_en[HNS_ROCE_V1_RESV_QP] = { 0 }; | ||
666 | u8 phy_port; | 667 | u8 phy_port; |
668 | u8 port = 0; | ||
667 | u8 sl; | 669 | u8 sl; |
668 | 670 | ||
669 | priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv; | 671 | priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv; |
@@ -709,11 +711,27 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) | |||
709 | attr.rnr_retry = 7; | 711 | attr.rnr_retry = 7; |
710 | attr.timeout = 0x12; | 712 | attr.timeout = 0x12; |
711 | attr.path_mtu = IB_MTU_256; | 713 | attr.path_mtu = IB_MTU_256; |
714 | attr.ah_attr.type = RDMA_AH_ATTR_TYPE_ROCE; | ||
712 | rdma_ah_set_grh(&attr.ah_attr, NULL, 0, 0, 1, 0); | 715 | rdma_ah_set_grh(&attr.ah_attr, NULL, 0, 0, 1, 0); |
713 | rdma_ah_set_static_rate(&attr.ah_attr, 3); | 716 | rdma_ah_set_static_rate(&attr.ah_attr, 3); |
714 | 717 | ||
715 | subnet_prefix = cpu_to_be64(0xfe80000000000000LL); | 718 | subnet_prefix = cpu_to_be64(0xfe80000000000000LL); |
716 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { | 719 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { |
720 | phy_port = (i >= HNS_ROCE_MAX_PORTS) ? (i - 2) : | ||
721 | (i % HNS_ROCE_MAX_PORTS); | ||
722 | sl = i / HNS_ROCE_MAX_PORTS; | ||
723 | |||
724 | for (j = 0; j < caps->num_ports; j++) { | ||
725 | if (hr_dev->iboe.phy_port[j] == phy_port) { | ||
726 | queue_en[i] = 1; | ||
727 | port = j; | ||
728 | break; | ||
729 | } | ||
730 | } | ||
731 | |||
732 | if (!queue_en[i]) | ||
733 | continue; | ||
734 | |||
717 | free_mr->mr_free_qp[i] = hns_roce_v1_create_lp_qp(hr_dev, pd); | 735 | free_mr->mr_free_qp[i] = hns_roce_v1_create_lp_qp(hr_dev, pd); |
718 | if (IS_ERR(free_mr->mr_free_qp[i])) { | 736 | if (IS_ERR(free_mr->mr_free_qp[i])) { |
719 | dev_err(dev, "Create loop qp failed!\n"); | 737 | dev_err(dev, "Create loop qp failed!\n"); |
@@ -721,15 +739,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) | |||
721 | } | 739 | } |
722 | hr_qp = free_mr->mr_free_qp[i]; | 740 | hr_qp = free_mr->mr_free_qp[i]; |
723 | 741 | ||
724 | sl = i / caps->num_ports; | 742 | hr_qp->port = port; |
725 | |||
726 | if (caps->num_ports == HNS_ROCE_MAX_PORTS) | ||
727 | phy_port = (i >= HNS_ROCE_MAX_PORTS) ? (i - 2) : | ||
728 | (i % caps->num_ports); | ||
729 | else | ||
730 | phy_port = i % caps->num_ports; | ||
731 | |||
732 | hr_qp->port = phy_port + 1; | ||
733 | hr_qp->phy_port = phy_port; | 743 | hr_qp->phy_port = phy_port; |
734 | hr_qp->ibqp.qp_type = IB_QPT_RC; | 744 | hr_qp->ibqp.qp_type = IB_QPT_RC; |
735 | hr_qp->ibqp.device = &hr_dev->ib_dev; | 745 | hr_qp->ibqp.device = &hr_dev->ib_dev; |
@@ -739,23 +749,22 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) | |||
739 | hr_qp->ibqp.recv_cq = cq; | 749 | hr_qp->ibqp.recv_cq = cq; |
740 | hr_qp->ibqp.send_cq = cq; | 750 | hr_qp->ibqp.send_cq = cq; |
741 | 751 | ||
742 | rdma_ah_set_port_num(&attr.ah_attr, phy_port + 1); | 752 | rdma_ah_set_port_num(&attr.ah_attr, port + 1); |
743 | rdma_ah_set_sl(&attr.ah_attr, phy_port + 1); | 753 | rdma_ah_set_sl(&attr.ah_attr, sl); |
744 | attr.port_num = phy_port + 1; | 754 | attr.port_num = port + 1; |
745 | 755 | ||
746 | attr.dest_qp_num = hr_qp->qpn; | 756 | attr.dest_qp_num = hr_qp->qpn; |
747 | memcpy(rdma_ah_retrieve_dmac(&attr.ah_attr), | 757 | memcpy(rdma_ah_retrieve_dmac(&attr.ah_attr), |
748 | hr_dev->dev_addr[phy_port], | 758 | hr_dev->dev_addr[port], |
749 | MAC_ADDR_OCTET_NUM); | 759 | MAC_ADDR_OCTET_NUM); |
750 | 760 | ||
751 | memcpy(&dgid.raw, &subnet_prefix, sizeof(u64)); | 761 | memcpy(&dgid.raw, &subnet_prefix, sizeof(u64)); |
752 | memcpy(&dgid.raw[8], hr_dev->dev_addr[phy_port], 3); | 762 | memcpy(&dgid.raw[8], hr_dev->dev_addr[port], 3); |
753 | memcpy(&dgid.raw[13], hr_dev->dev_addr[phy_port] + 3, 3); | 763 | memcpy(&dgid.raw[13], hr_dev->dev_addr[port] + 3, 3); |
754 | dgid.raw[11] = 0xff; | 764 | dgid.raw[11] = 0xff; |
755 | dgid.raw[12] = 0xfe; | 765 | dgid.raw[12] = 0xfe; |
756 | dgid.raw[8] ^= 2; | 766 | dgid.raw[8] ^= 2; |
757 | rdma_ah_set_dgid_raw(&attr.ah_attr, dgid.raw); | 767 | rdma_ah_set_dgid_raw(&attr.ah_attr, dgid.raw); |
758 | attr_mask |= IB_QP_PORT; | ||
759 | 768 | ||
760 | ret = hr_dev->hw->modify_qp(&hr_qp->ibqp, &attr, attr_mask, | 769 | ret = hr_dev->hw->modify_qp(&hr_qp->ibqp, &attr, attr_mask, |
761 | IB_QPS_RESET, IB_QPS_INIT); | 770 | IB_QPS_RESET, IB_QPS_INIT); |
@@ -812,6 +821,9 @@ static void hns_roce_v1_release_lp_qp(struct hns_roce_dev *hr_dev) | |||
812 | 821 | ||
813 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { | 822 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { |
814 | hr_qp = free_mr->mr_free_qp[i]; | 823 | hr_qp = free_mr->mr_free_qp[i]; |
824 | if (!hr_qp) | ||
825 | continue; | ||
826 | |||
815 | ret = hns_roce_v1_destroy_qp(&hr_qp->ibqp); | 827 | ret = hns_roce_v1_destroy_qp(&hr_qp->ibqp); |
816 | if (ret) | 828 | if (ret) |
817 | dev_err(dev, "Destroy qp %d for mr free failed(%d)!\n", | 829 | dev_err(dev, "Destroy qp %d for mr free failed(%d)!\n", |
@@ -963,7 +975,7 @@ static void hns_roce_v1_mr_free_work_fn(struct work_struct *work) | |||
963 | msecs_to_jiffies(HNS_ROCE_V1_FREE_MR_TIMEOUT_MSECS) + jiffies; | 975 | msecs_to_jiffies(HNS_ROCE_V1_FREE_MR_TIMEOUT_MSECS) + jiffies; |
964 | int i; | 976 | int i; |
965 | int ret; | 977 | int ret; |
966 | int ne; | 978 | int ne = 0; |
967 | 979 | ||
968 | mr_work = container_of(work, struct hns_roce_mr_free_work, work); | 980 | mr_work = container_of(work, struct hns_roce_mr_free_work, work); |
969 | hr_mr = (struct hns_roce_mr *)mr_work->mr; | 981 | hr_mr = (struct hns_roce_mr *)mr_work->mr; |
@@ -976,6 +988,10 @@ static void hns_roce_v1_mr_free_work_fn(struct work_struct *work) | |||
976 | 988 | ||
977 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { | 989 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { |
978 | hr_qp = free_mr->mr_free_qp[i]; | 990 | hr_qp = free_mr->mr_free_qp[i]; |
991 | if (!hr_qp) | ||
992 | continue; | ||
993 | ne++; | ||
994 | |||
979 | ret = hns_roce_v1_send_lp_wqe(hr_qp); | 995 | ret = hns_roce_v1_send_lp_wqe(hr_qp); |
980 | if (ret) { | 996 | if (ret) { |
981 | dev_err(dev, | 997 | dev_err(dev, |
@@ -985,7 +1001,6 @@ static void hns_roce_v1_mr_free_work_fn(struct work_struct *work) | |||
985 | } | 1001 | } |
986 | } | 1002 | } |
987 | 1003 | ||
988 | ne = HNS_ROCE_V1_RESV_QP; | ||
989 | do { | 1004 | do { |
990 | ret = hns_roce_v1_poll_cq(&mr_free_cq->ib_cq, ne, wc); | 1005 | ret = hns_roce_v1_poll_cq(&mr_free_cq->ib_cq, ne, wc); |
991 | if (ret < 0) { | 1006 | if (ret < 0) { |
@@ -995,7 +1010,8 @@ static void hns_roce_v1_mr_free_work_fn(struct work_struct *work) | |||
995 | goto free_work; | 1010 | goto free_work; |
996 | } | 1011 | } |
997 | ne -= ret; | 1012 | ne -= ret; |
998 | msleep(HNS_ROCE_V1_FREE_MR_WAIT_VALUE); | 1013 | usleep_range(HNS_ROCE_V1_FREE_MR_WAIT_VALUE * 1000, |
1014 | (1 + HNS_ROCE_V1_FREE_MR_WAIT_VALUE) * 1000); | ||
999 | } while (ne && time_before_eq(jiffies, end)); | 1015 | } while (ne && time_before_eq(jiffies, end)); |
1000 | 1016 | ||
1001 | if (ne != 0) | 1017 | if (ne != 0) |
@@ -2181,7 +2197,7 @@ static int hns_roce_v1_poll_one(struct hns_roce_cq *hr_cq, | |||
2181 | } | 2197 | } |
2182 | wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; | 2198 | wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; |
2183 | ++wq->tail; | 2199 | ++wq->tail; |
2184 | } else { | 2200 | } else { |
2185 | /* RQ conrespond to CQE */ | 2201 | /* RQ conrespond to CQE */ |
2186 | wc->byte_len = le32_to_cpu(cqe->byte_cnt); | 2202 | wc->byte_len = le32_to_cpu(cqe->byte_cnt); |
2187 | opcode = roce_get_field(cqe->cqe_byte_4, | 2203 | opcode = roce_get_field(cqe->cqe_byte_4, |
@@ -3533,10 +3549,12 @@ static int check_qp_db_process_status(struct hns_roce_dev *hr_dev, | |||
3533 | old_cnt = roce_get_field(old_send, | 3549 | old_cnt = roce_get_field(old_send, |
3534 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_M, | 3550 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_M, |
3535 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_S); | 3551 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_S); |
3536 | if (cur_cnt - old_cnt > SDB_ST_CMP_VAL) | 3552 | if (cur_cnt - old_cnt > |
3553 | SDB_ST_CMP_VAL) { | ||
3537 | success_flags = 1; | 3554 | success_flags = 1; |
3538 | else { | 3555 | } else { |
3539 | send_ptr = roce_get_field(old_send, | 3556 | send_ptr = |
3557 | roce_get_field(old_send, | ||
3540 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_M, | 3558 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_M, |
3541 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_S) + | 3559 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_S) + |
3542 | roce_get_field(sdb_retry_cnt, | 3560 | roce_get_field(sdb_retry_cnt, |
@@ -3641,6 +3659,7 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3641 | struct hns_roce_dev *hr_dev; | 3659 | struct hns_roce_dev *hr_dev; |
3642 | struct hns_roce_qp *hr_qp; | 3660 | struct hns_roce_qp *hr_qp; |
3643 | struct device *dev; | 3661 | struct device *dev; |
3662 | unsigned long qpn; | ||
3644 | int ret; | 3663 | int ret; |
3645 | 3664 | ||
3646 | qp_work_entry = container_of(work, struct hns_roce_qp_work, work); | 3665 | qp_work_entry = container_of(work, struct hns_roce_qp_work, work); |
@@ -3648,8 +3667,9 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3648 | dev = &hr_dev->pdev->dev; | 3667 | dev = &hr_dev->pdev->dev; |
3649 | priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv; | 3668 | priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv; |
3650 | hr_qp = qp_work_entry->qp; | 3669 | hr_qp = qp_work_entry->qp; |
3670 | qpn = hr_qp->qpn; | ||
3651 | 3671 | ||
3652 | dev_dbg(dev, "Schedule destroy QP(0x%lx) work.\n", hr_qp->qpn); | 3672 | dev_dbg(dev, "Schedule destroy QP(0x%lx) work.\n", qpn); |
3653 | 3673 | ||
3654 | qp_work_entry->sche_cnt++; | 3674 | qp_work_entry->sche_cnt++; |
3655 | 3675 | ||
@@ -3660,7 +3680,7 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3660 | &qp_work_entry->db_wait_stage); | 3680 | &qp_work_entry->db_wait_stage); |
3661 | if (ret) { | 3681 | if (ret) { |
3662 | dev_err(dev, "Check QP(0x%lx) db process status failed!\n", | 3682 | dev_err(dev, "Check QP(0x%lx) db process status failed!\n", |
3663 | hr_qp->qpn); | 3683 | qpn); |
3664 | return; | 3684 | return; |
3665 | } | 3685 | } |
3666 | 3686 | ||
@@ -3674,7 +3694,7 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3674 | ret = hns_roce_v1_modify_qp(&hr_qp->ibqp, NULL, 0, hr_qp->state, | 3694 | ret = hns_roce_v1_modify_qp(&hr_qp->ibqp, NULL, 0, hr_qp->state, |
3675 | IB_QPS_RESET); | 3695 | IB_QPS_RESET); |
3676 | if (ret) { | 3696 | if (ret) { |
3677 | dev_err(dev, "Modify QP(0x%lx) to RST failed!\n", hr_qp->qpn); | 3697 | dev_err(dev, "Modify QP(0x%lx) to RST failed!\n", qpn); |
3678 | return; | 3698 | return; |
3679 | } | 3699 | } |
3680 | 3700 | ||
@@ -3683,14 +3703,14 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3683 | 3703 | ||
3684 | if (hr_qp->ibqp.qp_type == IB_QPT_RC) { | 3704 | if (hr_qp->ibqp.qp_type == IB_QPT_RC) { |
3685 | /* RC QP, release QPN */ | 3705 | /* RC QP, release QPN */ |
3686 | hns_roce_release_range_qp(hr_dev, hr_qp->qpn, 1); | 3706 | hns_roce_release_range_qp(hr_dev, qpn, 1); |
3687 | kfree(hr_qp); | 3707 | kfree(hr_qp); |
3688 | } else | 3708 | } else |
3689 | kfree(hr_to_hr_sqp(hr_qp)); | 3709 | kfree(hr_to_hr_sqp(hr_qp)); |
3690 | 3710 | ||
3691 | kfree(qp_work_entry); | 3711 | kfree(qp_work_entry); |
3692 | 3712 | ||
3693 | dev_dbg(dev, "Accomplished destroy QP(0x%lx) work.\n", hr_qp->qpn); | 3713 | dev_dbg(dev, "Accomplished destroy QP(0x%lx) work.\n", qpn); |
3694 | } | 3714 | } |
3695 | 3715 | ||
3696 | int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) | 3716 | int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) |
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index c3b41f95e70a..d9777b662eba 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c | |||
@@ -125,8 +125,6 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port, | |||
125 | return -ENODEV; | 125 | return -ENODEV; |
126 | } | 126 | } |
127 | 127 | ||
128 | spin_lock_bh(&hr_dev->iboe.lock); | ||
129 | |||
130 | switch (event) { | 128 | switch (event) { |
131 | case NETDEV_UP: | 129 | case NETDEV_UP: |
132 | case NETDEV_CHANGE: | 130 | case NETDEV_CHANGE: |
@@ -144,7 +142,6 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port, | |||
144 | break; | 142 | break; |
145 | } | 143 | } |
146 | 144 | ||
147 | spin_unlock_bh(&hr_dev->iboe.lock); | ||
148 | return 0; | 145 | return 0; |
149 | } | 146 | } |
150 | 147 | ||
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c index 4f5a143fc0a7..ff931c580557 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c | |||
@@ -102,7 +102,7 @@ static int mlx4_ib_alloc_cq_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq_buf * | |||
102 | int err; | 102 | int err; |
103 | 103 | ||
104 | err = mlx4_buf_alloc(dev->dev, nent * dev->dev->caps.cqe_size, | 104 | err = mlx4_buf_alloc(dev->dev, nent * dev->dev->caps.cqe_size, |
105 | PAGE_SIZE * 2, &buf->buf, GFP_KERNEL); | 105 | PAGE_SIZE * 2, &buf->buf); |
106 | 106 | ||
107 | if (err) | 107 | if (err) |
108 | goto out; | 108 | goto out; |
@@ -113,7 +113,7 @@ static int mlx4_ib_alloc_cq_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq_buf * | |||
113 | if (err) | 113 | if (err) |
114 | goto err_buf; | 114 | goto err_buf; |
115 | 115 | ||
116 | err = mlx4_buf_write_mtt(dev->dev, &buf->mtt, &buf->buf, GFP_KERNEL); | 116 | err = mlx4_buf_write_mtt(dev->dev, &buf->mtt, &buf->buf); |
117 | if (err) | 117 | if (err) |
118 | goto err_mtt; | 118 | goto err_mtt; |
119 | 119 | ||
@@ -219,7 +219,7 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, | |||
219 | 219 | ||
220 | uar = &to_mucontext(context)->uar; | 220 | uar = &to_mucontext(context)->uar; |
221 | } else { | 221 | } else { |
222 | err = mlx4_db_alloc(dev->dev, &cq->db, 1, GFP_KERNEL); | 222 | err = mlx4_db_alloc(dev->dev, &cq->db, 1); |
223 | if (err) | 223 | if (err) |
224 | goto err_cq; | 224 | goto err_cq; |
225 | 225 | ||
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 75b2f7d4cd95..d1b43cbbfea7 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
@@ -1155,7 +1155,7 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext) | |||
1155 | * call to mlx4_ib_vma_close. | 1155 | * call to mlx4_ib_vma_close. |
1156 | */ | 1156 | */ |
1157 | put_task_struct(owning_process); | 1157 | put_task_struct(owning_process); |
1158 | msleep(1); | 1158 | usleep_range(1000, 2000); |
1159 | owning_process = get_pid_task(ibcontext->tgid, | 1159 | owning_process = get_pid_task(ibcontext->tgid, |
1160 | PIDTYPE_PID); | 1160 | PIDTYPE_PID); |
1161 | if (!owning_process || | 1161 | if (!owning_process || |
diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c index 3405e947dc1e..b73f89700ef9 100644 --- a/drivers/infiniband/hw/mlx4/mcg.c +++ b/drivers/infiniband/hw/mlx4/mcg.c | |||
@@ -1091,7 +1091,7 @@ static void _mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy | |||
1091 | if (!count) | 1091 | if (!count) |
1092 | break; | 1092 | break; |
1093 | 1093 | ||
1094 | msleep(1); | 1094 | usleep_range(1000, 2000); |
1095 | } while (time_after(end, jiffies)); | 1095 | } while (time_after(end, jiffies)); |
1096 | 1096 | ||
1097 | flush_workqueue(ctx->mcg_wq); | 1097 | flush_workqueue(ctx->mcg_wq); |
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h index c2b9cbf4da05..9db82e67e959 100644 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h | |||
@@ -185,7 +185,6 @@ enum mlx4_ib_qp_flags { | |||
185 | MLX4_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO, | 185 | MLX4_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO, |
186 | MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK, | 186 | MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK, |
187 | MLX4_IB_QP_NETIF = IB_QP_CREATE_NETIF_QP, | 187 | MLX4_IB_QP_NETIF = IB_QP_CREATE_NETIF_QP, |
188 | MLX4_IB_QP_CREATE_USE_GFP_NOIO = IB_QP_CREATE_USE_GFP_NOIO, | ||
189 | 188 | ||
190 | /* Mellanox specific flags start from IB_QP_CREATE_RESERVED_START */ | 189 | /* Mellanox specific flags start from IB_QP_CREATE_RESERVED_START */ |
191 | MLX4_IB_ROCE_V2_GSI_QP = MLX4_IB_QP_CREATE_ROCE_V2_GSI, | 190 | MLX4_IB_ROCE_V2_GSI_QP = MLX4_IB_QP_CREATE_ROCE_V2_GSI, |
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 996e9058e515..75c0e6c5dd56 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c | |||
@@ -634,8 +634,8 @@ static void mlx4_ib_free_qp_counter(struct mlx4_ib_dev *dev, | |||
634 | 634 | ||
635 | static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | 635 | static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, |
636 | struct ib_qp_init_attr *init_attr, | 636 | struct ib_qp_init_attr *init_attr, |
637 | struct ib_udata *udata, int sqpn, struct mlx4_ib_qp **caller_qp, | 637 | struct ib_udata *udata, int sqpn, |
638 | gfp_t gfp) | 638 | struct mlx4_ib_qp **caller_qp) |
639 | { | 639 | { |
640 | int qpn; | 640 | int qpn; |
641 | int err; | 641 | int err; |
@@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
691 | if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI || | 691 | if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI || |
692 | (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER | | 692 | (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER | |
693 | MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) { | 693 | MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) { |
694 | sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp); | 694 | sqp = kzalloc(sizeof(struct mlx4_ib_sqp), GFP_KERNEL); |
695 | if (!sqp) | 695 | if (!sqp) |
696 | return -ENOMEM; | 696 | return -ENOMEM; |
697 | qp = &sqp->qp; | 697 | qp = &sqp->qp; |
698 | qp->pri.vid = 0xFFFF; | 698 | qp->pri.vid = 0xFFFF; |
699 | qp->alt.vid = 0xFFFF; | 699 | qp->alt.vid = 0xFFFF; |
700 | } else { | 700 | } else { |
701 | qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp); | 701 | qp = kzalloc(sizeof(struct mlx4_ib_qp), GFP_KERNEL); |
702 | if (!qp) | 702 | if (!qp) |
703 | return -ENOMEM; | 703 | return -ENOMEM; |
704 | qp->pri.vid = 0xFFFF; | 704 | qp->pri.vid = 0xFFFF; |
@@ -780,7 +780,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
780 | goto err; | 780 | goto err; |
781 | 781 | ||
782 | if (qp_has_rq(init_attr)) { | 782 | if (qp_has_rq(init_attr)) { |
783 | err = mlx4_db_alloc(dev->dev, &qp->db, 0, gfp); | 783 | err = mlx4_db_alloc(dev->dev, &qp->db, 0); |
784 | if (err) | 784 | if (err) |
785 | goto err; | 785 | goto err; |
786 | 786 | ||
@@ -788,7 +788,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
788 | } | 788 | } |
789 | 789 | ||
790 | if (mlx4_buf_alloc(dev->dev, qp->buf_size, qp->buf_size, | 790 | if (mlx4_buf_alloc(dev->dev, qp->buf_size, qp->buf_size, |
791 | &qp->buf, gfp)) { | 791 | &qp->buf)) { |
792 | memcpy(&init_attr->cap, &backup_cap, | 792 | memcpy(&init_attr->cap, &backup_cap, |
793 | sizeof(backup_cap)); | 793 | sizeof(backup_cap)); |
794 | err = set_kernel_sq_size(dev, &init_attr->cap, qp_type, | 794 | err = set_kernel_sq_size(dev, &init_attr->cap, qp_type, |
@@ -797,7 +797,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
797 | goto err_db; | 797 | goto err_db; |
798 | 798 | ||
799 | if (mlx4_buf_alloc(dev->dev, qp->buf_size, | 799 | if (mlx4_buf_alloc(dev->dev, qp->buf_size, |
800 | PAGE_SIZE * 2, &qp->buf, gfp)) { | 800 | PAGE_SIZE * 2, &qp->buf)) { |
801 | err = -ENOMEM; | 801 | err = -ENOMEM; |
802 | goto err_db; | 802 | goto err_db; |
803 | } | 803 | } |
@@ -808,20 +808,20 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
808 | if (err) | 808 | if (err) |
809 | goto err_buf; | 809 | goto err_buf; |
810 | 810 | ||
811 | err = mlx4_buf_write_mtt(dev->dev, &qp->mtt, &qp->buf, gfp); | 811 | err = mlx4_buf_write_mtt(dev->dev, &qp->mtt, &qp->buf); |
812 | if (err) | 812 | if (err) |
813 | goto err_mtt; | 813 | goto err_mtt; |
814 | 814 | ||
815 | qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt, sizeof(u64), | 815 | qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt, sizeof(u64), |
816 | gfp | __GFP_NOWARN); | 816 | GFP_KERNEL | __GFP_NOWARN); |
817 | if (!qp->sq.wrid) | 817 | if (!qp->sq.wrid) |
818 | qp->sq.wrid = __vmalloc(qp->sq.wqe_cnt * sizeof(u64), | 818 | qp->sq.wrid = __vmalloc(qp->sq.wqe_cnt * sizeof(u64), |
819 | gfp, PAGE_KERNEL); | 819 | GFP_KERNEL, PAGE_KERNEL); |
820 | qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt, sizeof(u64), | 820 | qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt, sizeof(u64), |
821 | gfp | __GFP_NOWARN); | 821 | GFP_KERNEL | __GFP_NOWARN); |
822 | if (!qp->rq.wrid) | 822 | if (!qp->rq.wrid) |
823 | qp->rq.wrid = __vmalloc(qp->rq.wqe_cnt * sizeof(u64), | 823 | qp->rq.wrid = __vmalloc(qp->rq.wqe_cnt * sizeof(u64), |
824 | gfp, PAGE_KERNEL); | 824 | GFP_KERNEL, PAGE_KERNEL); |
825 | if (!qp->sq.wrid || !qp->rq.wrid) { | 825 | if (!qp->sq.wrid || !qp->rq.wrid) { |
826 | err = -ENOMEM; | 826 | err = -ENOMEM; |
827 | goto err_wrid; | 827 | goto err_wrid; |
@@ -859,7 +859,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
859 | if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) | 859 | if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) |
860 | qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK; | 860 | qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK; |
861 | 861 | ||
862 | err = mlx4_qp_alloc(dev->dev, qpn, &qp->mqp, gfp); | 862 | err = mlx4_qp_alloc(dev->dev, qpn, &qp->mqp); |
863 | if (err) | 863 | if (err) |
864 | goto err_qpn; | 864 | goto err_qpn; |
865 | 865 | ||
@@ -1127,10 +1127,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1127 | int err; | 1127 | int err; |
1128 | int sup_u_create_flags = MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK; | 1128 | int sup_u_create_flags = MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK; |
1129 | u16 xrcdn = 0; | 1129 | u16 xrcdn = 0; |
1130 | gfp_t gfp; | ||
1131 | 1130 | ||
1132 | gfp = (init_attr->create_flags & MLX4_IB_QP_CREATE_USE_GFP_NOIO) ? | ||
1133 | GFP_NOIO : GFP_KERNEL; | ||
1134 | /* | 1131 | /* |
1135 | * We only support LSO, vendor flag1, and multicast loopback blocking, | 1132 | * We only support LSO, vendor flag1, and multicast loopback blocking, |
1136 | * and only for kernel UD QPs. | 1133 | * and only for kernel UD QPs. |
@@ -1140,8 +1137,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1140 | MLX4_IB_SRIOV_TUNNEL_QP | | 1137 | MLX4_IB_SRIOV_TUNNEL_QP | |
1141 | MLX4_IB_SRIOV_SQP | | 1138 | MLX4_IB_SRIOV_SQP | |
1142 | MLX4_IB_QP_NETIF | | 1139 | MLX4_IB_QP_NETIF | |
1143 | MLX4_IB_QP_CREATE_ROCE_V2_GSI | | 1140 | MLX4_IB_QP_CREATE_ROCE_V2_GSI)) |
1144 | MLX4_IB_QP_CREATE_USE_GFP_NOIO)) | ||
1145 | return ERR_PTR(-EINVAL); | 1141 | return ERR_PTR(-EINVAL); |
1146 | 1142 | ||
1147 | if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) { | 1143 | if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) { |
@@ -1154,7 +1150,6 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1154 | return ERR_PTR(-EINVAL); | 1150 | return ERR_PTR(-EINVAL); |
1155 | 1151 | ||
1156 | if ((init_attr->create_flags & ~(MLX4_IB_SRIOV_SQP | | 1152 | if ((init_attr->create_flags & ~(MLX4_IB_SRIOV_SQP | |
1157 | MLX4_IB_QP_CREATE_USE_GFP_NOIO | | ||
1158 | MLX4_IB_QP_CREATE_ROCE_V2_GSI | | 1153 | MLX4_IB_QP_CREATE_ROCE_V2_GSI | |
1159 | MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK) && | 1154 | MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK) && |
1160 | init_attr->qp_type != IB_QPT_UD) || | 1155 | init_attr->qp_type != IB_QPT_UD) || |
@@ -1179,7 +1174,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1179 | case IB_QPT_RC: | 1174 | case IB_QPT_RC: |
1180 | case IB_QPT_UC: | 1175 | case IB_QPT_UC: |
1181 | case IB_QPT_RAW_PACKET: | 1176 | case IB_QPT_RAW_PACKET: |
1182 | qp = kzalloc(sizeof *qp, gfp); | 1177 | qp = kzalloc(sizeof(*qp), GFP_KERNEL); |
1183 | if (!qp) | 1178 | if (!qp) |
1184 | return ERR_PTR(-ENOMEM); | 1179 | return ERR_PTR(-ENOMEM); |
1185 | qp->pri.vid = 0xFFFF; | 1180 | qp->pri.vid = 0xFFFF; |
@@ -1188,7 +1183,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1188 | case IB_QPT_UD: | 1183 | case IB_QPT_UD: |
1189 | { | 1184 | { |
1190 | err = create_qp_common(to_mdev(pd->device), pd, init_attr, | 1185 | err = create_qp_common(to_mdev(pd->device), pd, init_attr, |
1191 | udata, 0, &qp, gfp); | 1186 | udata, 0, &qp); |
1192 | if (err) { | 1187 | if (err) { |
1193 | kfree(qp); | 1188 | kfree(qp); |
1194 | return ERR_PTR(err); | 1189 | return ERR_PTR(err); |
@@ -1217,8 +1212,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1217 | } | 1212 | } |
1218 | 1213 | ||
1219 | err = create_qp_common(to_mdev(pd->device), pd, init_attr, udata, | 1214 | err = create_qp_common(to_mdev(pd->device), pd, init_attr, udata, |
1220 | sqpn, | 1215 | sqpn, &qp); |
1221 | &qp, gfp); | ||
1222 | if (err) | 1216 | if (err) |
1223 | return ERR_PTR(err); | 1217 | return ERR_PTR(err); |
1224 | 1218 | ||
diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c index e32dd58937a8..0facaf5f6d23 100644 --- a/drivers/infiniband/hw/mlx4/srq.c +++ b/drivers/infiniband/hw/mlx4/srq.c | |||
@@ -135,14 +135,14 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, | |||
135 | if (err) | 135 | if (err) |
136 | goto err_mtt; | 136 | goto err_mtt; |
137 | } else { | 137 | } else { |
138 | err = mlx4_db_alloc(dev->dev, &srq->db, 0, GFP_KERNEL); | 138 | err = mlx4_db_alloc(dev->dev, &srq->db, 0); |
139 | if (err) | 139 | if (err) |
140 | goto err_srq; | 140 | goto err_srq; |
141 | 141 | ||
142 | *srq->db.db = 0; | 142 | *srq->db.db = 0; |
143 | 143 | ||
144 | if (mlx4_buf_alloc(dev->dev, buf_size, PAGE_SIZE * 2, &srq->buf, | 144 | if (mlx4_buf_alloc(dev->dev, buf_size, PAGE_SIZE * 2, |
145 | GFP_KERNEL)) { | 145 | &srq->buf)) { |
146 | err = -ENOMEM; | 146 | err = -ENOMEM; |
147 | goto err_db; | 147 | goto err_db; |
148 | } | 148 | } |
@@ -167,7 +167,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, | |||
167 | if (err) | 167 | if (err) |
168 | goto err_buf; | 168 | goto err_buf; |
169 | 169 | ||
170 | err = mlx4_buf_write_mtt(dev->dev, &srq->mtt, &srq->buf, GFP_KERNEL); | 170 | err = mlx4_buf_write_mtt(dev->dev, &srq->mtt, &srq->buf); |
171 | if (err) | 171 | if (err) |
172 | goto err_mtt; | 172 | goto err_mtt; |
173 | 173 | ||
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 763bb5b36144..8ab2f1360a45 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c | |||
@@ -582,6 +582,15 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c) | |||
582 | } | 582 | } |
583 | } | 583 | } |
584 | 584 | ||
585 | static void mlx5_mr_cache_debugfs_cleanup(struct mlx5_ib_dev *dev) | ||
586 | { | ||
587 | if (!mlx5_debugfs_root) | ||
588 | return; | ||
589 | |||
590 | debugfs_remove_recursive(dev->cache.root); | ||
591 | dev->cache.root = NULL; | ||
592 | } | ||
593 | |||
585 | static int mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev) | 594 | static int mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev) |
586 | { | 595 | { |
587 | struct mlx5_mr_cache *cache = &dev->cache; | 596 | struct mlx5_mr_cache *cache = &dev->cache; |
@@ -600,38 +609,34 @@ static int mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev) | |||
600 | sprintf(ent->name, "%d", ent->order); | 609 | sprintf(ent->name, "%d", ent->order); |
601 | ent->dir = debugfs_create_dir(ent->name, cache->root); | 610 | ent->dir = debugfs_create_dir(ent->name, cache->root); |
602 | if (!ent->dir) | 611 | if (!ent->dir) |
603 | return -ENOMEM; | 612 | goto err; |
604 | 613 | ||
605 | ent->fsize = debugfs_create_file("size", 0600, ent->dir, ent, | 614 | ent->fsize = debugfs_create_file("size", 0600, ent->dir, ent, |
606 | &size_fops); | 615 | &size_fops); |
607 | if (!ent->fsize) | 616 | if (!ent->fsize) |
608 | return -ENOMEM; | 617 | goto err; |
609 | 618 | ||
610 | ent->flimit = debugfs_create_file("limit", 0600, ent->dir, ent, | 619 | ent->flimit = debugfs_create_file("limit", 0600, ent->dir, ent, |
611 | &limit_fops); | 620 | &limit_fops); |
612 | if (!ent->flimit) | 621 | if (!ent->flimit) |
613 | return -ENOMEM; | 622 | goto err; |
614 | 623 | ||
615 | ent->fcur = debugfs_create_u32("cur", 0400, ent->dir, | 624 | ent->fcur = debugfs_create_u32("cur", 0400, ent->dir, |
616 | &ent->cur); | 625 | &ent->cur); |
617 | if (!ent->fcur) | 626 | if (!ent->fcur) |
618 | return -ENOMEM; | 627 | goto err; |
619 | 628 | ||
620 | ent->fmiss = debugfs_create_u32("miss", 0600, ent->dir, | 629 | ent->fmiss = debugfs_create_u32("miss", 0600, ent->dir, |
621 | &ent->miss); | 630 | &ent->miss); |
622 | if (!ent->fmiss) | 631 | if (!ent->fmiss) |
623 | return -ENOMEM; | 632 | goto err; |
624 | } | 633 | } |
625 | 634 | ||
626 | return 0; | 635 | return 0; |
627 | } | 636 | err: |
628 | 637 | mlx5_mr_cache_debugfs_cleanup(dev); | |
629 | static void mlx5_mr_cache_debugfs_cleanup(struct mlx5_ib_dev *dev) | ||
630 | { | ||
631 | if (!mlx5_debugfs_root) | ||
632 | return; | ||
633 | 638 | ||
634 | debugfs_remove_recursive(dev->cache.root); | 639 | return -ENOMEM; |
635 | } | 640 | } |
636 | 641 | ||
637 | static void delay_time_func(unsigned long ctx) | 642 | static void delay_time_func(unsigned long ctx) |
@@ -692,6 +697,11 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) | |||
692 | if (err) | 697 | if (err) |
693 | mlx5_ib_warn(dev, "cache debugfs failure\n"); | 698 | mlx5_ib_warn(dev, "cache debugfs failure\n"); |
694 | 699 | ||
700 | /* | ||
701 | * We don't want to fail driver if debugfs failed to initialize, | ||
702 | * so we are not forwarding error to the user. | ||
703 | */ | ||
704 | |||
695 | return 0; | 705 | return 0; |
696 | } | 706 | } |
697 | 707 | ||
@@ -1779,7 +1789,7 @@ mlx5_ib_sg_to_klms(struct mlx5_ib_mr *mr, | |||
1779 | mr->ndescs = sg_nents; | 1789 | mr->ndescs = sg_nents; |
1780 | 1790 | ||
1781 | for_each_sg(sgl, sg, sg_nents, i) { | 1791 | for_each_sg(sgl, sg, sg_nents, i) { |
1782 | if (unlikely(i > mr->max_descs)) | 1792 | if (unlikely(i >= mr->max_descs)) |
1783 | break; | 1793 | break; |
1784 | klms[i].va = cpu_to_be64(sg_dma_address(sg) + sg_offset); | 1794 | klms[i].va = cpu_to_be64(sg_dma_address(sg) + sg_offset); |
1785 | klms[i].bcount = cpu_to_be32(sg_dma_len(sg) - sg_offset); | 1795 | klms[i].bcount = cpu_to_be32(sg_dma_len(sg) - sg_offset); |
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c index 8f9d8b4ad583..b0adf65e4bdb 100644 --- a/drivers/infiniband/hw/nes/nes_hw.c +++ b/drivers/infiniband/hw/nes/nes_hw.c | |||
@@ -551,7 +551,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) { | |||
551 | if ((0x0F000100 == (pcs_control_status0 & 0x0F000100)) | 551 | if ((0x0F000100 == (pcs_control_status0 & 0x0F000100)) |
552 | || (0x0F000100 == (pcs_control_status1 & 0x0F000100))) | 552 | || (0x0F000100 == (pcs_control_status1 & 0x0F000100))) |
553 | int_cnt++; | 553 | int_cnt++; |
554 | msleep(1); | 554 | usleep_range(1000, 2000); |
555 | } | 555 | } |
556 | if (int_cnt > 1) { | 556 | if (int_cnt > 1) { |
557 | spin_lock_irqsave(&nesadapter->phy_lock, flags); | 557 | spin_lock_irqsave(&nesadapter->phy_lock, flags); |
@@ -592,7 +592,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) { | |||
592 | break; | 592 | break; |
593 | } | 593 | } |
594 | } | 594 | } |
595 | msleep(1); | 595 | usleep_range(1000, 2000); |
596 | } | 596 | } |
597 | } | 597 | } |
598 | } | 598 | } |
diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c index 5984981e7dd4..a343e3b5d4cb 100644 --- a/drivers/infiniband/hw/qib/qib_qp.c +++ b/drivers/infiniband/hw/qib/qib_qp.c | |||
@@ -104,10 +104,9 @@ const struct rvt_operation_params qib_post_parms[RVT_OPERATION_MAX] = { | |||
104 | 104 | ||
105 | }; | 105 | }; |
106 | 106 | ||
107 | static void get_map_page(struct rvt_qpn_table *qpt, struct rvt_qpn_map *map, | 107 | static void get_map_page(struct rvt_qpn_table *qpt, struct rvt_qpn_map *map) |
108 | gfp_t gfp) | ||
109 | { | 108 | { |
110 | unsigned long page = get_zeroed_page(gfp); | 109 | unsigned long page = get_zeroed_page(GFP_KERNEL); |
111 | 110 | ||
112 | /* | 111 | /* |
113 | * Free the page if someone raced with us installing it. | 112 | * Free the page if someone raced with us installing it. |
@@ -126,7 +125,7 @@ static void get_map_page(struct rvt_qpn_table *qpt, struct rvt_qpn_map *map, | |||
126 | * zero/one for QP type IB_QPT_SMI/IB_QPT_GSI. | 125 | * zero/one for QP type IB_QPT_SMI/IB_QPT_GSI. |
127 | */ | 126 | */ |
128 | int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | 127 | int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, |
129 | enum ib_qp_type type, u8 port, gfp_t gfp) | 128 | enum ib_qp_type type, u8 port) |
130 | { | 129 | { |
131 | u32 i, offset, max_scan, qpn; | 130 | u32 i, offset, max_scan, qpn; |
132 | struct rvt_qpn_map *map; | 131 | struct rvt_qpn_map *map; |
@@ -160,7 +159,7 @@ int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | |||
160 | max_scan = qpt->nmaps - !offset; | 159 | max_scan = qpt->nmaps - !offset; |
161 | for (i = 0;;) { | 160 | for (i = 0;;) { |
162 | if (unlikely(!map->page)) { | 161 | if (unlikely(!map->page)) { |
163 | get_map_page(qpt, map, gfp); | 162 | get_map_page(qpt, map); |
164 | if (unlikely(!map->page)) | 163 | if (unlikely(!map->page)) |
165 | break; | 164 | break; |
166 | } | 165 | } |
@@ -317,16 +316,16 @@ u32 qib_mtu_from_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, u32 pmtu) | |||
317 | return ib_mtu_enum_to_int(pmtu); | 316 | return ib_mtu_enum_to_int(pmtu); |
318 | } | 317 | } |
319 | 318 | ||
320 | void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, gfp_t gfp) | 319 | void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp) |
321 | { | 320 | { |
322 | struct qib_qp_priv *priv; | 321 | struct qib_qp_priv *priv; |
323 | 322 | ||
324 | priv = kzalloc(sizeof(*priv), gfp); | 323 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
325 | if (!priv) | 324 | if (!priv) |
326 | return ERR_PTR(-ENOMEM); | 325 | return ERR_PTR(-ENOMEM); |
327 | priv->owner = qp; | 326 | priv->owner = qp; |
328 | 327 | ||
329 | priv->s_hdr = kzalloc(sizeof(*priv->s_hdr), gfp); | 328 | priv->s_hdr = kzalloc(sizeof(*priv->s_hdr), GFP_KERNEL); |
330 | if (!priv->s_hdr) { | 329 | if (!priv->s_hdr) { |
331 | kfree(priv); | 330 | kfree(priv); |
332 | return ERR_PTR(-ENOMEM); | 331 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/infiniband/hw/qib/qib_verbs.h b/drivers/infiniband/hw/qib/qib_verbs.h index da0db5485ddc..a52fc67b40d7 100644 --- a/drivers/infiniband/hw/qib/qib_verbs.h +++ b/drivers/infiniband/hw/qib/qib_verbs.h | |||
@@ -274,11 +274,11 @@ int qib_get_counters(struct qib_pportdata *ppd, | |||
274 | * Functions provided by qib driver for rdmavt to use | 274 | * Functions provided by qib driver for rdmavt to use |
275 | */ | 275 | */ |
276 | unsigned qib_free_all_qps(struct rvt_dev_info *rdi); | 276 | unsigned qib_free_all_qps(struct rvt_dev_info *rdi); |
277 | void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, gfp_t gfp); | 277 | void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
278 | void qib_qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); | 278 | void qib_qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
279 | void qib_notify_qp_reset(struct rvt_qp *qp); | 279 | void qib_notify_qp_reset(struct rvt_qp *qp); |
280 | int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | 280 | int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, |
281 | enum ib_qp_type type, u8 port, gfp_t gfp); | 281 | enum ib_qp_type type, u8 port); |
282 | void qib_restart_rc(struct rvt_qp *qp, u32 psn, int wait); | 282 | void qib_restart_rc(struct rvt_qp *qp, u32 psn, int wait); |
283 | #ifdef CONFIG_DEBUG_FS | 283 | #ifdef CONFIG_DEBUG_FS |
284 | 284 | ||
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c index 727e81cc2c8f..459865439a0b 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c | |||
@@ -118,10 +118,9 @@ const int ib_rvt_state_ops[IB_QPS_ERR + 1] = { | |||
118 | EXPORT_SYMBOL(ib_rvt_state_ops); | 118 | EXPORT_SYMBOL(ib_rvt_state_ops); |
119 | 119 | ||
120 | static void get_map_page(struct rvt_qpn_table *qpt, | 120 | static void get_map_page(struct rvt_qpn_table *qpt, |
121 | struct rvt_qpn_map *map, | 121 | struct rvt_qpn_map *map) |
122 | gfp_t gfp) | ||
123 | { | 122 | { |
124 | unsigned long page = get_zeroed_page(gfp); | 123 | unsigned long page = get_zeroed_page(GFP_KERNEL); |
125 | 124 | ||
126 | /* | 125 | /* |
127 | * Free the page if someone raced with us installing it. | 126 | * Free the page if someone raced with us installing it. |
@@ -173,7 +172,7 @@ static int init_qpn_table(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt) | |||
173 | rdi->dparms.qpn_res_start, rdi->dparms.qpn_res_end); | 172 | rdi->dparms.qpn_res_start, rdi->dparms.qpn_res_end); |
174 | for (i = rdi->dparms.qpn_res_start; i <= rdi->dparms.qpn_res_end; i++) { | 173 | for (i = rdi->dparms.qpn_res_start; i <= rdi->dparms.qpn_res_end; i++) { |
175 | if (!map->page) { | 174 | if (!map->page) { |
176 | get_map_page(qpt, map, GFP_KERNEL); | 175 | get_map_page(qpt, map); |
177 | if (!map->page) { | 176 | if (!map->page) { |
178 | ret = -ENOMEM; | 177 | ret = -ENOMEM; |
179 | break; | 178 | break; |
@@ -342,14 +341,14 @@ static inline unsigned mk_qpn(struct rvt_qpn_table *qpt, | |||
342 | * Return: The queue pair number | 341 | * Return: The queue pair number |
343 | */ | 342 | */ |
344 | static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | 343 | static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, |
345 | enum ib_qp_type type, u8 port_num, gfp_t gfp) | 344 | enum ib_qp_type type, u8 port_num) |
346 | { | 345 | { |
347 | u32 i, offset, max_scan, qpn; | 346 | u32 i, offset, max_scan, qpn; |
348 | struct rvt_qpn_map *map; | 347 | struct rvt_qpn_map *map; |
349 | u32 ret; | 348 | u32 ret; |
350 | 349 | ||
351 | if (rdi->driver_f.alloc_qpn) | 350 | if (rdi->driver_f.alloc_qpn) |
352 | return rdi->driver_f.alloc_qpn(rdi, qpt, type, port_num, gfp); | 351 | return rdi->driver_f.alloc_qpn(rdi, qpt, type, port_num); |
353 | 352 | ||
354 | if (type == IB_QPT_SMI || type == IB_QPT_GSI) { | 353 | if (type == IB_QPT_SMI || type == IB_QPT_GSI) { |
355 | unsigned n; | 354 | unsigned n; |
@@ -374,7 +373,7 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | |||
374 | max_scan = qpt->nmaps - !offset; | 373 | max_scan = qpt->nmaps - !offset; |
375 | for (i = 0;;) { | 374 | for (i = 0;;) { |
376 | if (unlikely(!map->page)) { | 375 | if (unlikely(!map->page)) { |
377 | get_map_page(qpt, map, gfp); | 376 | get_map_page(qpt, map); |
378 | if (unlikely(!map->page)) | 377 | if (unlikely(!map->page)) |
379 | break; | 378 | break; |
380 | } | 379 | } |
@@ -672,7 +671,6 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
672 | struct ib_qp *ret = ERR_PTR(-ENOMEM); | 671 | struct ib_qp *ret = ERR_PTR(-ENOMEM); |
673 | struct rvt_dev_info *rdi = ib_to_rvt(ibpd->device); | 672 | struct rvt_dev_info *rdi = ib_to_rvt(ibpd->device); |
674 | void *priv = NULL; | 673 | void *priv = NULL; |
675 | gfp_t gfp; | ||
676 | size_t sqsize; | 674 | size_t sqsize; |
677 | 675 | ||
678 | if (!rdi) | 676 | if (!rdi) |
@@ -680,18 +678,9 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
680 | 678 | ||
681 | if (init_attr->cap.max_send_sge > rdi->dparms.props.max_sge || | 679 | if (init_attr->cap.max_send_sge > rdi->dparms.props.max_sge || |
682 | init_attr->cap.max_send_wr > rdi->dparms.props.max_qp_wr || | 680 | init_attr->cap.max_send_wr > rdi->dparms.props.max_qp_wr || |
683 | init_attr->create_flags & ~(IB_QP_CREATE_USE_GFP_NOIO)) | 681 | init_attr->create_flags) |
684 | return ERR_PTR(-EINVAL); | 682 | return ERR_PTR(-EINVAL); |
685 | 683 | ||
686 | /* GFP_NOIO is applicable to RC QP's only */ | ||
687 | |||
688 | if (init_attr->create_flags & IB_QP_CREATE_USE_GFP_NOIO && | ||
689 | init_attr->qp_type != IB_QPT_RC) | ||
690 | return ERR_PTR(-EINVAL); | ||
691 | |||
692 | gfp = init_attr->create_flags & IB_QP_CREATE_USE_GFP_NOIO ? | ||
693 | GFP_NOIO : GFP_KERNEL; | ||
694 | |||
695 | /* Check receive queue parameters if no SRQ is specified. */ | 684 | /* Check receive queue parameters if no SRQ is specified. */ |
696 | if (!init_attr->srq) { | 685 | if (!init_attr->srq) { |
697 | if (init_attr->cap.max_recv_sge > rdi->dparms.props.max_sge || | 686 | if (init_attr->cap.max_recv_sge > rdi->dparms.props.max_sge || |
@@ -719,14 +708,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
719 | sz = sizeof(struct rvt_sge) * | 708 | sz = sizeof(struct rvt_sge) * |
720 | init_attr->cap.max_send_sge + | 709 | init_attr->cap.max_send_sge + |
721 | sizeof(struct rvt_swqe); | 710 | sizeof(struct rvt_swqe); |
722 | if (gfp == GFP_NOIO) | 711 | swq = vzalloc_node(sqsize * sz, rdi->dparms.node); |
723 | swq = __vmalloc( | ||
724 | sqsize * sz, | ||
725 | gfp | __GFP_ZERO, PAGE_KERNEL); | ||
726 | else | ||
727 | swq = vzalloc_node( | ||
728 | sqsize * sz, | ||
729 | rdi->dparms.node); | ||
730 | if (!swq) | 712 | if (!swq) |
731 | return ERR_PTR(-ENOMEM); | 713 | return ERR_PTR(-ENOMEM); |
732 | 714 | ||
@@ -741,7 +723,8 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
741 | } else if (init_attr->cap.max_recv_sge > 1) | 723 | } else if (init_attr->cap.max_recv_sge > 1) |
742 | sg_list_sz = sizeof(*qp->r_sg_list) * | 724 | sg_list_sz = sizeof(*qp->r_sg_list) * |
743 | (init_attr->cap.max_recv_sge - 1); | 725 | (init_attr->cap.max_recv_sge - 1); |
744 | qp = kzalloc_node(sz + sg_list_sz, gfp, rdi->dparms.node); | 726 | qp = kzalloc_node(sz + sg_list_sz, GFP_KERNEL, |
727 | rdi->dparms.node); | ||
745 | if (!qp) | 728 | if (!qp) |
746 | goto bail_swq; | 729 | goto bail_swq; |
747 | 730 | ||
@@ -751,7 +734,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
751 | kzalloc_node( | 734 | kzalloc_node( |
752 | sizeof(*qp->s_ack_queue) * | 735 | sizeof(*qp->s_ack_queue) * |
753 | rvt_max_atomic(rdi), | 736 | rvt_max_atomic(rdi), |
754 | gfp, | 737 | GFP_KERNEL, |
755 | rdi->dparms.node); | 738 | rdi->dparms.node); |
756 | if (!qp->s_ack_queue) | 739 | if (!qp->s_ack_queue) |
757 | goto bail_qp; | 740 | goto bail_qp; |
@@ -766,7 +749,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
766 | * Driver needs to set up it's private QP structure and do any | 749 | * Driver needs to set up it's private QP structure and do any |
767 | * initialization that is needed. | 750 | * initialization that is needed. |
768 | */ | 751 | */ |
769 | priv = rdi->driver_f.qp_priv_alloc(rdi, qp, gfp); | 752 | priv = rdi->driver_f.qp_priv_alloc(rdi, qp); |
770 | if (IS_ERR(priv)) { | 753 | if (IS_ERR(priv)) { |
771 | ret = priv; | 754 | ret = priv; |
772 | goto bail_qp; | 755 | goto bail_qp; |
@@ -786,11 +769,6 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
786 | qp->r_rq.wq = vmalloc_user( | 769 | qp->r_rq.wq = vmalloc_user( |
787 | sizeof(struct rvt_rwq) + | 770 | sizeof(struct rvt_rwq) + |
788 | qp->r_rq.size * sz); | 771 | qp->r_rq.size * sz); |
789 | else if (gfp == GFP_NOIO) | ||
790 | qp->r_rq.wq = __vmalloc( | ||
791 | sizeof(struct rvt_rwq) + | ||
792 | qp->r_rq.size * sz, | ||
793 | gfp | __GFP_ZERO, PAGE_KERNEL); | ||
794 | else | 772 | else |
795 | qp->r_rq.wq = vzalloc_node( | 773 | qp->r_rq.wq = vzalloc_node( |
796 | sizeof(struct rvt_rwq) + | 774 | sizeof(struct rvt_rwq) + |
@@ -824,7 +802,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
824 | 802 | ||
825 | err = alloc_qpn(rdi, &rdi->qp_dev->qpn_table, | 803 | err = alloc_qpn(rdi, &rdi->qp_dev->qpn_table, |
826 | init_attr->qp_type, | 804 | init_attr->qp_type, |
827 | init_attr->port_num, gfp); | 805 | init_attr->port_num); |
828 | if (err < 0) { | 806 | if (err < 0) { |
829 | ret = ERR_PTR(err); | 807 | ret = ERR_PTR(err); |
830 | goto bail_rq_wq; | 808 | goto bail_rq_wq; |
diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index c3a140ed4df2..08f3f90d2912 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c | |||
@@ -441,6 +441,8 @@ static void rxe_skb_tx_dtor(struct sk_buff *skb) | |||
441 | if (unlikely(qp->need_req_skb && | 441 | if (unlikely(qp->need_req_skb && |
442 | skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) | 442 | skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) |
443 | rxe_run_task(&qp->req.task, 1); | 443 | rxe_run_task(&qp->req.task, 1); |
444 | |||
445 | rxe_drop_ref(qp); | ||
444 | } | 446 | } |
445 | 447 | ||
446 | int rxe_send(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, struct sk_buff *skb) | 448 | int rxe_send(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, struct sk_buff *skb) |
@@ -473,6 +475,7 @@ int rxe_send(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, struct sk_buff *skb) | |||
473 | return -EAGAIN; | 475 | return -EAGAIN; |
474 | } | 476 | } |
475 | 477 | ||
478 | rxe_add_ref(pkt->qp); | ||
476 | atomic_inc(&pkt->qp->skb_out); | 479 | atomic_inc(&pkt->qp->skb_out); |
477 | kfree_skb(skb); | 480 | kfree_skb(skb); |
478 | 481 | ||
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 073e66783f1d..07511718d98d 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c | |||
@@ -1240,6 +1240,8 @@ int rxe_register_device(struct rxe_dev *rxe) | |||
1240 | addrconf_addr_eui48((unsigned char *)&dev->node_guid, | 1240 | addrconf_addr_eui48((unsigned char *)&dev->node_guid, |
1241 | rxe->ndev->dev_addr); | 1241 | rxe->ndev->dev_addr); |
1242 | dev->dev.dma_ops = &dma_virt_ops; | 1242 | dev->dev.dma_ops = &dma_virt_ops; |
1243 | dma_coerce_mask_and_coherent(&dev->dev, | ||
1244 | dma_get_required_mask(dev->dev.parent)); | ||
1243 | 1245 | ||
1244 | dev->uverbs_abi_ver = RXE_UVERBS_ABI_VERSION; | 1246 | dev->uverbs_abi_ver = RXE_UVERBS_ABI_VERSION; |
1245 | dev->uverbs_cmd_mask = BIT_ULL(IB_USER_VERBS_CMD_GET_CONTEXT) | 1247 | dev->uverbs_cmd_mask = BIT_ULL(IB_USER_VERBS_CMD_GET_CONTEXT) |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 7cbcfdac6529..f87d104837dc 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/vmalloc.h> | 39 | #include <linux/vmalloc.h> |
40 | #include <linux/moduleparam.h> | 40 | #include <linux/moduleparam.h> |
41 | #include <linux/sched/signal.h> | 41 | #include <linux/sched/signal.h> |
42 | #include <linux/sched/mm.h> | ||
42 | 43 | ||
43 | #include "ipoib.h" | 44 | #include "ipoib.h" |
44 | 45 | ||
@@ -954,7 +955,7 @@ void ipoib_cm_dev_stop(struct net_device *dev) | |||
954 | break; | 955 | break; |
955 | } | 956 | } |
956 | spin_unlock_irq(&priv->lock); | 957 | spin_unlock_irq(&priv->lock); |
957 | msleep(1); | 958 | usleep_range(1000, 2000); |
958 | ipoib_drain_cq(dev); | 959 | ipoib_drain_cq(dev); |
959 | spin_lock_irq(&priv->lock); | 960 | spin_lock_irq(&priv->lock); |
960 | } | 961 | } |
@@ -1047,9 +1048,8 @@ static struct ib_qp *ipoib_cm_create_tx_qp(struct net_device *dev, struct ipoib_ | |||
1047 | .sq_sig_type = IB_SIGNAL_ALL_WR, | 1048 | .sq_sig_type = IB_SIGNAL_ALL_WR, |
1048 | .qp_type = IB_QPT_RC, | 1049 | .qp_type = IB_QPT_RC, |
1049 | .qp_context = tx, | 1050 | .qp_context = tx, |
1050 | .create_flags = IB_QP_CREATE_USE_GFP_NOIO | 1051 | .create_flags = 0 |
1051 | }; | 1052 | }; |
1052 | |||
1053 | struct ib_qp *tx_qp; | 1053 | struct ib_qp *tx_qp; |
1054 | 1054 | ||
1055 | if (dev->features & NETIF_F_SG) | 1055 | if (dev->features & NETIF_F_SG) |
@@ -1057,10 +1057,6 @@ static struct ib_qp *ipoib_cm_create_tx_qp(struct net_device *dev, struct ipoib_ | |||
1057 | min_t(u32, priv->ca->attrs.max_sge, MAX_SKB_FRAGS + 1); | 1057 | min_t(u32, priv->ca->attrs.max_sge, MAX_SKB_FRAGS + 1); |
1058 | 1058 | ||
1059 | tx_qp = ib_create_qp(priv->pd, &attr); | 1059 | tx_qp = ib_create_qp(priv->pd, &attr); |
1060 | if (PTR_ERR(tx_qp) == -EINVAL) { | ||
1061 | attr.create_flags &= ~IB_QP_CREATE_USE_GFP_NOIO; | ||
1062 | tx_qp = ib_create_qp(priv->pd, &attr); | ||
1063 | } | ||
1064 | tx->max_send_sge = attr.cap.max_send_sge; | 1060 | tx->max_send_sge = attr.cap.max_send_sge; |
1065 | return tx_qp; | 1061 | return tx_qp; |
1066 | } | 1062 | } |
@@ -1131,10 +1127,11 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, | |||
1131 | struct sa_path_rec *pathrec) | 1127 | struct sa_path_rec *pathrec) |
1132 | { | 1128 | { |
1133 | struct ipoib_dev_priv *priv = ipoib_priv(p->dev); | 1129 | struct ipoib_dev_priv *priv = ipoib_priv(p->dev); |
1130 | unsigned int noio_flag; | ||
1134 | int ret; | 1131 | int ret; |
1135 | 1132 | ||
1136 | p->tx_ring = __vmalloc(ipoib_sendq_size * sizeof *p->tx_ring, | 1133 | noio_flag = memalloc_noio_save(); |
1137 | GFP_NOIO, PAGE_KERNEL); | 1134 | p->tx_ring = vzalloc(ipoib_sendq_size * sizeof(*p->tx_ring)); |
1138 | if (!p->tx_ring) { | 1135 | if (!p->tx_ring) { |
1139 | ret = -ENOMEM; | 1136 | ret = -ENOMEM; |
1140 | goto err_tx; | 1137 | goto err_tx; |
@@ -1142,9 +1139,10 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, | |||
1142 | memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring); | 1139 | memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring); |
1143 | 1140 | ||
1144 | p->qp = ipoib_cm_create_tx_qp(p->dev, p); | 1141 | p->qp = ipoib_cm_create_tx_qp(p->dev, p); |
1142 | memalloc_noio_restore(noio_flag); | ||
1145 | if (IS_ERR(p->qp)) { | 1143 | if (IS_ERR(p->qp)) { |
1146 | ret = PTR_ERR(p->qp); | 1144 | ret = PTR_ERR(p->qp); |
1147 | ipoib_warn(priv, "failed to allocate tx qp: %d\n", ret); | 1145 | ipoib_warn(priv, "failed to create tx qp: %d\n", ret); |
1148 | goto err_qp; | 1146 | goto err_qp; |
1149 | } | 1147 | } |
1150 | 1148 | ||
@@ -1206,7 +1204,7 @@ static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p) | |||
1206 | goto timeout; | 1204 | goto timeout; |
1207 | } | 1205 | } |
1208 | 1206 | ||
1209 | msleep(1); | 1207 | usleep_range(1000, 2000); |
1210 | } | 1208 | } |
1211 | } | 1209 | } |
1212 | 1210 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index efe7402f4885..57a9655e844d 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -770,7 +770,7 @@ int ipoib_ib_dev_stop_default(struct net_device *dev) | |||
770 | 770 | ||
771 | ipoib_drain_cq(dev); | 771 | ipoib_drain_cq(dev); |
772 | 772 | ||
773 | msleep(1); | 773 | usleep_range(1000, 2000); |
774 | } | 774 | } |
775 | 775 | ||
776 | ipoib_dbg(priv, "All sends and receives done.\n"); | 776 | ipoib_dbg(priv, "All sends and receives done.\n"); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 6e86eeee370e..70dacaf9044e 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -233,6 +233,7 @@ static netdev_features_t ipoib_fix_features(struct net_device *dev, netdev_featu | |||
233 | static int ipoib_change_mtu(struct net_device *dev, int new_mtu) | 233 | static int ipoib_change_mtu(struct net_device *dev, int new_mtu) |
234 | { | 234 | { |
235 | struct ipoib_dev_priv *priv = ipoib_priv(dev); | 235 | struct ipoib_dev_priv *priv = ipoib_priv(dev); |
236 | int ret = 0; | ||
236 | 237 | ||
237 | /* dev->mtu > 2K ==> connected mode */ | 238 | /* dev->mtu > 2K ==> connected mode */ |
238 | if (ipoib_cm_admin_enabled(dev)) { | 239 | if (ipoib_cm_admin_enabled(dev)) { |
@@ -256,9 +257,34 @@ static int ipoib_change_mtu(struct net_device *dev, int new_mtu) | |||
256 | ipoib_dbg(priv, "MTU must be smaller than the underlying " | 257 | ipoib_dbg(priv, "MTU must be smaller than the underlying " |
257 | "link layer MTU - 4 (%u)\n", priv->mcast_mtu); | 258 | "link layer MTU - 4 (%u)\n", priv->mcast_mtu); |
258 | 259 | ||
259 | dev->mtu = min(priv->mcast_mtu, priv->admin_mtu); | 260 | new_mtu = min(priv->mcast_mtu, priv->admin_mtu); |
260 | 261 | ||
261 | return 0; | 262 | if (priv->rn_ops->ndo_change_mtu) { |
263 | bool carrier_status = netif_carrier_ok(dev); | ||
264 | |||
265 | netif_carrier_off(dev); | ||
266 | |||
267 | /* notify lower level on the real mtu */ | ||
268 | ret = priv->rn_ops->ndo_change_mtu(dev, new_mtu); | ||
269 | |||
270 | if (carrier_status) | ||
271 | netif_carrier_on(dev); | ||
272 | } else { | ||
273 | dev->mtu = new_mtu; | ||
274 | } | ||
275 | |||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | static void ipoib_get_stats(struct net_device *dev, | ||
280 | struct rtnl_link_stats64 *stats) | ||
281 | { | ||
282 | struct ipoib_dev_priv *priv = ipoib_priv(dev); | ||
283 | |||
284 | if (priv->rn_ops->ndo_get_stats64) | ||
285 | priv->rn_ops->ndo_get_stats64(dev, stats); | ||
286 | else | ||
287 | netdev_stats_to_stats64(stats, &dev->stats); | ||
262 | } | 288 | } |
263 | 289 | ||
264 | /* Called with an RCU read lock taken */ | 290 | /* Called with an RCU read lock taken */ |
@@ -1808,6 +1834,7 @@ static const struct net_device_ops ipoib_netdev_ops_pf = { | |||
1808 | .ndo_get_vf_stats = ipoib_get_vf_stats, | 1834 | .ndo_get_vf_stats = ipoib_get_vf_stats, |
1809 | .ndo_set_vf_guid = ipoib_set_vf_guid, | 1835 | .ndo_set_vf_guid = ipoib_set_vf_guid, |
1810 | .ndo_set_mac_address = ipoib_set_mac, | 1836 | .ndo_set_mac_address = ipoib_set_mac, |
1837 | .ndo_get_stats64 = ipoib_get_stats, | ||
1811 | }; | 1838 | }; |
1812 | 1839 | ||
1813 | static const struct net_device_ops ipoib_netdev_ops_vf = { | 1840 | static const struct net_device_ops ipoib_netdev_ops_vf = { |
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 5a887efb4bdf..37b33d708c2d 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c | |||
@@ -83,6 +83,7 @@ static struct scsi_host_template iscsi_iser_sht; | |||
83 | static struct iscsi_transport iscsi_iser_transport; | 83 | static struct iscsi_transport iscsi_iser_transport; |
84 | static struct scsi_transport_template *iscsi_iser_scsi_transport; | 84 | static struct scsi_transport_template *iscsi_iser_scsi_transport; |
85 | static struct workqueue_struct *release_wq; | 85 | static struct workqueue_struct *release_wq; |
86 | static DEFINE_MUTEX(unbind_iser_conn_mutex); | ||
86 | struct iser_global ig; | 87 | struct iser_global ig; |
87 | 88 | ||
88 | int iser_debug_level = 0; | 89 | int iser_debug_level = 0; |
@@ -550,12 +551,14 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) | |||
550 | */ | 551 | */ |
551 | if (iser_conn) { | 552 | if (iser_conn) { |
552 | mutex_lock(&iser_conn->state_mutex); | 553 | mutex_lock(&iser_conn->state_mutex); |
554 | mutex_lock(&unbind_iser_conn_mutex); | ||
553 | iser_conn_terminate(iser_conn); | 555 | iser_conn_terminate(iser_conn); |
554 | iscsi_conn_stop(cls_conn, flag); | 556 | iscsi_conn_stop(cls_conn, flag); |
555 | 557 | ||
556 | /* unbind */ | 558 | /* unbind */ |
557 | iser_conn->iscsi_conn = NULL; | 559 | iser_conn->iscsi_conn = NULL; |
558 | conn->dd_data = NULL; | 560 | conn->dd_data = NULL; |
561 | mutex_unlock(&unbind_iser_conn_mutex); | ||
559 | 562 | ||
560 | complete(&iser_conn->stop_completion); | 563 | complete(&iser_conn->stop_completion); |
561 | mutex_unlock(&iser_conn->state_mutex); | 564 | mutex_unlock(&iser_conn->state_mutex); |
@@ -977,13 +980,21 @@ static int iscsi_iser_slave_alloc(struct scsi_device *sdev) | |||
977 | struct iser_conn *iser_conn; | 980 | struct iser_conn *iser_conn; |
978 | struct ib_device *ib_dev; | 981 | struct ib_device *ib_dev; |
979 | 982 | ||
983 | mutex_lock(&unbind_iser_conn_mutex); | ||
984 | |||
980 | session = starget_to_session(scsi_target(sdev))->dd_data; | 985 | session = starget_to_session(scsi_target(sdev))->dd_data; |
981 | iser_conn = session->leadconn->dd_data; | 986 | iser_conn = session->leadconn->dd_data; |
987 | if (!iser_conn) { | ||
988 | mutex_unlock(&unbind_iser_conn_mutex); | ||
989 | return -ENOTCONN; | ||
990 | } | ||
982 | ib_dev = iser_conn->ib_conn.device->ib_device; | 991 | ib_dev = iser_conn->ib_conn.device->ib_device; |
983 | 992 | ||
984 | if (!(ib_dev->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG)) | 993 | if (!(ib_dev->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG)) |
985 | blk_queue_virt_boundary(sdev->request_queue, ~MASK_4K); | 994 | blk_queue_virt_boundary(sdev->request_queue, ~MASK_4K); |
986 | 995 | ||
996 | mutex_unlock(&unbind_iser_conn_mutex); | ||
997 | |||
987 | return 0; | 998 | return 0; |
988 | } | 999 | } |
989 | 1000 | ||
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index c538a38c91ce..26a004e97ae0 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -708,8 +708,14 @@ iser_calc_scsi_params(struct iser_conn *iser_conn, | |||
708 | unsigned short sg_tablesize, sup_sg_tablesize; | 708 | unsigned short sg_tablesize, sup_sg_tablesize; |
709 | 709 | ||
710 | sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K); | 710 | sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K); |
711 | sup_sg_tablesize = min_t(unsigned, ISCSI_ISER_MAX_SG_TABLESIZE, | 711 | if (device->ib_device->attrs.device_cap_flags & |
712 | device->ib_device->attrs.max_fast_reg_page_list_len); | 712 | IB_DEVICE_MEM_MGT_EXTENSIONS) |
713 | sup_sg_tablesize = | ||
714 | min_t( | ||
715 | uint, ISCSI_ISER_MAX_SG_TABLESIZE, | ||
716 | device->ib_device->attrs.max_fast_reg_page_list_len); | ||
717 | else | ||
718 | sup_sg_tablesize = ISCSI_ISER_MAX_SG_TABLESIZE; | ||
713 | 719 | ||
714 | iser_conn->scsi_sg_tablesize = min(sg_tablesize, sup_sg_tablesize); | 720 | iser_conn->scsi_sg_tablesize = min(sg_tablesize, sup_sg_tablesize); |
715 | } | 721 | } |
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index f4eace5ea184..40f3cd7eab0f 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -156,7 +156,8 @@ static int read_sb_page(struct mddev *mddev, loff_t offset, | |||
156 | 156 | ||
157 | rdev_for_each(rdev, mddev) { | 157 | rdev_for_each(rdev, mddev) { |
158 | if (! test_bit(In_sync, &rdev->flags) | 158 | if (! test_bit(In_sync, &rdev->flags) |
159 | || test_bit(Faulty, &rdev->flags)) | 159 | || test_bit(Faulty, &rdev->flags) |
160 | || test_bit(Bitmap_sync, &rdev->flags)) | ||
160 | continue; | 161 | continue; |
161 | 162 | ||
162 | target = offset + index * (PAGE_SIZE/512); | 163 | target = offset + index * (PAGE_SIZE/512); |
diff --git a/drivers/md/md.h b/drivers/md/md.h index 991f0fe2dcc6..b50eb4ac1b82 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -134,7 +134,9 @@ enum flag_bits { | |||
134 | Faulty, /* device is known to have a fault */ | 134 | Faulty, /* device is known to have a fault */ |
135 | In_sync, /* device is in_sync with rest of array */ | 135 | In_sync, /* device is in_sync with rest of array */ |
136 | Bitmap_sync, /* ..actually, not quite In_sync. Need a | 136 | Bitmap_sync, /* ..actually, not quite In_sync. Need a |
137 | * bitmap-based recovery to get fully in sync | 137 | * bitmap-based recovery to get fully in sync. |
138 | * The bit is only meaningful before device | ||
139 | * has been passed to pers->hot_add_disk. | ||
138 | */ | 140 | */ |
139 | WriteMostly, /* Avoid reading if at all possible */ | 141 | WriteMostly, /* Avoid reading if at all possible */ |
140 | AutoDetected, /* added by auto-detect */ | 142 | AutoDetected, /* added by auto-detect */ |
diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c index 77cce3573aa8..44ad5baf3206 100644 --- a/drivers/md/raid5-ppl.c +++ b/drivers/md/raid5-ppl.c | |||
@@ -1150,7 +1150,7 @@ int ppl_init_log(struct r5conf *conf) | |||
1150 | goto err; | 1150 | goto err; |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | ppl_conf->bs = bioset_create(conf->raid_disks, 0, 0); | 1153 | ppl_conf->bs = bioset_create(conf->raid_disks, 0, BIOSET_NEED_BVECS); |
1154 | if (!ppl_conf->bs) { | 1154 | if (!ppl_conf->bs) { |
1155 | ret = -ENOMEM; | 1155 | ret = -ENOMEM; |
1156 | goto err; | 1156 | goto err; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 2ceb338b094b..aeeb8d6854e2 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -7951,12 +7951,10 @@ static void end_reshape(struct r5conf *conf) | |||
7951 | { | 7951 | { |
7952 | 7952 | ||
7953 | if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { | 7953 | if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { |
7954 | struct md_rdev *rdev; | ||
7955 | 7954 | ||
7956 | spin_lock_irq(&conf->device_lock); | 7955 | spin_lock_irq(&conf->device_lock); |
7957 | conf->previous_raid_disks = conf->raid_disks; | 7956 | conf->previous_raid_disks = conf->raid_disks; |
7958 | rdev_for_each(rdev, conf->mddev) | 7957 | md_finish_reshape(conf->mddev); |
7959 | rdev->data_offset = rdev->new_data_offset; | ||
7960 | smp_wmb(); | 7958 | smp_wmb(); |
7961 | conf->reshape_progress = MaxSector; | 7959 | conf->reshape_progress = MaxSector; |
7962 | conf->mddev->reshape_position = MaxSector; | 7960 | conf->mddev->reshape_position = MaxSector; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c index 249a4584401a..d94b3744a5b9 100644 --- a/drivers/net/ethernet/mellanox/mlx4/alloc.c +++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c | |||
@@ -578,7 +578,7 @@ out: | |||
578 | } | 578 | } |
579 | 579 | ||
580 | static int mlx4_buf_direct_alloc(struct mlx4_dev *dev, int size, | 580 | static int mlx4_buf_direct_alloc(struct mlx4_dev *dev, int size, |
581 | struct mlx4_buf *buf, gfp_t gfp) | 581 | struct mlx4_buf *buf) |
582 | { | 582 | { |
583 | dma_addr_t t; | 583 | dma_addr_t t; |
584 | 584 | ||
@@ -587,7 +587,7 @@ static int mlx4_buf_direct_alloc(struct mlx4_dev *dev, int size, | |||
587 | buf->page_shift = get_order(size) + PAGE_SHIFT; | 587 | buf->page_shift = get_order(size) + PAGE_SHIFT; |
588 | buf->direct.buf = | 588 | buf->direct.buf = |
589 | dma_zalloc_coherent(&dev->persist->pdev->dev, | 589 | dma_zalloc_coherent(&dev->persist->pdev->dev, |
590 | size, &t, gfp); | 590 | size, &t, GFP_KERNEL); |
591 | if (!buf->direct.buf) | 591 | if (!buf->direct.buf) |
592 | return -ENOMEM; | 592 | return -ENOMEM; |
593 | 593 | ||
@@ -607,10 +607,10 @@ static int mlx4_buf_direct_alloc(struct mlx4_dev *dev, int size, | |||
607 | * multiple pages, so we don't require too much contiguous memory. | 607 | * multiple pages, so we don't require too much contiguous memory. |
608 | */ | 608 | */ |
609 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, | 609 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, |
610 | struct mlx4_buf *buf, gfp_t gfp) | 610 | struct mlx4_buf *buf) |
611 | { | 611 | { |
612 | if (size <= max_direct) { | 612 | if (size <= max_direct) { |
613 | return mlx4_buf_direct_alloc(dev, size, buf, gfp); | 613 | return mlx4_buf_direct_alloc(dev, size, buf); |
614 | } else { | 614 | } else { |
615 | dma_addr_t t; | 615 | dma_addr_t t; |
616 | int i; | 616 | int i; |
@@ -620,14 +620,14 @@ int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, | |||
620 | buf->npages = buf->nbufs; | 620 | buf->npages = buf->nbufs; |
621 | buf->page_shift = PAGE_SHIFT; | 621 | buf->page_shift = PAGE_SHIFT; |
622 | buf->page_list = kcalloc(buf->nbufs, sizeof(*buf->page_list), | 622 | buf->page_list = kcalloc(buf->nbufs, sizeof(*buf->page_list), |
623 | gfp); | 623 | GFP_KERNEL); |
624 | if (!buf->page_list) | 624 | if (!buf->page_list) |
625 | return -ENOMEM; | 625 | return -ENOMEM; |
626 | 626 | ||
627 | for (i = 0; i < buf->nbufs; ++i) { | 627 | for (i = 0; i < buf->nbufs; ++i) { |
628 | buf->page_list[i].buf = | 628 | buf->page_list[i].buf = |
629 | dma_zalloc_coherent(&dev->persist->pdev->dev, | 629 | dma_zalloc_coherent(&dev->persist->pdev->dev, |
630 | PAGE_SIZE, &t, gfp); | 630 | PAGE_SIZE, &t, GFP_KERNEL); |
631 | if (!buf->page_list[i].buf) | 631 | if (!buf->page_list[i].buf) |
632 | goto err_free; | 632 | goto err_free; |
633 | 633 | ||
@@ -663,12 +663,11 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf) | |||
663 | } | 663 | } |
664 | EXPORT_SYMBOL_GPL(mlx4_buf_free); | 664 | EXPORT_SYMBOL_GPL(mlx4_buf_free); |
665 | 665 | ||
666 | static struct mlx4_db_pgdir *mlx4_alloc_db_pgdir(struct device *dma_device, | 666 | static struct mlx4_db_pgdir *mlx4_alloc_db_pgdir(struct device *dma_device) |
667 | gfp_t gfp) | ||
668 | { | 667 | { |
669 | struct mlx4_db_pgdir *pgdir; | 668 | struct mlx4_db_pgdir *pgdir; |
670 | 669 | ||
671 | pgdir = kzalloc(sizeof *pgdir, gfp); | 670 | pgdir = kzalloc(sizeof(*pgdir), GFP_KERNEL); |
672 | if (!pgdir) | 671 | if (!pgdir) |
673 | return NULL; | 672 | return NULL; |
674 | 673 | ||
@@ -676,7 +675,7 @@ static struct mlx4_db_pgdir *mlx4_alloc_db_pgdir(struct device *dma_device, | |||
676 | pgdir->bits[0] = pgdir->order0; | 675 | pgdir->bits[0] = pgdir->order0; |
677 | pgdir->bits[1] = pgdir->order1; | 676 | pgdir->bits[1] = pgdir->order1; |
678 | pgdir->db_page = dma_alloc_coherent(dma_device, PAGE_SIZE, | 677 | pgdir->db_page = dma_alloc_coherent(dma_device, PAGE_SIZE, |
679 | &pgdir->db_dma, gfp); | 678 | &pgdir->db_dma, GFP_KERNEL); |
680 | if (!pgdir->db_page) { | 679 | if (!pgdir->db_page) { |
681 | kfree(pgdir); | 680 | kfree(pgdir); |
682 | return NULL; | 681 | return NULL; |
@@ -716,7 +715,7 @@ found: | |||
716 | return 0; | 715 | return 0; |
717 | } | 716 | } |
718 | 717 | ||
719 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order, gfp_t gfp) | 718 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order) |
720 | { | 719 | { |
721 | struct mlx4_priv *priv = mlx4_priv(dev); | 720 | struct mlx4_priv *priv = mlx4_priv(dev); |
722 | struct mlx4_db_pgdir *pgdir; | 721 | struct mlx4_db_pgdir *pgdir; |
@@ -728,7 +727,7 @@ int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order, gfp_t gfp | |||
728 | if (!mlx4_alloc_db_from_pgdir(pgdir, db, order)) | 727 | if (!mlx4_alloc_db_from_pgdir(pgdir, db, order)) |
729 | goto out; | 728 | goto out; |
730 | 729 | ||
731 | pgdir = mlx4_alloc_db_pgdir(&dev->persist->pdev->dev, gfp); | 730 | pgdir = mlx4_alloc_db_pgdir(&dev->persist->pdev->dev); |
732 | if (!pgdir) { | 731 | if (!pgdir) { |
733 | ret = -ENOMEM; | 732 | ret = -ENOMEM; |
734 | goto out; | 733 | goto out; |
@@ -780,13 +779,13 @@ int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | |||
780 | { | 779 | { |
781 | int err; | 780 | int err; |
782 | 781 | ||
783 | err = mlx4_db_alloc(dev, &wqres->db, 1, GFP_KERNEL); | 782 | err = mlx4_db_alloc(dev, &wqres->db, 1); |
784 | if (err) | 783 | if (err) |
785 | return err; | 784 | return err; |
786 | 785 | ||
787 | *wqres->db.db = 0; | 786 | *wqres->db.db = 0; |
788 | 787 | ||
789 | err = mlx4_buf_direct_alloc(dev, size, &wqres->buf, GFP_KERNEL); | 788 | err = mlx4_buf_direct_alloc(dev, size, &wqres->buf); |
790 | if (err) | 789 | if (err) |
791 | goto err_db; | 790 | goto err_db; |
792 | 791 | ||
@@ -795,7 +794,7 @@ int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | |||
795 | if (err) | 794 | if (err) |
796 | goto err_buf; | 795 | goto err_buf; |
797 | 796 | ||
798 | err = mlx4_buf_write_mtt(dev, &wqres->mtt, &wqres->buf, GFP_KERNEL); | 797 | err = mlx4_buf_write_mtt(dev, &wqres->mtt, &wqres->buf); |
799 | if (err) | 798 | if (err) |
800 | goto err_mtt; | 799 | goto err_mtt; |
801 | 800 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c index fa6d2354a0e9..c56a511b918e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/cq.c | |||
@@ -224,11 +224,11 @@ int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn) | |||
224 | if (*cqn == -1) | 224 | if (*cqn == -1) |
225 | return -ENOMEM; | 225 | return -ENOMEM; |
226 | 226 | ||
227 | err = mlx4_table_get(dev, &cq_table->table, *cqn, GFP_KERNEL); | 227 | err = mlx4_table_get(dev, &cq_table->table, *cqn); |
228 | if (err) | 228 | if (err) |
229 | goto err_out; | 229 | goto err_out; |
230 | 230 | ||
231 | err = mlx4_table_get(dev, &cq_table->cmpt_table, *cqn, GFP_KERNEL); | 231 | err = mlx4_table_get(dev, &cq_table->cmpt_table, *cqn); |
232 | if (err) | 232 | if (err) |
233 | goto err_put; | 233 | goto err_put; |
234 | return 0; | 234 | return 0; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index e5fb89505a13..436f7689a032 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c | |||
@@ -1042,7 +1042,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, | |||
1042 | if (!context) | 1042 | if (!context) |
1043 | return -ENOMEM; | 1043 | return -ENOMEM; |
1044 | 1044 | ||
1045 | err = mlx4_qp_alloc(mdev->dev, qpn, qp, GFP_KERNEL); | 1045 | err = mlx4_qp_alloc(mdev->dev, qpn, qp); |
1046 | if (err) { | 1046 | if (err) { |
1047 | en_err(priv, "Failed to allocate qp #%x\n", qpn); | 1047 | en_err(priv, "Failed to allocate qp #%x\n", qpn); |
1048 | goto out; | 1048 | goto out; |
@@ -1086,7 +1086,7 @@ int mlx4_en_create_drop_qp(struct mlx4_en_priv *priv) | |||
1086 | en_err(priv, "Failed reserving drop qpn\n"); | 1086 | en_err(priv, "Failed reserving drop qpn\n"); |
1087 | return err; | 1087 | return err; |
1088 | } | 1088 | } |
1089 | err = mlx4_qp_alloc(priv->mdev->dev, qpn, &priv->drop_qp, GFP_KERNEL); | 1089 | err = mlx4_qp_alloc(priv->mdev->dev, qpn, &priv->drop_qp); |
1090 | if (err) { | 1090 | if (err) { |
1091 | en_err(priv, "Failed allocating drop qp\n"); | 1091 | en_err(priv, "Failed allocating drop qp\n"); |
1092 | mlx4_qp_release_range(priv->mdev->dev, qpn, 1); | 1092 | mlx4_qp_release_range(priv->mdev->dev, qpn, 1); |
@@ -1158,8 +1158,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) | |||
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | /* Configure RSS indirection qp */ | 1160 | /* Configure RSS indirection qp */ |
1161 | err = mlx4_qp_alloc(mdev->dev, priv->base_qpn, rss_map->indir_qp, | 1161 | err = mlx4_qp_alloc(mdev->dev, priv->base_qpn, rss_map->indir_qp); |
1162 | GFP_KERNEL); | ||
1163 | if (err) { | 1162 | if (err) { |
1164 | en_err(priv, "Failed to allocate RSS indirection QP\n"); | 1163 | en_err(priv, "Failed to allocate RSS indirection QP\n"); |
1165 | goto rss_err; | 1164 | goto rss_err; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 4f3a9b27ce4a..73faa3d77921 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c | |||
@@ -111,7 +111,7 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, | |||
111 | goto err_hwq_res; | 111 | goto err_hwq_res; |
112 | } | 112 | } |
113 | 113 | ||
114 | err = mlx4_qp_alloc(mdev->dev, ring->qpn, &ring->sp_qp, GFP_KERNEL); | 114 | err = mlx4_qp_alloc(mdev->dev, ring->qpn, &ring->sp_qp); |
115 | if (err) { | 115 | if (err) { |
116 | en_err(priv, "Failed allocating qp %d\n", ring->qpn); | 116 | en_err(priv, "Failed allocating qp %d\n", ring->qpn); |
117 | goto err_reserve; | 117 | goto err_reserve; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c index e1f9e7cebf8f..5a7816e7c7b4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/icm.c +++ b/drivers/net/ethernet/mellanox/mlx4/icm.c | |||
@@ -251,8 +251,7 @@ int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev) | |||
251 | MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); | 251 | MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); |
252 | } | 252 | } |
253 | 253 | ||
254 | int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj, | 254 | int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj) |
255 | gfp_t gfp) | ||
256 | { | 255 | { |
257 | u32 i = (obj & (table->num_obj - 1)) / | 256 | u32 i = (obj & (table->num_obj - 1)) / |
258 | (MLX4_TABLE_CHUNK_SIZE / table->obj_size); | 257 | (MLX4_TABLE_CHUNK_SIZE / table->obj_size); |
@@ -266,7 +265,7 @@ int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj, | |||
266 | } | 265 | } |
267 | 266 | ||
268 | table->icm[i] = mlx4_alloc_icm(dev, MLX4_TABLE_CHUNK_SIZE >> PAGE_SHIFT, | 267 | table->icm[i] = mlx4_alloc_icm(dev, MLX4_TABLE_CHUNK_SIZE >> PAGE_SHIFT, |
269 | (table->lowmem ? gfp : GFP_HIGHUSER) | | 268 | (table->lowmem ? GFP_KERNEL : GFP_HIGHUSER) | |
270 | __GFP_NOWARN, table->coherent); | 269 | __GFP_NOWARN, table->coherent); |
271 | if (!table->icm[i]) { | 270 | if (!table->icm[i]) { |
272 | ret = -ENOMEM; | 271 | ret = -ENOMEM; |
@@ -363,7 +362,7 @@ int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, | |||
363 | u32 i; | 362 | u32 i; |
364 | 363 | ||
365 | for (i = start; i <= end; i += inc) { | 364 | for (i = start; i <= end; i += inc) { |
366 | err = mlx4_table_get(dev, table, i, GFP_KERNEL); | 365 | err = mlx4_table_get(dev, table, i); |
367 | if (err) | 366 | if (err) |
368 | goto fail; | 367 | goto fail; |
369 | } | 368 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.h b/drivers/net/ethernet/mellanox/mlx4/icm.h index 0c7364550150..dee67fa39107 100644 --- a/drivers/net/ethernet/mellanox/mlx4/icm.h +++ b/drivers/net/ethernet/mellanox/mlx4/icm.h | |||
@@ -71,8 +71,7 @@ struct mlx4_icm *mlx4_alloc_icm(struct mlx4_dev *dev, int npages, | |||
71 | gfp_t gfp_mask, int coherent); | 71 | gfp_t gfp_mask, int coherent); |
72 | void mlx4_free_icm(struct mlx4_dev *dev, struct mlx4_icm *icm, int coherent); | 72 | void mlx4_free_icm(struct mlx4_dev *dev, struct mlx4_icm *icm, int coherent); |
73 | 73 | ||
74 | int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj, | 74 | int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj); |
75 | gfp_t gfp); | ||
76 | void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj); | 75 | void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj); |
77 | int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, | 76 | int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, |
78 | u32 start, u32 end); | 77 | u32 start, u32 end); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h index 30616cd0140d..706d7f21ac5c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h | |||
@@ -969,7 +969,7 @@ void mlx4_cleanup_cq_table(struct mlx4_dev *dev); | |||
969 | void mlx4_cleanup_qp_table(struct mlx4_dev *dev); | 969 | void mlx4_cleanup_qp_table(struct mlx4_dev *dev); |
970 | void mlx4_cleanup_srq_table(struct mlx4_dev *dev); | 970 | void mlx4_cleanup_srq_table(struct mlx4_dev *dev); |
971 | void mlx4_cleanup_mcg_table(struct mlx4_dev *dev); | 971 | void mlx4_cleanup_mcg_table(struct mlx4_dev *dev); |
972 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp); | 972 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn); |
973 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn); | 973 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn); |
974 | int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn); | 974 | int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn); |
975 | void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn); | 975 | void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn); |
@@ -977,7 +977,7 @@ int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn); | |||
977 | void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn); | 977 | void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn); |
978 | int __mlx4_mpt_reserve(struct mlx4_dev *dev); | 978 | int __mlx4_mpt_reserve(struct mlx4_dev *dev); |
979 | void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index); | 979 | void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index); |
980 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp); | 980 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index); |
981 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index); | 981 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index); |
982 | u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order); | 982 | u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order); |
983 | void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order); | 983 | void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c index ce852ca22a96..24282cd017d3 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c | |||
@@ -479,14 +479,14 @@ static void mlx4_mpt_release(struct mlx4_dev *dev, u32 index) | |||
479 | __mlx4_mpt_release(dev, index); | 479 | __mlx4_mpt_release(dev, index); |
480 | } | 480 | } |
481 | 481 | ||
482 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp) | 482 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index) |
483 | { | 483 | { |
484 | struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table; | 484 | struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table; |
485 | 485 | ||
486 | return mlx4_table_get(dev, &mr_table->dmpt_table, index, gfp); | 486 | return mlx4_table_get(dev, &mr_table->dmpt_table, index); |
487 | } | 487 | } |
488 | 488 | ||
489 | static int mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp) | 489 | static int mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index) |
490 | { | 490 | { |
491 | u64 param = 0; | 491 | u64 param = 0; |
492 | 492 | ||
@@ -497,7 +497,7 @@ static int mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp) | |||
497 | MLX4_CMD_TIME_CLASS_A, | 497 | MLX4_CMD_TIME_CLASS_A, |
498 | MLX4_CMD_WRAPPED); | 498 | MLX4_CMD_WRAPPED); |
499 | } | 499 | } |
500 | return __mlx4_mpt_alloc_icm(dev, index, gfp); | 500 | return __mlx4_mpt_alloc_icm(dev, index); |
501 | } | 501 | } |
502 | 502 | ||
503 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index) | 503 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index) |
@@ -629,7 +629,7 @@ int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr) | |||
629 | struct mlx4_mpt_entry *mpt_entry; | 629 | struct mlx4_mpt_entry *mpt_entry; |
630 | int err; | 630 | int err; |
631 | 631 | ||
632 | err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mr->key), GFP_KERNEL); | 632 | err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mr->key)); |
633 | if (err) | 633 | if (err) |
634 | return err; | 634 | return err; |
635 | 635 | ||
@@ -787,14 +787,13 @@ int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | |||
787 | EXPORT_SYMBOL_GPL(mlx4_write_mtt); | 787 | EXPORT_SYMBOL_GPL(mlx4_write_mtt); |
788 | 788 | ||
789 | int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | 789 | int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, |
790 | struct mlx4_buf *buf, gfp_t gfp) | 790 | struct mlx4_buf *buf) |
791 | { | 791 | { |
792 | u64 *page_list; | 792 | u64 *page_list; |
793 | int err; | 793 | int err; |
794 | int i; | 794 | int i; |
795 | 795 | ||
796 | page_list = kmalloc(buf->npages * sizeof *page_list, | 796 | page_list = kcalloc(buf->npages, sizeof(*page_list), GFP_KERNEL); |
797 | gfp); | ||
798 | if (!page_list) | 797 | if (!page_list) |
799 | return -ENOMEM; | 798 | return -ENOMEM; |
800 | 799 | ||
@@ -841,7 +840,7 @@ int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw) | |||
841 | struct mlx4_mpt_entry *mpt_entry; | 840 | struct mlx4_mpt_entry *mpt_entry; |
842 | int err; | 841 | int err; |
843 | 842 | ||
844 | err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mw->key), GFP_KERNEL); | 843 | err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mw->key)); |
845 | if (err) | 844 | if (err) |
846 | return err; | 845 | return err; |
847 | 846 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c index 5a310d313e94..26747212526b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/qp.c +++ b/drivers/net/ethernet/mellanox/mlx4/qp.c | |||
@@ -301,29 +301,29 @@ void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt) | |||
301 | } | 301 | } |
302 | EXPORT_SYMBOL_GPL(mlx4_qp_release_range); | 302 | EXPORT_SYMBOL_GPL(mlx4_qp_release_range); |
303 | 303 | ||
304 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp) | 304 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn) |
305 | { | 305 | { |
306 | struct mlx4_priv *priv = mlx4_priv(dev); | 306 | struct mlx4_priv *priv = mlx4_priv(dev); |
307 | struct mlx4_qp_table *qp_table = &priv->qp_table; | 307 | struct mlx4_qp_table *qp_table = &priv->qp_table; |
308 | int err; | 308 | int err; |
309 | 309 | ||
310 | err = mlx4_table_get(dev, &qp_table->qp_table, qpn, gfp); | 310 | err = mlx4_table_get(dev, &qp_table->qp_table, qpn); |
311 | if (err) | 311 | if (err) |
312 | goto err_out; | 312 | goto err_out; |
313 | 313 | ||
314 | err = mlx4_table_get(dev, &qp_table->auxc_table, qpn, gfp); | 314 | err = mlx4_table_get(dev, &qp_table->auxc_table, qpn); |
315 | if (err) | 315 | if (err) |
316 | goto err_put_qp; | 316 | goto err_put_qp; |
317 | 317 | ||
318 | err = mlx4_table_get(dev, &qp_table->altc_table, qpn, gfp); | 318 | err = mlx4_table_get(dev, &qp_table->altc_table, qpn); |
319 | if (err) | 319 | if (err) |
320 | goto err_put_auxc; | 320 | goto err_put_auxc; |
321 | 321 | ||
322 | err = mlx4_table_get(dev, &qp_table->rdmarc_table, qpn, gfp); | 322 | err = mlx4_table_get(dev, &qp_table->rdmarc_table, qpn); |
323 | if (err) | 323 | if (err) |
324 | goto err_put_altc; | 324 | goto err_put_altc; |
325 | 325 | ||
326 | err = mlx4_table_get(dev, &qp_table->cmpt_table, qpn, gfp); | 326 | err = mlx4_table_get(dev, &qp_table->cmpt_table, qpn); |
327 | if (err) | 327 | if (err) |
328 | goto err_put_rdmarc; | 328 | goto err_put_rdmarc; |
329 | 329 | ||
@@ -345,7 +345,7 @@ err_out: | |||
345 | return err; | 345 | return err; |
346 | } | 346 | } |
347 | 347 | ||
348 | static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp) | 348 | static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn) |
349 | { | 349 | { |
350 | u64 param = 0; | 350 | u64 param = 0; |
351 | 351 | ||
@@ -355,7 +355,7 @@ static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp) | |||
355 | MLX4_CMD_ALLOC_RES, MLX4_CMD_TIME_CLASS_A, | 355 | MLX4_CMD_ALLOC_RES, MLX4_CMD_TIME_CLASS_A, |
356 | MLX4_CMD_WRAPPED); | 356 | MLX4_CMD_WRAPPED); |
357 | } | 357 | } |
358 | return __mlx4_qp_alloc_icm(dev, qpn, gfp); | 358 | return __mlx4_qp_alloc_icm(dev, qpn); |
359 | } | 359 | } |
360 | 360 | ||
361 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn) | 361 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn) |
@@ -397,7 +397,7 @@ struct mlx4_qp *mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn) | |||
397 | return qp; | 397 | return qp; |
398 | } | 398 | } |
399 | 399 | ||
400 | int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp, gfp_t gfp) | 400 | int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp) |
401 | { | 401 | { |
402 | struct mlx4_priv *priv = mlx4_priv(dev); | 402 | struct mlx4_priv *priv = mlx4_priv(dev); |
403 | struct mlx4_qp_table *qp_table = &priv->qp_table; | 403 | struct mlx4_qp_table *qp_table = &priv->qp_table; |
@@ -408,7 +408,7 @@ int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp, gfp_t gfp) | |||
408 | 408 | ||
409 | qp->qpn = qpn; | 409 | qp->qpn = qpn; |
410 | 410 | ||
411 | err = mlx4_qp_alloc_icm(dev, qpn, gfp); | 411 | err = mlx4_qp_alloc_icm(dev, qpn); |
412 | if (err) | 412 | if (err) |
413 | return err; | 413 | return err; |
414 | 414 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index 812783865205..215e21c3dc8a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | |||
@@ -1822,7 +1822,7 @@ static int qp_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, | |||
1822 | return err; | 1822 | return err; |
1823 | 1823 | ||
1824 | if (!fw_reserved(dev, qpn)) { | 1824 | if (!fw_reserved(dev, qpn)) { |
1825 | err = __mlx4_qp_alloc_icm(dev, qpn, GFP_KERNEL); | 1825 | err = __mlx4_qp_alloc_icm(dev, qpn); |
1826 | if (err) { | 1826 | if (err) { |
1827 | res_abort_move(dev, slave, RES_QP, qpn); | 1827 | res_abort_move(dev, slave, RES_QP, qpn); |
1828 | return err; | 1828 | return err; |
@@ -1909,7 +1909,7 @@ static int mpt_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, | |||
1909 | if (err) | 1909 | if (err) |
1910 | return err; | 1910 | return err; |
1911 | 1911 | ||
1912 | err = __mlx4_mpt_alloc_icm(dev, mpt->key, GFP_KERNEL); | 1912 | err = __mlx4_mpt_alloc_icm(dev, mpt->key); |
1913 | if (err) { | 1913 | if (err) { |
1914 | res_abort_move(dev, slave, RES_MPT, id); | 1914 | res_abort_move(dev, slave, RES_MPT, id); |
1915 | return err; | 1915 | return err; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c index f44d089e2ca6..bedf52126824 100644 --- a/drivers/net/ethernet/mellanox/mlx4/srq.c +++ b/drivers/net/ethernet/mellanox/mlx4/srq.c | |||
@@ -100,11 +100,11 @@ int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn) | |||
100 | if (*srqn == -1) | 100 | if (*srqn == -1) |
101 | return -ENOMEM; | 101 | return -ENOMEM; |
102 | 102 | ||
103 | err = mlx4_table_get(dev, &srq_table->table, *srqn, GFP_KERNEL); | 103 | err = mlx4_table_get(dev, &srq_table->table, *srqn); |
104 | if (err) | 104 | if (err) |
105 | goto err_out; | 105 | goto err_out; |
106 | 106 | ||
107 | err = mlx4_table_get(dev, &srq_table->cmpt_table, *srqn, GFP_KERNEL); | 107 | err = mlx4_table_get(dev, &srq_table->cmpt_table, *srqn); |
108 | if (err) | 108 | if (err) |
109 | goto err_put; | 109 | goto err_put; |
110 | return 0; | 110 | return 0; |
diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index 7cd99b1f8596..75bc08c6838c 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c | |||
@@ -421,14 +421,15 @@ static void set_badblock(struct badblocks *bb, sector_t s, int num) | |||
421 | static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len) | 421 | static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len) |
422 | { | 422 | { |
423 | const unsigned int sector_size = 512; | 423 | const unsigned int sector_size = 512; |
424 | sector_t start_sector; | 424 | sector_t start_sector, end_sector; |
425 | u64 num_sectors; | 425 | u64 num_sectors; |
426 | u32 rem; | 426 | u32 rem; |
427 | 427 | ||
428 | start_sector = div_u64(ns_offset, sector_size); | 428 | start_sector = div_u64(ns_offset, sector_size); |
429 | num_sectors = div_u64_rem(len, sector_size, &rem); | 429 | end_sector = div_u64_rem(ns_offset + len, sector_size, &rem); |
430 | if (rem) | 430 | if (rem) |
431 | num_sectors++; | 431 | end_sector++; |
432 | num_sectors = end_sector - start_sector; | ||
432 | 433 | ||
433 | if (unlikely(num_sectors > (u64)INT_MAX)) { | 434 | if (unlikely(num_sectors > (u64)INT_MAX)) { |
434 | u64 remaining = num_sectors; | 435 | u64 remaining = num_sectors; |
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 077f62e208aa..6a4367cc9caa 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c | |||
@@ -3401,9 +3401,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, | |||
3401 | if (is_write) { | 3401 | if (is_write) { |
3402 | req_flags |= SISL_REQ_FLAGS_HOST_WRITE; | 3402 | req_flags |= SISL_REQ_FLAGS_HOST_WRITE; |
3403 | 3403 | ||
3404 | rc = copy_from_user(kbuf, ubuf, ulen); | 3404 | if (copy_from_user(kbuf, ubuf, ulen)) { |
3405 | if (unlikely(rc)) | 3405 | rc = -EFAULT; |
3406 | goto out; | 3406 | goto out; |
3407 | } | ||
3407 | } | 3408 | } |
3408 | } | 3409 | } |
3409 | 3410 | ||
@@ -3431,8 +3432,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, | |||
3431 | goto out; | 3432 | goto out; |
3432 | } | 3433 | } |
3433 | 3434 | ||
3434 | if (ulen && !is_write) | 3435 | if (ulen && !is_write) { |
3435 | rc = copy_to_user(ubuf, kbuf, ulen); | 3436 | if (copy_to_user(ubuf, kbuf, ulen)) |
3437 | rc = -EFAULT; | ||
3438 | } | ||
3436 | out: | 3439 | out: |
3437 | kfree(buf); | 3440 | kfree(buf); |
3438 | dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc); | 3441 | dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc); |
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 551d103c27f1..2bfea7082e3a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | |||
@@ -1693,7 +1693,7 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba, | |||
1693 | 1693 | ||
1694 | static int parse_trans_tx_err_code_v2_hw(u32 err_msk) | 1694 | static int parse_trans_tx_err_code_v2_hw(u32 err_msk) |
1695 | { | 1695 | { |
1696 | const u8 trans_tx_err_code_prio[] = { | 1696 | static const u8 trans_tx_err_code_prio[] = { |
1697 | TRANS_TX_OPEN_FAIL_WITH_IT_NEXUS_LOSS, | 1697 | TRANS_TX_OPEN_FAIL_WITH_IT_NEXUS_LOSS, |
1698 | TRANS_TX_ERR_PHY_NOT_ENABLE, | 1698 | TRANS_TX_ERR_PHY_NOT_ENABLE, |
1699 | TRANS_TX_OPEN_CNX_ERR_WRONG_DESTINATION, | 1699 | TRANS_TX_OPEN_CNX_ERR_WRONG_DESTINATION, |
@@ -1738,7 +1738,7 @@ static int parse_trans_tx_err_code_v2_hw(u32 err_msk) | |||
1738 | 1738 | ||
1739 | static int parse_trans_rx_err_code_v2_hw(u32 err_msk) | 1739 | static int parse_trans_rx_err_code_v2_hw(u32 err_msk) |
1740 | { | 1740 | { |
1741 | const u8 trans_rx_err_code_prio[] = { | 1741 | static const u8 trans_rx_err_code_prio[] = { |
1742 | TRANS_RX_ERR_WITH_RXFRAME_CRC_ERR, | 1742 | TRANS_RX_ERR_WITH_RXFRAME_CRC_ERR, |
1743 | TRANS_RX_ERR_WITH_RXFIS_8B10B_DISP_ERR, | 1743 | TRANS_RX_ERR_WITH_RXFIS_8B10B_DISP_ERR, |
1744 | TRANS_RX_ERR_WITH_RXFRAME_HAVE_ERRPRM, | 1744 | TRANS_RX_ERR_WITH_RXFRAME_HAVE_ERRPRM, |
@@ -1784,7 +1784,7 @@ static int parse_trans_rx_err_code_v2_hw(u32 err_msk) | |||
1784 | 1784 | ||
1785 | static int parse_dma_tx_err_code_v2_hw(u32 err_msk) | 1785 | static int parse_dma_tx_err_code_v2_hw(u32 err_msk) |
1786 | { | 1786 | { |
1787 | const u8 dma_tx_err_code_prio[] = { | 1787 | static const u8 dma_tx_err_code_prio[] = { |
1788 | DMA_TX_UNEXP_XFER_ERR, | 1788 | DMA_TX_UNEXP_XFER_ERR, |
1789 | DMA_TX_UNEXP_RETRANS_ERR, | 1789 | DMA_TX_UNEXP_RETRANS_ERR, |
1790 | DMA_TX_XFER_LEN_OVERFLOW, | 1790 | DMA_TX_XFER_LEN_OVERFLOW, |
@@ -1810,7 +1810,7 @@ static int parse_dma_tx_err_code_v2_hw(u32 err_msk) | |||
1810 | 1810 | ||
1811 | static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) | 1811 | static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) |
1812 | { | 1812 | { |
1813 | const u8 sipc_rx_err_code_prio[] = { | 1813 | static const u8 sipc_rx_err_code_prio[] = { |
1814 | SIPC_RX_FIS_STATUS_ERR_BIT_VLD, | 1814 | SIPC_RX_FIS_STATUS_ERR_BIT_VLD, |
1815 | SIPC_RX_PIO_WRSETUP_STATUS_DRQ_ERR, | 1815 | SIPC_RX_PIO_WRSETUP_STATUS_DRQ_ERR, |
1816 | SIPC_RX_FIS_STATUS_BSY_BIT_ERR, | 1816 | SIPC_RX_FIS_STATUS_BSY_BIT_ERR, |
@@ -1836,7 +1836,7 @@ static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) | |||
1836 | 1836 | ||
1837 | static int parse_dma_rx_err_code_v2_hw(u32 err_msk) | 1837 | static int parse_dma_rx_err_code_v2_hw(u32 err_msk) |
1838 | { | 1838 | { |
1839 | const u8 dma_rx_err_code_prio[] = { | 1839 | static const u8 dma_rx_err_code_prio[] = { |
1840 | DMA_RX_UNKNOWN_FRM_ERR, | 1840 | DMA_RX_UNKNOWN_FRM_ERR, |
1841 | DMA_RX_DATA_LEN_OVERFLOW, | 1841 | DMA_RX_DATA_LEN_OVERFLOW, |
1842 | DMA_RX_DATA_LEN_UNDERFLOW, | 1842 | DMA_RX_DATA_LEN_UNDERFLOW, |
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 47f66e949745..ed197bc8e801 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -213,7 +213,7 @@ static void sci_task_request_build_ssp_task_iu(struct isci_request *ireq) | |||
213 | * @task_context: | 213 | * @task_context: |
214 | * | 214 | * |
215 | */ | 215 | */ |
216 | static void scu_ssp_reqeust_construct_task_context( | 216 | static void scu_ssp_request_construct_task_context( |
217 | struct isci_request *ireq, | 217 | struct isci_request *ireq, |
218 | struct scu_task_context *task_context) | 218 | struct scu_task_context *task_context) |
219 | { | 219 | { |
@@ -425,7 +425,7 @@ static void scu_ssp_io_request_construct_task_context(struct isci_request *ireq, | |||
425 | u8 prot_type = scsi_get_prot_type(scmd); | 425 | u8 prot_type = scsi_get_prot_type(scmd); |
426 | u8 prot_op = scsi_get_prot_op(scmd); | 426 | u8 prot_op = scsi_get_prot_op(scmd); |
427 | 427 | ||
428 | scu_ssp_reqeust_construct_task_context(ireq, task_context); | 428 | scu_ssp_request_construct_task_context(ireq, task_context); |
429 | 429 | ||
430 | task_context->ssp_command_iu_length = | 430 | task_context->ssp_command_iu_length = |
431 | sizeof(struct ssp_cmd_iu) / sizeof(u32); | 431 | sizeof(struct ssp_cmd_iu) / sizeof(u32); |
@@ -472,7 +472,7 @@ static void scu_ssp_task_request_construct_task_context(struct isci_request *ire | |||
472 | { | 472 | { |
473 | struct scu_task_context *task_context = ireq->tc; | 473 | struct scu_task_context *task_context = ireq->tc; |
474 | 474 | ||
475 | scu_ssp_reqeust_construct_task_context(ireq, task_context); | 475 | scu_ssp_request_construct_task_context(ireq, task_context); |
476 | 476 | ||
477 | task_context->control_frame = 1; | 477 | task_context->control_frame = 1; |
478 | task_context->priority = SCU_TASK_PRIORITY_HIGH; | 478 | task_context->priority = SCU_TASK_PRIORITY_HIGH; |
@@ -495,7 +495,7 @@ static void scu_ssp_task_request_construct_task_context(struct isci_request *ire | |||
495 | * the command buffer is complete. none Revisit task context construction to | 495 | * the command buffer is complete. none Revisit task context construction to |
496 | * determine what is common for SSP/SMP/STP task context structures. | 496 | * determine what is common for SSP/SMP/STP task context structures. |
497 | */ | 497 | */ |
498 | static void scu_sata_reqeust_construct_task_context( | 498 | static void scu_sata_request_construct_task_context( |
499 | struct isci_request *ireq, | 499 | struct isci_request *ireq, |
500 | struct scu_task_context *task_context) | 500 | struct scu_task_context *task_context) |
501 | { | 501 | { |
@@ -562,7 +562,7 @@ static void scu_stp_raw_request_construct_task_context(struct isci_request *ireq | |||
562 | { | 562 | { |
563 | struct scu_task_context *task_context = ireq->tc; | 563 | struct scu_task_context *task_context = ireq->tc; |
564 | 564 | ||
565 | scu_sata_reqeust_construct_task_context(ireq, task_context); | 565 | scu_sata_request_construct_task_context(ireq, task_context); |
566 | 566 | ||
567 | task_context->control_frame = 0; | 567 | task_context->control_frame = 0; |
568 | task_context->priority = SCU_TASK_PRIORITY_NORMAL; | 568 | task_context->priority = SCU_TASK_PRIORITY_NORMAL; |
@@ -613,7 +613,7 @@ static void sci_stp_optimized_request_construct(struct isci_request *ireq, | |||
613 | struct scu_task_context *task_context = ireq->tc; | 613 | struct scu_task_context *task_context = ireq->tc; |
614 | 614 | ||
615 | /* Build the STP task context structure */ | 615 | /* Build the STP task context structure */ |
616 | scu_sata_reqeust_construct_task_context(ireq, task_context); | 616 | scu_sata_request_construct_task_context(ireq, task_context); |
617 | 617 | ||
618 | /* Copy over the SGL elements */ | 618 | /* Copy over the SGL elements */ |
619 | sci_request_build_sgl(ireq); | 619 | sci_request_build_sgl(ireq); |
@@ -1401,7 +1401,7 @@ static enum sci_status sci_stp_request_pio_data_out_transmit_data(struct isci_re | |||
1401 | * @data_buffer: The buffer of data to be copied. | 1401 | * @data_buffer: The buffer of data to be copied. |
1402 | * @length: The length of the data transfer. | 1402 | * @length: The length of the data transfer. |
1403 | * | 1403 | * |
1404 | * Copy the data from the buffer for the length specified to the IO reqeust SGL | 1404 | * Copy the data from the buffer for the length specified to the IO request SGL |
1405 | * specified data region. enum sci_status | 1405 | * specified data region. enum sci_status |
1406 | */ | 1406 | */ |
1407 | static enum sci_status | 1407 | static enum sci_status |
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index fd501f8dbb11..8660f923ace0 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
@@ -573,7 +573,7 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
573 | event = DISC_EV_FAILED; | 573 | event = DISC_EV_FAILED; |
574 | } | 574 | } |
575 | if (error) | 575 | if (error) |
576 | fc_disc_error(disc, fp); | 576 | fc_disc_error(disc, ERR_PTR(error)); |
577 | else if (event != DISC_EV_NONE) | 577 | else if (event != DISC_EV_NONE) |
578 | fc_disc_done(disc, event); | 578 | fc_disc_done(disc, event); |
579 | fc_frame_free(fp); | 579 | fc_frame_free(fp); |
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index b58bba4604e8..7786c97e033f 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c | |||
@@ -1227,7 +1227,7 @@ static void qedf_rport_event_handler(struct fc_lport *lport, | |||
1227 | 1227 | ||
1228 | if (rdata->spp_type != FC_TYPE_FCP) { | 1228 | if (rdata->spp_type != FC_TYPE_FCP) { |
1229 | QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, | 1229 | QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, |
1230 | "Not offlading since since spp type isn't FCP\n"); | 1230 | "Not offloading since spp type isn't FCP\n"); |
1231 | break; | 1231 | break; |
1232 | } | 1232 | } |
1233 | if (!(rdata->ids.roles & FC_RPORT_ROLE_FCP_TARGET)) { | 1233 | if (!(rdata->ids.roles & FC_RPORT_ROLE_FCP_TARGET)) { |
diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h index 32632c9b2276..91d2f51c351b 100644 --- a/drivers/scsi/qedi/qedi.h +++ b/drivers/scsi/qedi/qedi.h | |||
@@ -23,11 +23,17 @@ | |||
23 | #include <linux/qed/qed_iscsi_if.h> | 23 | #include <linux/qed/qed_iscsi_if.h> |
24 | #include <linux/qed/qed_ll2_if.h> | 24 | #include <linux/qed/qed_ll2_if.h> |
25 | #include "qedi_version.h" | 25 | #include "qedi_version.h" |
26 | #include "qedi_nvm_iscsi_cfg.h" | ||
26 | 27 | ||
27 | #define QEDI_MODULE_NAME "qedi" | 28 | #define QEDI_MODULE_NAME "qedi" |
28 | 29 | ||
29 | struct qedi_endpoint; | 30 | struct qedi_endpoint; |
30 | 31 | ||
32 | #ifndef GET_FIELD2 | ||
33 | #define GET_FIELD2(value, name) \ | ||
34 | (((value) & (name ## _MASK)) >> (name ## _OFFSET)) | ||
35 | #endif | ||
36 | |||
31 | /* | 37 | /* |
32 | * PCI function probe defines | 38 | * PCI function probe defines |
33 | */ | 39 | */ |
@@ -66,6 +72,11 @@ struct qedi_endpoint; | |||
66 | #define QEDI_HW_DMA_BOUNDARY 0xfff | 72 | #define QEDI_HW_DMA_BOUNDARY 0xfff |
67 | #define QEDI_PATH_HANDLE 0xFE0000000UL | 73 | #define QEDI_PATH_HANDLE 0xFE0000000UL |
68 | 74 | ||
75 | enum qedi_nvm_tgts { | ||
76 | QEDI_NVM_TGT_PRI, | ||
77 | QEDI_NVM_TGT_SEC, | ||
78 | }; | ||
79 | |||
69 | struct qedi_uio_ctrl { | 80 | struct qedi_uio_ctrl { |
70 | /* meta data */ | 81 | /* meta data */ |
71 | u32 uio_hsi_version; | 82 | u32 uio_hsi_version; |
@@ -283,6 +294,8 @@ struct qedi_ctx { | |||
283 | void *bdq_pbl_list; | 294 | void *bdq_pbl_list; |
284 | dma_addr_t bdq_pbl_list_dma; | 295 | dma_addr_t bdq_pbl_list_dma; |
285 | u8 bdq_pbl_list_num_entries; | 296 | u8 bdq_pbl_list_num_entries; |
297 | struct nvm_iscsi_cfg *iscsi_cfg; | ||
298 | dma_addr_t nvm_buf_dma; | ||
286 | void __iomem *bdq_primary_prod; | 299 | void __iomem *bdq_primary_prod; |
287 | void __iomem *bdq_secondary_prod; | 300 | void __iomem *bdq_secondary_prod; |
288 | u16 bdq_prod_idx; | 301 | u16 bdq_prod_idx; |
@@ -337,6 +350,10 @@ struct qedi_ctx { | |||
337 | bool use_fast_sge; | 350 | bool use_fast_sge; |
338 | 351 | ||
339 | atomic_t num_offloads; | 352 | atomic_t num_offloads; |
353 | #define SYSFS_FLAG_FW_SEL_BOOT 2 | ||
354 | #define IPV6_LEN 41 | ||
355 | #define IPV4_LEN 17 | ||
356 | struct iscsi_boot_kset *boot_kset; | ||
340 | }; | 357 | }; |
341 | 358 | ||
342 | struct qedi_work { | 359 | struct qedi_work { |
diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 19254bd739d9..93d54acd4a22 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c | |||
@@ -1411,7 +1411,7 @@ static void qedi_tmf_work(struct work_struct *work) | |||
1411 | 1411 | ||
1412 | list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); | 1412 | list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); |
1413 | if (!list_work) { | 1413 | if (!list_work) { |
1414 | QEDI_ERR(&qedi->dbg_ctx, "Memory alloction failed\n"); | 1414 | QEDI_ERR(&qedi->dbg_ctx, "Memory allocation failed\n"); |
1415 | goto abort_ret; | 1415 | goto abort_ret; |
1416 | } | 1416 | } |
1417 | 1417 | ||
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 5f5a4ef2e529..2c3783684815 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/if_vlan.h> | 20 | #include <linux/if_vlan.h> |
21 | #include <linux/cpu.h> | 21 | #include <linux/cpu.h> |
22 | #include <linux/iscsi_boot_sysfs.h> | ||
22 | 23 | ||
23 | #include <scsi/scsi_cmnd.h> | 24 | #include <scsi/scsi_cmnd.h> |
24 | #include <scsi/scsi_device.h> | 25 | #include <scsi/scsi_device.h> |
@@ -1143,6 +1144,30 @@ exit_setup_int: | |||
1143 | return rc; | 1144 | return rc; |
1144 | } | 1145 | } |
1145 | 1146 | ||
1147 | static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi) | ||
1148 | { | ||
1149 | if (qedi->iscsi_cfg) | ||
1150 | dma_free_coherent(&qedi->pdev->dev, | ||
1151 | sizeof(struct nvm_iscsi_cfg), | ||
1152 | qedi->iscsi_cfg, qedi->nvm_buf_dma); | ||
1153 | } | ||
1154 | |||
1155 | static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi) | ||
1156 | { | ||
1157 | qedi->iscsi_cfg = dma_zalloc_coherent(&qedi->pdev->dev, | ||
1158 | sizeof(struct nvm_iscsi_cfg), | ||
1159 | &qedi->nvm_buf_dma, GFP_KERNEL); | ||
1160 | if (!qedi->iscsi_cfg) { | ||
1161 | QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n"); | ||
1162 | return -ENOMEM; | ||
1163 | } | ||
1164 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, | ||
1165 | "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_cfg, | ||
1166 | qedi->nvm_buf_dma); | ||
1167 | |||
1168 | return 0; | ||
1169 | } | ||
1170 | |||
1146 | static void qedi_free_bdq(struct qedi_ctx *qedi) | 1171 | static void qedi_free_bdq(struct qedi_ctx *qedi) |
1147 | { | 1172 | { |
1148 | int i; | 1173 | int i; |
@@ -1183,6 +1208,7 @@ static void qedi_free_global_queues(struct qedi_ctx *qedi) | |||
1183 | kfree(gl[i]); | 1208 | kfree(gl[i]); |
1184 | } | 1209 | } |
1185 | qedi_free_bdq(qedi); | 1210 | qedi_free_bdq(qedi); |
1211 | qedi_free_nvm_iscsi_cfg(qedi); | ||
1186 | } | 1212 | } |
1187 | 1213 | ||
1188 | static int qedi_alloc_bdq(struct qedi_ctx *qedi) | 1214 | static int qedi_alloc_bdq(struct qedi_ctx *qedi) |
@@ -1309,6 +1335,11 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi) | |||
1309 | if (rc) | 1335 | if (rc) |
1310 | goto mem_alloc_failure; | 1336 | goto mem_alloc_failure; |
1311 | 1337 | ||
1338 | /* Allocate DMA coherent buffers for NVM_ISCSI_CFG */ | ||
1339 | rc = qedi_alloc_nvm_iscsi_cfg(qedi); | ||
1340 | if (rc) | ||
1341 | goto mem_alloc_failure; | ||
1342 | |||
1312 | /* Allocate a CQ and an associated PBL for each MSI-X | 1343 | /* Allocate a CQ and an associated PBL for each MSI-X |
1313 | * vector. | 1344 | * vector. |
1314 | */ | 1345 | */ |
@@ -1671,6 +1702,387 @@ void qedi_reset_host_mtu(struct qedi_ctx *qedi, u16 mtu) | |||
1671 | qedi_ops->ll2->start(qedi->cdev, ¶ms); | 1702 | qedi_ops->ll2->start(qedi->cdev, ¶ms); |
1672 | } | 1703 | } |
1673 | 1704 | ||
1705 | /** | ||
1706 | * qedi_get_nvram_block: - Scan through the iSCSI NVRAM block (while accounting | ||
1707 | * for gaps) for the matching absolute-pf-id of the QEDI device. | ||
1708 | */ | ||
1709 | static struct nvm_iscsi_block * | ||
1710 | qedi_get_nvram_block(struct qedi_ctx *qedi) | ||
1711 | { | ||
1712 | int i; | ||
1713 | u8 pf; | ||
1714 | u32 flags; | ||
1715 | struct nvm_iscsi_block *block; | ||
1716 | |||
1717 | pf = qedi->dev_info.common.abs_pf_id; | ||
1718 | block = &qedi->iscsi_cfg->block[0]; | ||
1719 | for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) { | ||
1720 | flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >> | ||
1721 | NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET; | ||
1722 | if (flags & (NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY | | ||
1723 | NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED) && | ||
1724 | (pf == (block->id & NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK) | ||
1725 | >> NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET)) | ||
1726 | return block; | ||
1727 | } | ||
1728 | return NULL; | ||
1729 | } | ||
1730 | |||
1731 | static ssize_t qedi_show_boot_eth_info(void *data, int type, char *buf) | ||
1732 | { | ||
1733 | struct qedi_ctx *qedi = data; | ||
1734 | struct nvm_iscsi_initiator *initiator; | ||
1735 | char *str = buf; | ||
1736 | int rc = 1; | ||
1737 | u32 ipv6_en, dhcp_en, ip_len; | ||
1738 | struct nvm_iscsi_block *block; | ||
1739 | char *fmt, *ip, *sub, *gw; | ||
1740 | |||
1741 | block = qedi_get_nvram_block(qedi); | ||
1742 | if (!block) | ||
1743 | return 0; | ||
1744 | |||
1745 | initiator = &block->initiator; | ||
1746 | ipv6_en = block->generic.ctrl_flags & | ||
1747 | NVM_ISCSI_CFG_GEN_IPV6_ENABLED; | ||
1748 | dhcp_en = block->generic.ctrl_flags & | ||
1749 | NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED; | ||
1750 | /* Static IP assignments. */ | ||
1751 | fmt = ipv6_en ? "%pI6\n" : "%pI4\n"; | ||
1752 | ip = ipv6_en ? initiator->ipv6.addr.byte : initiator->ipv4.addr.byte; | ||
1753 | ip_len = ipv6_en ? IPV6_LEN : IPV4_LEN; | ||
1754 | sub = ipv6_en ? initiator->ipv6.subnet_mask.byte : | ||
1755 | initiator->ipv4.subnet_mask.byte; | ||
1756 | gw = ipv6_en ? initiator->ipv6.gateway.byte : | ||
1757 | initiator->ipv4.gateway.byte; | ||
1758 | /* DHCP IP adjustments. */ | ||
1759 | fmt = dhcp_en ? "%s\n" : fmt; | ||
1760 | if (dhcp_en) { | ||
1761 | ip = ipv6_en ? "0::0" : "0.0.0.0"; | ||
1762 | sub = ip; | ||
1763 | gw = ip; | ||
1764 | ip_len = ipv6_en ? 5 : 8; | ||
1765 | } | ||
1766 | |||
1767 | switch (type) { | ||
1768 | case ISCSI_BOOT_ETH_IP_ADDR: | ||
1769 | rc = snprintf(str, ip_len, fmt, ip); | ||
1770 | break; | ||
1771 | case ISCSI_BOOT_ETH_SUBNET_MASK: | ||
1772 | rc = snprintf(str, ip_len, fmt, sub); | ||
1773 | break; | ||
1774 | case ISCSI_BOOT_ETH_GATEWAY: | ||
1775 | rc = snprintf(str, ip_len, fmt, gw); | ||
1776 | break; | ||
1777 | case ISCSI_BOOT_ETH_FLAGS: | ||
1778 | rc = snprintf(str, 3, "%hhd\n", | ||
1779 | SYSFS_FLAG_FW_SEL_BOOT); | ||
1780 | break; | ||
1781 | case ISCSI_BOOT_ETH_INDEX: | ||
1782 | rc = snprintf(str, 3, "0\n"); | ||
1783 | break; | ||
1784 | case ISCSI_BOOT_ETH_MAC: | ||
1785 | rc = sysfs_format_mac(str, qedi->mac, ETH_ALEN); | ||
1786 | break; | ||
1787 | case ISCSI_BOOT_ETH_VLAN: | ||
1788 | rc = snprintf(str, 12, "%d\n", | ||
1789 | GET_FIELD2(initiator->generic_cont0, | ||
1790 | NVM_ISCSI_CFG_INITIATOR_VLAN)); | ||
1791 | break; | ||
1792 | case ISCSI_BOOT_ETH_ORIGIN: | ||
1793 | if (dhcp_en) | ||
1794 | rc = snprintf(str, 3, "3\n"); | ||
1795 | break; | ||
1796 | default: | ||
1797 | rc = 0; | ||
1798 | break; | ||
1799 | } | ||
1800 | |||
1801 | return rc; | ||
1802 | } | ||
1803 | |||
1804 | static umode_t qedi_eth_get_attr_visibility(void *data, int type) | ||
1805 | { | ||
1806 | int rc = 1; | ||
1807 | |||
1808 | switch (type) { | ||
1809 | case ISCSI_BOOT_ETH_FLAGS: | ||
1810 | case ISCSI_BOOT_ETH_MAC: | ||
1811 | case ISCSI_BOOT_ETH_INDEX: | ||
1812 | case ISCSI_BOOT_ETH_IP_ADDR: | ||
1813 | case ISCSI_BOOT_ETH_SUBNET_MASK: | ||
1814 | case ISCSI_BOOT_ETH_GATEWAY: | ||
1815 | case ISCSI_BOOT_ETH_ORIGIN: | ||
1816 | case ISCSI_BOOT_ETH_VLAN: | ||
1817 | rc = 0444; | ||
1818 | break; | ||
1819 | default: | ||
1820 | rc = 0; | ||
1821 | break; | ||
1822 | } | ||
1823 | return rc; | ||
1824 | } | ||
1825 | |||
1826 | static ssize_t qedi_show_boot_ini_info(void *data, int type, char *buf) | ||
1827 | { | ||
1828 | struct qedi_ctx *qedi = data; | ||
1829 | struct nvm_iscsi_initiator *initiator; | ||
1830 | char *str = buf; | ||
1831 | int rc; | ||
1832 | struct nvm_iscsi_block *block; | ||
1833 | |||
1834 | block = qedi_get_nvram_block(qedi); | ||
1835 | if (!block) | ||
1836 | return 0; | ||
1837 | |||
1838 | initiator = &block->initiator; | ||
1839 | |||
1840 | switch (type) { | ||
1841 | case ISCSI_BOOT_INI_INITIATOR_NAME: | ||
1842 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | ||
1843 | initiator->initiator_name.byte); | ||
1844 | break; | ||
1845 | default: | ||
1846 | rc = 0; | ||
1847 | break; | ||
1848 | } | ||
1849 | return rc; | ||
1850 | } | ||
1851 | |||
1852 | static umode_t qedi_ini_get_attr_visibility(void *data, int type) | ||
1853 | { | ||
1854 | int rc; | ||
1855 | |||
1856 | switch (type) { | ||
1857 | case ISCSI_BOOT_INI_INITIATOR_NAME: | ||
1858 | rc = 0444; | ||
1859 | break; | ||
1860 | default: | ||
1861 | rc = 0; | ||
1862 | break; | ||
1863 | } | ||
1864 | return rc; | ||
1865 | } | ||
1866 | |||
1867 | static ssize_t | ||
1868 | qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, | ||
1869 | char *buf, enum qedi_nvm_tgts idx) | ||
1870 | { | ||
1871 | char *str = buf; | ||
1872 | int rc = 1; | ||
1873 | u32 ctrl_flags, ipv6_en, chap_en, mchap_en, ip_len; | ||
1874 | struct nvm_iscsi_block *block; | ||
1875 | char *chap_name, *chap_secret; | ||
1876 | char *mchap_name, *mchap_secret; | ||
1877 | |||
1878 | block = qedi_get_nvram_block(qedi); | ||
1879 | if (!block) | ||
1880 | goto exit_show_tgt_info; | ||
1881 | |||
1882 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_EVT, | ||
1883 | "Port:%d, tgt_idx:%d\n", | ||
1884 | GET_FIELD2(block->id, NVM_ISCSI_CFG_BLK_MAPPED_PF_ID), idx); | ||
1885 | |||
1886 | ctrl_flags = block->target[idx].ctrl_flags & | ||
1887 | NVM_ISCSI_CFG_TARGET_ENABLED; | ||
1888 | |||
1889 | if (!ctrl_flags) { | ||
1890 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_EVT, | ||
1891 | "Target disabled\n"); | ||
1892 | goto exit_show_tgt_info; | ||
1893 | } | ||
1894 | |||
1895 | ipv6_en = block->generic.ctrl_flags & | ||
1896 | NVM_ISCSI_CFG_GEN_IPV6_ENABLED; | ||
1897 | ip_len = ipv6_en ? IPV6_LEN : IPV4_LEN; | ||
1898 | chap_en = block->generic.ctrl_flags & | ||
1899 | NVM_ISCSI_CFG_GEN_CHAP_ENABLED; | ||
1900 | chap_name = chap_en ? block->initiator.chap_name.byte : NULL; | ||
1901 | chap_secret = chap_en ? block->initiator.chap_password.byte : NULL; | ||
1902 | |||
1903 | mchap_en = block->generic.ctrl_flags & | ||
1904 | NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED; | ||
1905 | mchap_name = mchap_en ? block->target[idx].chap_name.byte : NULL; | ||
1906 | mchap_secret = mchap_en ? block->target[idx].chap_password.byte : NULL; | ||
1907 | |||
1908 | switch (type) { | ||
1909 | case ISCSI_BOOT_TGT_NAME: | ||
1910 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | ||
1911 | block->target[idx].target_name.byte); | ||
1912 | break; | ||
1913 | case ISCSI_BOOT_TGT_IP_ADDR: | ||
1914 | if (ipv6_en) | ||
1915 | rc = snprintf(str, ip_len, "%pI6\n", | ||
1916 | block->target[idx].ipv6_addr.byte); | ||
1917 | else | ||
1918 | rc = snprintf(str, ip_len, "%pI4\n", | ||
1919 | block->target[idx].ipv4_addr.byte); | ||
1920 | break; | ||
1921 | case ISCSI_BOOT_TGT_PORT: | ||
1922 | rc = snprintf(str, 12, "%d\n", | ||
1923 | GET_FIELD2(block->target[idx].generic_cont0, | ||
1924 | NVM_ISCSI_CFG_TARGET_TCP_PORT)); | ||
1925 | break; | ||
1926 | case ISCSI_BOOT_TGT_LUN: | ||
1927 | rc = snprintf(str, 22, "%.*d\n", | ||
1928 | block->target[idx].lun.value[1], | ||
1929 | block->target[idx].lun.value[0]); | ||
1930 | break; | ||
1931 | case ISCSI_BOOT_TGT_CHAP_NAME: | ||
1932 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | ||
1933 | chap_name); | ||
1934 | break; | ||
1935 | case ISCSI_BOOT_TGT_CHAP_SECRET: | ||
1936 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | ||
1937 | chap_secret); | ||
1938 | break; | ||
1939 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: | ||
1940 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | ||
1941 | mchap_name); | ||
1942 | break; | ||
1943 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: | ||
1944 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | ||
1945 | mchap_secret); | ||
1946 | break; | ||
1947 | case ISCSI_BOOT_TGT_FLAGS: | ||
1948 | rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); | ||
1949 | break; | ||
1950 | case ISCSI_BOOT_TGT_NIC_ASSOC: | ||
1951 | rc = snprintf(str, 3, "0\n"); | ||
1952 | break; | ||
1953 | default: | ||
1954 | rc = 0; | ||
1955 | break; | ||
1956 | } | ||
1957 | |||
1958 | exit_show_tgt_info: | ||
1959 | return rc; | ||
1960 | } | ||
1961 | |||
1962 | static ssize_t qedi_show_boot_tgt_pri_info(void *data, int type, char *buf) | ||
1963 | { | ||
1964 | struct qedi_ctx *qedi = data; | ||
1965 | |||
1966 | return qedi_show_boot_tgt_info(qedi, type, buf, QEDI_NVM_TGT_PRI); | ||
1967 | } | ||
1968 | |||
1969 | static ssize_t qedi_show_boot_tgt_sec_info(void *data, int type, char *buf) | ||
1970 | { | ||
1971 | struct qedi_ctx *qedi = data; | ||
1972 | |||
1973 | return qedi_show_boot_tgt_info(qedi, type, buf, QEDI_NVM_TGT_SEC); | ||
1974 | } | ||
1975 | |||
1976 | static umode_t qedi_tgt_get_attr_visibility(void *data, int type) | ||
1977 | { | ||
1978 | int rc; | ||
1979 | |||
1980 | switch (type) { | ||
1981 | case ISCSI_BOOT_TGT_NAME: | ||
1982 | case ISCSI_BOOT_TGT_IP_ADDR: | ||
1983 | case ISCSI_BOOT_TGT_PORT: | ||
1984 | case ISCSI_BOOT_TGT_LUN: | ||
1985 | case ISCSI_BOOT_TGT_CHAP_NAME: | ||
1986 | case ISCSI_BOOT_TGT_CHAP_SECRET: | ||
1987 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: | ||
1988 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: | ||
1989 | case ISCSI_BOOT_TGT_NIC_ASSOC: | ||
1990 | case ISCSI_BOOT_TGT_FLAGS: | ||
1991 | rc = 0444; | ||
1992 | break; | ||
1993 | default: | ||
1994 | rc = 0; | ||
1995 | break; | ||
1996 | } | ||
1997 | return rc; | ||
1998 | } | ||
1999 | |||
2000 | static void qedi_boot_release(void *data) | ||
2001 | { | ||
2002 | struct qedi_ctx *qedi = data; | ||
2003 | |||
2004 | scsi_host_put(qedi->shost); | ||
2005 | } | ||
2006 | |||
2007 | static int qedi_get_boot_info(struct qedi_ctx *qedi) | ||
2008 | { | ||
2009 | int ret = 1; | ||
2010 | u16 len; | ||
2011 | |||
2012 | len = sizeof(struct nvm_iscsi_cfg); | ||
2013 | |||
2014 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, | ||
2015 | "Get NVM iSCSI CFG image\n"); | ||
2016 | ret = qedi_ops->common->nvm_get_image(qedi->cdev, | ||
2017 | QED_NVM_IMAGE_ISCSI_CFG, | ||
2018 | (char *)qedi->iscsi_cfg, len); | ||
2019 | if (ret) | ||
2020 | QEDI_ERR(&qedi->dbg_ctx, | ||
2021 | "Could not get NVM image. ret = %d\n", ret); | ||
2022 | |||
2023 | return ret; | ||
2024 | } | ||
2025 | |||
2026 | static int qedi_setup_boot_info(struct qedi_ctx *qedi) | ||
2027 | { | ||
2028 | struct iscsi_boot_kobj *boot_kobj; | ||
2029 | |||
2030 | if (qedi_get_boot_info(qedi)) | ||
2031 | return -EPERM; | ||
2032 | |||
2033 | qedi->boot_kset = iscsi_boot_create_host_kset(qedi->shost->host_no); | ||
2034 | if (!qedi->boot_kset) | ||
2035 | goto kset_free; | ||
2036 | |||
2037 | if (!scsi_host_get(qedi->shost)) | ||
2038 | goto kset_free; | ||
2039 | |||
2040 | boot_kobj = iscsi_boot_create_target(qedi->boot_kset, 0, qedi, | ||
2041 | qedi_show_boot_tgt_pri_info, | ||
2042 | qedi_tgt_get_attr_visibility, | ||
2043 | qedi_boot_release); | ||
2044 | if (!boot_kobj) | ||
2045 | goto put_host; | ||
2046 | |||
2047 | if (!scsi_host_get(qedi->shost)) | ||
2048 | goto kset_free; | ||
2049 | |||
2050 | boot_kobj = iscsi_boot_create_target(qedi->boot_kset, 1, qedi, | ||
2051 | qedi_show_boot_tgt_sec_info, | ||
2052 | qedi_tgt_get_attr_visibility, | ||
2053 | qedi_boot_release); | ||
2054 | if (!boot_kobj) | ||
2055 | goto put_host; | ||
2056 | |||
2057 | if (!scsi_host_get(qedi->shost)) | ||
2058 | goto kset_free; | ||
2059 | |||
2060 | boot_kobj = iscsi_boot_create_initiator(qedi->boot_kset, 0, qedi, | ||
2061 | qedi_show_boot_ini_info, | ||
2062 | qedi_ini_get_attr_visibility, | ||
2063 | qedi_boot_release); | ||
2064 | if (!boot_kobj) | ||
2065 | goto put_host; | ||
2066 | |||
2067 | if (!scsi_host_get(qedi->shost)) | ||
2068 | goto kset_free; | ||
2069 | |||
2070 | boot_kobj = iscsi_boot_create_ethernet(qedi->boot_kset, 0, qedi, | ||
2071 | qedi_show_boot_eth_info, | ||
2072 | qedi_eth_get_attr_visibility, | ||
2073 | qedi_boot_release); | ||
2074 | if (!boot_kobj) | ||
2075 | goto put_host; | ||
2076 | |||
2077 | return 0; | ||
2078 | |||
2079 | put_host: | ||
2080 | scsi_host_put(qedi->shost); | ||
2081 | kset_free: | ||
2082 | iscsi_boot_destroy_kset(qedi->boot_kset); | ||
2083 | return -ENOMEM; | ||
2084 | } | ||
2085 | |||
1674 | static void __qedi_remove(struct pci_dev *pdev, int mode) | 2086 | static void __qedi_remove(struct pci_dev *pdev, int mode) |
1675 | { | 2087 | { |
1676 | struct qedi_ctx *qedi = pci_get_drvdata(pdev); | 2088 | struct qedi_ctx *qedi = pci_get_drvdata(pdev); |
@@ -1724,6 +2136,9 @@ static void __qedi_remove(struct pci_dev *pdev, int mode) | |||
1724 | qedi->ll2_recv_thread = NULL; | 2136 | qedi->ll2_recv_thread = NULL; |
1725 | } | 2137 | } |
1726 | qedi_ll2_free_skbs(qedi); | 2138 | qedi_ll2_free_skbs(qedi); |
2139 | |||
2140 | if (qedi->boot_kset) | ||
2141 | iscsi_boot_destroy_kset(qedi->boot_kset); | ||
1727 | } | 2142 | } |
1728 | } | 2143 | } |
1729 | 2144 | ||
@@ -1967,6 +2382,10 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) | |||
1967 | /* F/w needs 1st task context memory entry for performance */ | 2382 | /* F/w needs 1st task context memory entry for performance */ |
1968 | set_bit(QEDI_RESERVE_TASK_ID, qedi->task_idx_map); | 2383 | set_bit(QEDI_RESERVE_TASK_ID, qedi->task_idx_map); |
1969 | atomic_set(&qedi->num_offloads, 0); | 2384 | atomic_set(&qedi->num_offloads, 0); |
2385 | |||
2386 | if (qedi_setup_boot_info(qedi)) | ||
2387 | QEDI_ERR(&qedi->dbg_ctx, | ||
2388 | "No iSCSI boot target configured\n"); | ||
1970 | } | 2389 | } |
1971 | 2390 | ||
1972 | return 0; | 2391 | return 0; |
diff --git a/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h b/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h new file mode 100644 index 000000000000..df39b69b366d --- /dev/null +++ b/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h | |||
@@ -0,0 +1,210 @@ | |||
1 | /* | ||
2 | * QLogic iSCSI Offload Driver | ||
3 | * Copyright (c) 2016 Cavium Inc. | ||
4 | * | ||
5 | * This software is available under the terms of the GNU General Public License | ||
6 | * (GPL) Version 2, available from the file COPYING in the main directory of | ||
7 | * this source tree. | ||
8 | */ | ||
9 | |||
10 | #ifndef NVM_ISCSI_CFG_H | ||
11 | #define NVM_ISCSI_CFG_H | ||
12 | |||
13 | #define NUM_OF_ISCSI_TARGET_PER_PF 4 /* Defined as per the | ||
14 | * ISCSI IBFT constraint | ||
15 | */ | ||
16 | #define NUM_OF_ISCSI_PF_SUPPORTED 4 /* One PF per Port - | ||
17 | * assuming 4 port card | ||
18 | */ | ||
19 | |||
20 | #define NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN 256 | ||
21 | |||
22 | union nvm_iscsi_dhcp_vendor_id { | ||
23 | u32 value[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN / 4]; | ||
24 | u8 byte[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN]; | ||
25 | }; | ||
26 | |||
27 | #define NVM_ISCSI_IPV4_ADDR_BYTE_LEN 4 | ||
28 | union nvm_iscsi_ipv4_addr { | ||
29 | u32 addr; | ||
30 | u8 byte[NVM_ISCSI_IPV4_ADDR_BYTE_LEN]; | ||
31 | }; | ||
32 | |||
33 | #define NVM_ISCSI_IPV6_ADDR_BYTE_LEN 16 | ||
34 | union nvm_iscsi_ipv6_addr { | ||
35 | u32 addr[4]; | ||
36 | u8 byte[NVM_ISCSI_IPV6_ADDR_BYTE_LEN]; | ||
37 | }; | ||
38 | |||
39 | struct nvm_iscsi_initiator_ipv4 { | ||
40 | union nvm_iscsi_ipv4_addr addr; /* 0x0 */ | ||
41 | union nvm_iscsi_ipv4_addr subnet_mask; /* 0x4 */ | ||
42 | union nvm_iscsi_ipv4_addr gateway; /* 0x8 */ | ||
43 | union nvm_iscsi_ipv4_addr primary_dns; /* 0xC */ | ||
44 | union nvm_iscsi_ipv4_addr secondary_dns; /* 0x10 */ | ||
45 | union nvm_iscsi_ipv4_addr dhcp_addr; /* 0x14 */ | ||
46 | |||
47 | union nvm_iscsi_ipv4_addr isns_server; /* 0x18 */ | ||
48 | union nvm_iscsi_ipv4_addr slp_server; /* 0x1C */ | ||
49 | union nvm_iscsi_ipv4_addr primay_radius_server; /* 0x20 */ | ||
50 | union nvm_iscsi_ipv4_addr secondary_radius_server; /* 0x24 */ | ||
51 | |||
52 | union nvm_iscsi_ipv4_addr rsvd[4]; /* 0x28 */ | ||
53 | }; | ||
54 | |||
55 | struct nvm_iscsi_initiator_ipv6 { | ||
56 | union nvm_iscsi_ipv6_addr addr; /* 0x0 */ | ||
57 | union nvm_iscsi_ipv6_addr subnet_mask; /* 0x10 */ | ||
58 | union nvm_iscsi_ipv6_addr gateway; /* 0x20 */ | ||
59 | union nvm_iscsi_ipv6_addr primary_dns; /* 0x30 */ | ||
60 | union nvm_iscsi_ipv6_addr secondary_dns; /* 0x40 */ | ||
61 | union nvm_iscsi_ipv6_addr dhcp_addr; /* 0x50 */ | ||
62 | |||
63 | union nvm_iscsi_ipv6_addr isns_server; /* 0x60 */ | ||
64 | union nvm_iscsi_ipv6_addr slp_server; /* 0x70 */ | ||
65 | union nvm_iscsi_ipv6_addr primay_radius_server; /* 0x80 */ | ||
66 | union nvm_iscsi_ipv6_addr secondary_radius_server; /* 0x90 */ | ||
67 | |||
68 | union nvm_iscsi_ipv6_addr rsvd[3]; /* 0xA0 */ | ||
69 | |||
70 | u32 config; /* 0xD0 */ | ||
71 | #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_MASK 0x000000FF | ||
72 | #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_OFFSET 0 | ||
73 | |||
74 | u32 rsvd_1[3]; | ||
75 | }; | ||
76 | |||
77 | #define NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN 256 | ||
78 | union nvm_iscsi_name { | ||
79 | u32 value[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN / 4]; | ||
80 | u8 byte[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN]; | ||
81 | }; | ||
82 | |||
83 | #define NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN 256 | ||
84 | union nvm_iscsi_chap_name { | ||
85 | u32 value[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN / 4]; | ||
86 | u8 byte[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN]; | ||
87 | }; | ||
88 | |||
89 | #define NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN 16 /* md5 need per RFC1996 | ||
90 | * is 16 octets | ||
91 | */ | ||
92 | union nvm_iscsi_chap_password { | ||
93 | u32 value[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN / 4]; | ||
94 | u8 byte[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN]; | ||
95 | }; | ||
96 | |||
97 | union nvm_iscsi_lun { | ||
98 | u8 byte[8]; | ||
99 | u32 value[2]; | ||
100 | }; | ||
101 | |||
102 | struct nvm_iscsi_generic { | ||
103 | u32 ctrl_flags; /* 0x0 */ | ||
104 | #define NVM_ISCSI_CFG_GEN_CHAP_ENABLED BIT(0) | ||
105 | #define NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED BIT(1) | ||
106 | #define NVM_ISCSI_CFG_GEN_DHCP_ISCSI_CONFIG_ENABLED BIT(2) | ||
107 | #define NVM_ISCSI_CFG_GEN_IPV6_ENABLED BIT(3) | ||
108 | #define NVM_ISCSI_CFG_GEN_IPV4_FALLBACK_ENABLED BIT(4) | ||
109 | #define NVM_ISCSI_CFG_GEN_ISNS_WORLD_LOGIN BIT(5) | ||
110 | #define NVM_ISCSI_CFG_GEN_ISNS_SELECTIVE_LOGIN BIT(6) | ||
111 | #define NVM_ISCSI_CFG_GEN_ADDR_REDIRECT_ENABLED BIT(7) | ||
112 | #define NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED BIT(8) | ||
113 | |||
114 | u32 timeout; /* 0x4 */ | ||
115 | #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_MASK 0x0000FFFF | ||
116 | #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_OFFSET 0 | ||
117 | #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_MASK 0xFFFF0000 | ||
118 | #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_OFFSET 16 | ||
119 | |||
120 | union nvm_iscsi_dhcp_vendor_id dhcp_vendor_id; /* 0x8 */ | ||
121 | u32 rsvd[62]; /* 0x108 */ | ||
122 | }; | ||
123 | |||
124 | struct nvm_iscsi_initiator { | ||
125 | struct nvm_iscsi_initiator_ipv4 ipv4; /* 0x0 */ | ||
126 | struct nvm_iscsi_initiator_ipv6 ipv6; /* 0x38 */ | ||
127 | |||
128 | union nvm_iscsi_name initiator_name; /* 0x118 */ | ||
129 | union nvm_iscsi_chap_name chap_name; /* 0x218 */ | ||
130 | union nvm_iscsi_chap_password chap_password; /* 0x318 */ | ||
131 | |||
132 | u32 generic_cont0; /* 0x398 */ | ||
133 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_MASK 0x0000FFFF | ||
134 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_OFFSET 0 | ||
135 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_MASK 0x00030000 | ||
136 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_OFFSET 16 | ||
137 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4 1 | ||
138 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_6 2 | ||
139 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4_AND_6 3 | ||
140 | |||
141 | u32 ctrl_flags; | ||
142 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_PRIORITY_V6 BIT(0) | ||
143 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_ENABLED BIT(1) | ||
144 | |||
145 | u32 rsvd[116]; /* 0x32C */ | ||
146 | }; | ||
147 | |||
148 | struct nvm_iscsi_target { | ||
149 | u32 ctrl_flags; /* 0x0 */ | ||
150 | #define NVM_ISCSI_CFG_TARGET_ENABLED BIT(0) | ||
151 | #define NVM_ISCSI_CFG_BOOT_TIME_LOGIN_STATUS BIT(1) | ||
152 | |||
153 | u32 generic_cont0; /* 0x4 */ | ||
154 | #define NVM_ISCSI_CFG_TARGET_TCP_PORT_MASK 0x0000FFFF | ||
155 | #define NVM_ISCSI_CFG_TARGET_TCP_PORT_OFFSET 0 | ||
156 | |||
157 | u32 ip_ver; | ||
158 | #define NVM_ISCSI_CFG_IPv4 4 | ||
159 | #define NVM_ISCSI_CFG_IPv6 6 | ||
160 | |||
161 | u32 rsvd_1[7]; /* 0x24 */ | ||
162 | union nvm_iscsi_ipv4_addr ipv4_addr; /* 0x28 */ | ||
163 | union nvm_iscsi_ipv6_addr ipv6_addr; /* 0x2C */ | ||
164 | union nvm_iscsi_lun lun; /* 0x3C */ | ||
165 | |||
166 | union nvm_iscsi_name target_name; /* 0x44 */ | ||
167 | union nvm_iscsi_chap_name chap_name; /* 0x144 */ | ||
168 | union nvm_iscsi_chap_password chap_password; /* 0x244 */ | ||
169 | |||
170 | u32 rsvd_2[107]; /* 0x2C4 */ | ||
171 | }; | ||
172 | |||
173 | struct nvm_iscsi_block { | ||
174 | u32 id; /* 0x0 */ | ||
175 | #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK 0x0000000F | ||
176 | #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET 0 | ||
177 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK 0x00000FF0 | ||
178 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET 4 | ||
179 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY BIT(0) | ||
180 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED BIT(1) | ||
181 | |||
182 | u32 rsvd_1[5]; /* 0x4 */ | ||
183 | |||
184 | struct nvm_iscsi_generic generic; /* 0x18 */ | ||
185 | struct nvm_iscsi_initiator initiator; /* 0x218 */ | ||
186 | struct nvm_iscsi_target target[NUM_OF_ISCSI_TARGET_PER_PF]; | ||
187 | /* 0x718 */ | ||
188 | |||
189 | u32 rsvd_2[58]; /* 0x1718 */ | ||
190 | /* total size - 0x1800 - 6K block */ | ||
191 | }; | ||
192 | |||
193 | struct nvm_iscsi_cfg { | ||
194 | u32 id; /* 0x0 */ | ||
195 | #define NVM_ISCSI_CFG_BLK_VERSION_MINOR_MASK 0x000000FF | ||
196 | #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR_MASK 0x0000FF00 | ||
197 | #define NVM_ISCSI_CFG_BLK_SIGNATURE_MASK 0xFFFF0000 | ||
198 | #define NVM_ISCSI_CFG_BLK_SIGNATURE 0x49430000 /* IC - Iscsi | ||
199 | * Config | ||
200 | */ | ||
201 | |||
202 | #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR 0 | ||
203 | #define NVM_ISCSI_CFG_BLK_VERSION_MINOR 10 | ||
204 | #define NVM_ISCSI_CFG_BLK_VERSION ((NVM_ISCSI_CFG_BLK_VERSION_MAJOR << 8) | \ | ||
205 | NVM_ISCSI_CFG_BLK_VERSION_MINOR) | ||
206 | |||
207 | struct nvm_iscsi_block block[NUM_OF_ISCSI_PF_SUPPORTED]; /* 0x4 */ | ||
208 | }; | ||
209 | |||
210 | #endif | ||
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index c2dc836dc484..e101cd3043b9 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
@@ -3727,7 +3727,7 @@ static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha, | |||
3727 | h &= QLA_CMD_HANDLE_MASK; | 3727 | h &= QLA_CMD_HANDLE_MASK; |
3728 | 3728 | ||
3729 | if (h != QLA_TGT_NULL_HANDLE) { | 3729 | if (h != QLA_TGT_NULL_HANDLE) { |
3730 | if (unlikely(h > req->num_outstanding_cmds)) { | 3730 | if (unlikely(h >= req->num_outstanding_cmds)) { |
3731 | ql_dbg(ql_dbg_tgt, vha, 0xe052, | 3731 | ql_dbg(ql_dbg_tgt, vha, 0xe052, |
3732 | "qla_target(%d): Wrong handle %x received\n", | 3732 | "qla_target(%d): Wrong handle %x received\n", |
3733 | vha->vp_idx, handle); | 3733 | vha->vp_idx, handle); |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 21225d62b0c1..1e82d4128a84 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -758,8 +758,11 @@ static bool sg_is_valid_dxfer(sg_io_hdr_t *hp) | |||
758 | if (hp->dxferp || hp->dxfer_len > 0) | 758 | if (hp->dxferp || hp->dxfer_len > 0) |
759 | return false; | 759 | return false; |
760 | return true; | 760 | return true; |
761 | case SG_DXFER_TO_DEV: | ||
762 | case SG_DXFER_FROM_DEV: | 761 | case SG_DXFER_FROM_DEV: |
762 | if (hp->dxfer_len < 0) | ||
763 | return false; | ||
764 | return true; | ||
765 | case SG_DXFER_TO_DEV: | ||
763 | case SG_DXFER_TO_FROM_DEV: | 766 | case SG_DXFER_TO_FROM_DEV: |
764 | if (!hp->dxferp || hp->dxfer_len == 0) | 767 | if (!hp->dxferp || hp->dxfer_len == 0) |
765 | return false; | 768 | return false; |
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 8b93197daefe..9be211d68b15 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c | |||
@@ -837,6 +837,7 @@ static struct scsi_host_template virtscsi_host_template_multi = { | |||
837 | .eh_abort_handler = virtscsi_abort, | 837 | .eh_abort_handler = virtscsi_abort, |
838 | .eh_device_reset_handler = virtscsi_device_reset, | 838 | .eh_device_reset_handler = virtscsi_device_reset, |
839 | .eh_timed_out = virtscsi_eh_timed_out, | 839 | .eh_timed_out = virtscsi_eh_timed_out, |
840 | .slave_alloc = virtscsi_device_alloc, | ||
840 | 841 | ||
841 | .can_queue = 1024, | 842 | .can_queue = 1024, |
842 | .dma_boundary = UINT_MAX, | 843 | .dma_boundary = UINT_MAX, |
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index e071d23f6148..ef7240ace576 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c | |||
@@ -271,6 +271,11 @@ out: | |||
271 | if (ret < 0) | 271 | if (ret < 0) |
272 | err = ret; | 272 | err = ret; |
273 | dput(last); | 273 | dput(last); |
274 | /* last_name no longer match cache index */ | ||
275 | if (fi->readdir_cache_idx >= 0) { | ||
276 | fi->readdir_cache_idx = -1; | ||
277 | fi->dir_release_count = 0; | ||
278 | } | ||
274 | } | 279 | } |
275 | return err; | 280 | return err; |
276 | } | 281 | } |
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c index a140c5e3dc54..b4b8438c42ef 100644 --- a/fs/f2fs/acl.c +++ b/fs/f2fs/acl.c | |||
@@ -211,7 +211,7 @@ static int __f2fs_set_acl(struct inode *inode, int type, | |||
211 | switch (type) { | 211 | switch (type) { |
212 | case ACL_TYPE_ACCESS: | 212 | case ACL_TYPE_ACCESS: |
213 | name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; | 213 | name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; |
214 | if (acl) { | 214 | if (acl && !ipage) { |
215 | error = posix_acl_update_mode(inode, &inode->i_mode, &acl); | 215 | error = posix_acl_update_mode(inode, &inode->i_mode, &acl); |
216 | if (error) | 216 | if (error) |
217 | return error; | 217 | return error; |
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 56bbf592e487..5b876f6d3f6b 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -879,6 +879,7 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type) | |||
879 | struct inode *inode; | 879 | struct inode *inode; |
880 | struct f2fs_inode_info *fi; | 880 | struct f2fs_inode_info *fi; |
881 | bool is_dir = (type == DIR_INODE); | 881 | bool is_dir = (type == DIR_INODE); |
882 | unsigned long ino = 0; | ||
882 | 883 | ||
883 | trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir, | 884 | trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir, |
884 | get_pages(sbi, is_dir ? | 885 | get_pages(sbi, is_dir ? |
@@ -901,8 +902,17 @@ retry: | |||
901 | inode = igrab(&fi->vfs_inode); | 902 | inode = igrab(&fi->vfs_inode); |
902 | spin_unlock(&sbi->inode_lock[type]); | 903 | spin_unlock(&sbi->inode_lock[type]); |
903 | if (inode) { | 904 | if (inode) { |
905 | unsigned long cur_ino = inode->i_ino; | ||
906 | |||
904 | filemap_fdatawrite(inode->i_mapping); | 907 | filemap_fdatawrite(inode->i_mapping); |
905 | iput(inode); | 908 | iput(inode); |
909 | /* We need to give cpu to another writers. */ | ||
910 | if (ino == cur_ino) { | ||
911 | congestion_wait(BLK_RW_ASYNC, HZ/50); | ||
912 | cond_resched(); | ||
913 | } else { | ||
914 | ino = cur_ino; | ||
915 | } | ||
906 | } else { | 916 | } else { |
907 | /* | 917 | /* |
908 | * We should submit bio, since it exists several | 918 | * We should submit bio, since it exists several |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a0e6d2c65a9e..2706130c261b 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -1538,7 +1538,6 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg) | |||
1538 | 1538 | ||
1539 | /* Is it quota file? Do not allow user to mess with it */ | 1539 | /* Is it quota file? Do not allow user to mess with it */ |
1540 | if (IS_NOQUOTA(inode)) { | 1540 | if (IS_NOQUOTA(inode)) { |
1541 | inode_unlock(inode); | ||
1542 | ret = -EPERM; | 1541 | ret = -EPERM; |
1543 | goto unlock_out; | 1542 | goto unlock_out; |
1544 | } | 1543 | } |
@@ -1549,9 +1548,8 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg) | |||
1549 | 1548 | ||
1550 | if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) { | 1549 | if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) { |
1551 | if (!capable(CAP_LINUX_IMMUTABLE)) { | 1550 | if (!capable(CAP_LINUX_IMMUTABLE)) { |
1552 | inode_unlock(inode); | ||
1553 | ret = -EPERM; | 1551 | ret = -EPERM; |
1554 | goto out; | 1552 | goto unlock_out; |
1555 | } | 1553 | } |
1556 | } | 1554 | } |
1557 | 1555 | ||
@@ -1564,7 +1562,6 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg) | |||
1564 | f2fs_mark_inode_dirty_sync(inode, false); | 1562 | f2fs_mark_inode_dirty_sync(inode, false); |
1565 | unlock_out: | 1563 | unlock_out: |
1566 | inode_unlock(inode); | 1564 | inode_unlock(inode); |
1567 | out: | ||
1568 | mnt_drop_write_file(filp); | 1565 | mnt_drop_write_file(filp); |
1569 | return ret; | 1566 | return ret; |
1570 | } | 1567 | } |
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 9adc202fcd6f..71191d89917d 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c | |||
@@ -11,6 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | #include <linux/proc_fs.h> | 12 | #include <linux/proc_fs.h> |
13 | #include <linux/f2fs_fs.h> | 13 | #include <linux/f2fs_fs.h> |
14 | #include <linux/seq_file.h> | ||
14 | 15 | ||
15 | #include "f2fs.h" | 16 | #include "f2fs.h" |
16 | #include "segment.h" | 17 | #include "segment.h" |
diff --git a/fs/mount.h b/fs/mount.h index de45d9e76748..6790767d1883 100644 --- a/fs/mount.h +++ b/fs/mount.h | |||
@@ -16,7 +16,7 @@ struct mnt_namespace { | |||
16 | u64 event; | 16 | u64 event; |
17 | unsigned int mounts; /* # of mounts in the namespace */ | 17 | unsigned int mounts; /* # of mounts in the namespace */ |
18 | unsigned int pending_mounts; | 18 | unsigned int pending_mounts; |
19 | }; | 19 | } __randomize_layout; |
20 | 20 | ||
21 | struct mnt_pcp { | 21 | struct mnt_pcp { |
22 | int mnt_count; | 22 | int mnt_count; |
@@ -69,7 +69,7 @@ struct mount { | |||
69 | struct hlist_head mnt_pins; | 69 | struct hlist_head mnt_pins; |
70 | struct fs_pin mnt_umount; | 70 | struct fs_pin mnt_umount; |
71 | struct dentry *mnt_ex_mountpoint; | 71 | struct dentry *mnt_ex_mountpoint; |
72 | }; | 72 | } __randomize_layout; |
73 | 73 | ||
74 | #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */ | 74 | #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */ |
75 | 75 | ||
diff --git a/fs/namei.c b/fs/namei.c index 88fd38d1e3e7..ddb6a7c2b3d4 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -524,7 +524,7 @@ struct nameidata { | |||
524 | struct inode *link_inode; | 524 | struct inode *link_inode; |
525 | unsigned root_seq; | 525 | unsigned root_seq; |
526 | int dfd; | 526 | int dfd; |
527 | }; | 527 | } __randomize_layout; |
528 | 528 | ||
529 | static void set_nameidata(struct nameidata *p, int dfd, struct filename *name) | 529 | static void set_nameidata(struct nameidata *p, int dfd, struct filename *name) |
530 | { | 530 | { |
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index b45083c0f9ae..49b0a9e7ff18 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
@@ -720,8 +720,8 @@ static const struct rpc_version nfs_cb_version4 = { | |||
720 | .counts = nfs4_cb_counts, | 720 | .counts = nfs4_cb_counts, |
721 | }; | 721 | }; |
722 | 722 | ||
723 | static const struct rpc_version *nfs_cb_version[] = { | 723 | static const struct rpc_version *nfs_cb_version[2] = { |
724 | &nfs_cb_version4, | 724 | [1] = &nfs_cb_version4, |
725 | }; | 725 | }; |
726 | 726 | ||
727 | static const struct rpc_program cb_program; | 727 | static const struct rpc_program cb_program; |
@@ -795,7 +795,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c | |||
795 | .saddress = (struct sockaddr *) &conn->cb_saddr, | 795 | .saddress = (struct sockaddr *) &conn->cb_saddr, |
796 | .timeout = &timeparms, | 796 | .timeout = &timeparms, |
797 | .program = &cb_program, | 797 | .program = &cb_program, |
798 | .version = 0, | 798 | .version = 1, |
799 | .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), | 799 | .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), |
800 | }; | 800 | }; |
801 | struct rpc_clnt *client; | 801 | struct rpc_clnt *client; |
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 18694598bebf..aa2b89071630 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
@@ -51,7 +51,7 @@ struct proc_dir_entry { | |||
51 | spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */ | 51 | spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */ |
52 | u8 namelen; | 52 | u8 namelen; |
53 | char name[]; | 53 | char name[]; |
54 | }; | 54 | } __randomize_layout; |
55 | 55 | ||
56 | union proc_op { | 56 | union proc_op { |
57 | int (*proc_get_link)(struct dentry *, struct path *); | 57 | int (*proc_get_link)(struct dentry *, struct path *); |
@@ -70,7 +70,7 @@ struct proc_inode { | |||
70 | struct hlist_node sysctl_inodes; | 70 | struct hlist_node sysctl_inodes; |
71 | const struct proc_ns_operations *ns_ops; | 71 | const struct proc_ns_operations *ns_ops; |
72 | struct inode vfs_inode; | 72 | struct inode vfs_inode; |
73 | }; | 73 | } __randomize_layout; |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * General functions | 76 | * General functions |
@@ -279,7 +279,7 @@ struct proc_maps_private { | |||
279 | #ifdef CONFIG_NUMA | 279 | #ifdef CONFIG_NUMA |
280 | struct mempolicy *task_mempolicy; | 280 | struct mempolicy *task_mempolicy; |
281 | #endif | 281 | #endif |
282 | }; | 282 | } __randomize_layout; |
283 | 283 | ||
284 | struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode); | 284 | struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode); |
285 | 285 | ||
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 05488da3aee9..3ae9013eeaaa 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -46,7 +46,7 @@ struct linux_binprm { | |||
46 | unsigned interp_flags; | 46 | unsigned interp_flags; |
47 | unsigned interp_data; | 47 | unsigned interp_data; |
48 | unsigned long loader, exec; | 48 | unsigned long loader, exec; |
49 | }; | 49 | } __randomize_layout; |
50 | 50 | ||
51 | #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 | 51 | #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 |
52 | #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT) | 52 | #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT) |
@@ -81,7 +81,7 @@ struct linux_binfmt { | |||
81 | int (*load_shlib)(struct file *); | 81 | int (*load_shlib)(struct file *); |
82 | int (*core_dump)(struct coredump_params *cprm); | 82 | int (*core_dump)(struct coredump_params *cprm); |
83 | unsigned long min_coredump; /* minimal dump size */ | 83 | unsigned long min_coredump; /* minimal dump size */ |
84 | }; | 84 | } __randomize_layout; |
85 | 85 | ||
86 | extern void __register_binfmt(struct linux_binfmt *fmt, int insert); | 86 | extern void __register_binfmt(struct linux_binfmt *fmt, int insert); |
87 | 87 | ||
diff --git a/include/linux/cdev.h b/include/linux/cdev.h index 408bc09ce497..cb28eb21e3ca 100644 --- a/include/linux/cdev.h +++ b/include/linux/cdev.h | |||
@@ -17,7 +17,7 @@ struct cdev { | |||
17 | struct list_head list; | 17 | struct list_head list; |
18 | dev_t dev; | 18 | dev_t dev; |
19 | unsigned int count; | 19 | unsigned int count; |
20 | }; | 20 | } __randomize_layout; |
21 | 21 | ||
22 | void cdev_init(struct cdev *, const struct file_operations *); | 22 | void cdev_init(struct cdev *, const struct file_operations *); |
23 | 23 | ||
diff --git a/include/linux/ceph/ceph_features.h b/include/linux/ceph/ceph_features.h index f0f6c537b64c..040dd105c3e7 100644 --- a/include/linux/ceph/ceph_features.h +++ b/include/linux/ceph/ceph_features.h | |||
@@ -10,14 +10,14 @@ | |||
10 | #define CEPH_FEATURE_INCARNATION_2 (1ull<<57) // CEPH_FEATURE_SERVER_JEWEL | 10 | #define CEPH_FEATURE_INCARNATION_2 (1ull<<57) // CEPH_FEATURE_SERVER_JEWEL |
11 | 11 | ||
12 | #define DEFINE_CEPH_FEATURE(bit, incarnation, name) \ | 12 | #define DEFINE_CEPH_FEATURE(bit, incarnation, name) \ |
13 | const static uint64_t CEPH_FEATURE_##name = (1ULL<<bit); \ | 13 | static const uint64_t CEPH_FEATURE_##name = (1ULL<<bit); \ |
14 | const static uint64_t CEPH_FEATUREMASK_##name = \ | 14 | static const uint64_t CEPH_FEATUREMASK_##name = \ |
15 | (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation); | 15 | (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation); |
16 | 16 | ||
17 | /* this bit is ignored but still advertised by release *when* */ | 17 | /* this bit is ignored but still advertised by release *when* */ |
18 | #define DEFINE_CEPH_FEATURE_DEPRECATED(bit, incarnation, name, when) \ | 18 | #define DEFINE_CEPH_FEATURE_DEPRECATED(bit, incarnation, name, when) \ |
19 | const static uint64_t DEPRECATED_CEPH_FEATURE_##name = (1ULL<<bit); \ | 19 | static const uint64_t DEPRECATED_CEPH_FEATURE_##name = (1ULL<<bit); \ |
20 | const static uint64_t DEPRECATED_CEPH_FEATUREMASK_##name = \ | 20 | static const uint64_t DEPRECATED_CEPH_FEATUREMASK_##name = \ |
21 | (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation); | 21 | (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation); |
22 | 22 | ||
23 | /* | 23 | /* |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index cd4bbe8242bd..bdb80c4aef6e 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -235,6 +235,7 @@ | |||
235 | #endif /* GCC_VERSION >= 40500 */ | 235 | #endif /* GCC_VERSION >= 40500 */ |
236 | 236 | ||
237 | #if GCC_VERSION >= 40600 | 237 | #if GCC_VERSION >= 40600 |
238 | |||
238 | /* | 239 | /* |
239 | * When used with Link Time Optimization, gcc can optimize away C functions or | 240 | * When used with Link Time Optimization, gcc can optimize away C functions or |
240 | * variables which are referenced only from assembly code. __visible tells the | 241 | * variables which are referenced only from assembly code. __visible tells the |
@@ -242,7 +243,17 @@ | |||
242 | * this. | 243 | * this. |
243 | */ | 244 | */ |
244 | #define __visible __attribute__((externally_visible)) | 245 | #define __visible __attribute__((externally_visible)) |
245 | #endif | 246 | |
247 | /* | ||
248 | * RANDSTRUCT_PLUGIN wants to use an anonymous struct, but it is only | ||
249 | * possible since GCC 4.6. To provide as much build testing coverage | ||
250 | * as possible, this is used for all GCC 4.6+ builds, and not just on | ||
251 | * RANDSTRUCT_PLUGIN builds. | ||
252 | */ | ||
253 | #define randomized_struct_fields_start struct { | ||
254 | #define randomized_struct_fields_end } __randomize_layout; | ||
255 | |||
256 | #endif /* GCC_VERSION >= 40600 */ | ||
246 | 257 | ||
247 | 258 | ||
248 | #if GCC_VERSION >= 40900 && !defined(__CHECKER__) | 259 | #if GCC_VERSION >= 40900 && !defined(__CHECKER__) |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 219f82f3ec1a..eca8ad75e28b 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -452,6 +452,11 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s | |||
452 | # define __no_randomize_layout | 452 | # define __no_randomize_layout |
453 | #endif | 453 | #endif |
454 | 454 | ||
455 | #ifndef randomized_struct_fields_start | ||
456 | # define randomized_struct_fields_start | ||
457 | # define randomized_struct_fields_end | ||
458 | #endif | ||
459 | |||
455 | /* | 460 | /* |
456 | * Tell gcc if a function is cold. The compiler will assume any path | 461 | * Tell gcc if a function is cold. The compiler will assume any path |
457 | * directly leading to the call is unlikely. | 462 | * directly leading to the call is unlikely. |
diff --git a/include/linux/cred.h b/include/linux/cred.h index c728d515e5e2..099058e1178b 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
@@ -31,7 +31,7 @@ struct group_info { | |||
31 | atomic_t usage; | 31 | atomic_t usage; |
32 | int ngroups; | 32 | int ngroups; |
33 | kgid_t gid[0]; | 33 | kgid_t gid[0]; |
34 | }; | 34 | } __randomize_layout; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * get_group_info - Get a reference to a group info structure | 37 | * get_group_info - Get a reference to a group info structure |
@@ -145,7 +145,7 @@ struct cred { | |||
145 | struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */ | 145 | struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */ |
146 | struct group_info *group_info; /* supplementary groups for euid/fsgid */ | 146 | struct group_info *group_info; /* supplementary groups for euid/fsgid */ |
147 | struct rcu_head rcu; /* RCU deletion hook */ | 147 | struct rcu_head rcu; /* RCU deletion hook */ |
148 | }; | 148 | } __randomize_layout; |
149 | 149 | ||
150 | extern void __put_cred(struct cred *); | 150 | extern void __put_cred(struct cred *); |
151 | extern void exit_creds(struct task_struct *); | 151 | extern void exit_creds(struct task_struct *); |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 3f3ff4ccdc3f..aae1cdb76851 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -118,7 +118,7 @@ struct dentry { | |||
118 | struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */ | 118 | struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */ |
119 | struct rcu_head d_rcu; | 119 | struct rcu_head d_rcu; |
120 | } d_u; | 120 | } d_u; |
121 | }; | 121 | } __randomize_layout; |
122 | 122 | ||
123 | /* | 123 | /* |
124 | * dentry->d_lock spinlock nesting subclasses: | 124 | * dentry->d_lock spinlock nesting subclasses: |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 7b5d6816542b..6e1fd5d21248 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -296,7 +296,7 @@ struct kiocb { | |||
296 | void *private; | 296 | void *private; |
297 | int ki_flags; | 297 | int ki_flags; |
298 | enum rw_hint ki_hint; | 298 | enum rw_hint ki_hint; |
299 | }; | 299 | } __randomize_layout; |
300 | 300 | ||
301 | static inline bool is_sync_kiocb(struct kiocb *kiocb) | 301 | static inline bool is_sync_kiocb(struct kiocb *kiocb) |
302 | { | 302 | { |
@@ -404,7 +404,7 @@ struct address_space { | |||
404 | struct list_head private_list; /* ditto */ | 404 | struct list_head private_list; /* ditto */ |
405 | void *private_data; /* ditto */ | 405 | void *private_data; /* ditto */ |
406 | errseq_t wb_err; | 406 | errseq_t wb_err; |
407 | } __attribute__((aligned(sizeof(long)))); | 407 | } __attribute__((aligned(sizeof(long)))) __randomize_layout; |
408 | /* | 408 | /* |
409 | * On most architectures that alignment is already the case; but | 409 | * On most architectures that alignment is already the case; but |
410 | * must be enforced here for CRIS, to let the least significant bit | 410 | * must be enforced here for CRIS, to let the least significant bit |
@@ -447,7 +447,7 @@ struct block_device { | |||
447 | int bd_fsfreeze_count; | 447 | int bd_fsfreeze_count; |
448 | /* Mutex for freeze */ | 448 | /* Mutex for freeze */ |
449 | struct mutex bd_fsfreeze_mutex; | 449 | struct mutex bd_fsfreeze_mutex; |
450 | }; | 450 | } __randomize_layout; |
451 | 451 | ||
452 | /* | 452 | /* |
453 | * Radix-tree tags, for tagging dirty and writeback pages within the pagecache | 453 | * Radix-tree tags, for tagging dirty and writeback pages within the pagecache |
@@ -666,7 +666,7 @@ struct inode { | |||
666 | #endif | 666 | #endif |
667 | 667 | ||
668 | void *i_private; /* fs or device private pointer */ | 668 | void *i_private; /* fs or device private pointer */ |
669 | }; | 669 | } __randomize_layout; |
670 | 670 | ||
671 | static inline unsigned int i_blocksize(const struct inode *node) | 671 | static inline unsigned int i_blocksize(const struct inode *node) |
672 | { | 672 | { |
@@ -883,7 +883,8 @@ struct file { | |||
883 | #endif /* #ifdef CONFIG_EPOLL */ | 883 | #endif /* #ifdef CONFIG_EPOLL */ |
884 | struct address_space *f_mapping; | 884 | struct address_space *f_mapping; |
885 | errseq_t f_wb_err; | 885 | errseq_t f_wb_err; |
886 | } __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ | 886 | } __randomize_layout |
887 | __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ | ||
887 | 888 | ||
888 | struct file_handle { | 889 | struct file_handle { |
889 | __u32 handle_bytes; | 890 | __u32 handle_bytes; |
@@ -1020,7 +1021,7 @@ struct file_lock { | |||
1020 | int state; /* state of grant or error if -ve */ | 1021 | int state; /* state of grant or error if -ve */ |
1021 | } afs; | 1022 | } afs; |
1022 | } fl_u; | 1023 | } fl_u; |
1023 | }; | 1024 | } __randomize_layout; |
1024 | 1025 | ||
1025 | struct file_lock_context { | 1026 | struct file_lock_context { |
1026 | spinlock_t flc_lock; | 1027 | spinlock_t flc_lock; |
@@ -1412,7 +1413,7 @@ struct super_block { | |||
1412 | 1413 | ||
1413 | spinlock_t s_inode_wblist_lock; | 1414 | spinlock_t s_inode_wblist_lock; |
1414 | struct list_head s_inodes_wb; /* writeback inodes */ | 1415 | struct list_head s_inodes_wb; /* writeback inodes */ |
1415 | }; | 1416 | } __randomize_layout; |
1416 | 1417 | ||
1417 | /* Helper functions so that in most cases filesystems will | 1418 | /* Helper functions so that in most cases filesystems will |
1418 | * not need to deal directly with kuid_t and kgid_t and can | 1419 | * not need to deal directly with kuid_t and kgid_t and can |
@@ -1698,7 +1699,7 @@ struct file_operations { | |||
1698 | u64); | 1699 | u64); |
1699 | ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, | 1700 | ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, |
1700 | u64); | 1701 | u64); |
1701 | }; | 1702 | } __randomize_layout; |
1702 | 1703 | ||
1703 | struct inode_operations { | 1704 | struct inode_operations { |
1704 | struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); | 1705 | struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); |
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h index 0efc3e62843a..7a026240cbb1 100644 --- a/include/linux/fs_struct.h +++ b/include/linux/fs_struct.h | |||
@@ -12,7 +12,7 @@ struct fs_struct { | |||
12 | int umask; | 12 | int umask; |
13 | int in_exec; | 13 | int in_exec; |
14 | struct path root, pwd; | 14 | struct path root, pwd; |
15 | }; | 15 | } __randomize_layout; |
16 | 16 | ||
17 | extern struct kmem_cache *fs_cachep; | 17 | extern struct kmem_cache *fs_cachep; |
18 | 18 | ||
diff --git a/include/linux/ipc.h b/include/linux/ipc.h index 5591f055e13f..fadd579d577d 100644 --- a/include/linux/ipc.h +++ b/include/linux/ipc.h | |||
@@ -23,6 +23,6 @@ struct kern_ipc_perm { | |||
23 | 23 | ||
24 | struct rcu_head rcu; | 24 | struct rcu_head rcu; |
25 | atomic_t refcount; | 25 | atomic_t refcount; |
26 | } ____cacheline_aligned_in_smp; | 26 | } ____cacheline_aligned_in_smp __randomize_layout; |
27 | 27 | ||
28 | #endif /* _LINUX_IPC_H */ | 28 | #endif /* _LINUX_IPC_H */ |
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index 848e5796400e..65327ee0936b 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h | |||
@@ -61,7 +61,7 @@ struct ipc_namespace { | |||
61 | struct ucounts *ucounts; | 61 | struct ucounts *ucounts; |
62 | 62 | ||
63 | struct ns_common ns; | 63 | struct ns_common ns; |
64 | }; | 64 | } __randomize_layout; |
65 | 65 | ||
66 | extern struct ipc_namespace init_ipc_ns; | 66 | extern struct ipc_namespace init_ipc_ns; |
67 | extern spinlock_t mq_lock; | 67 | extern spinlock_t mq_lock; |
diff --git a/include/linux/key-type.h b/include/linux/key-type.h index 8496cf64575c..9520fc3c3b9a 100644 --- a/include/linux/key-type.h +++ b/include/linux/key-type.h | |||
@@ -45,7 +45,7 @@ struct key_preparsed_payload { | |||
45 | size_t datalen; /* Raw datalen */ | 45 | size_t datalen; /* Raw datalen */ |
46 | size_t quotalen; /* Quota length for proposed payload */ | 46 | size_t quotalen; /* Quota length for proposed payload */ |
47 | time_t expiry; /* Expiry time of key */ | 47 | time_t expiry; /* Expiry time of key */ |
48 | }; | 48 | } __randomize_layout; |
49 | 49 | ||
50 | typedef int (*request_key_actor_t)(struct key_construction *key, | 50 | typedef int (*request_key_actor_t)(struct key_construction *key, |
51 | const char *op, void *aux); | 51 | const char *op, void *aux); |
@@ -158,7 +158,7 @@ struct key_type { | |||
158 | /* internal fields */ | 158 | /* internal fields */ |
159 | struct list_head link; /* link in types list */ | 159 | struct list_head link; /* link in types list */ |
160 | struct lock_class_key lock_class; /* key->sem lock class */ | 160 | struct lock_class_key lock_class; /* key->sem lock class */ |
161 | }; | 161 | } __randomize_layout; |
162 | 162 | ||
163 | extern struct key_type key_type_keyring; | 163 | extern struct key_type key_type_keyring; |
164 | 164 | ||
diff --git a/include/linux/kmod.h b/include/linux/kmod.h index c4e441e00db5..655082c88fd9 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h | |||
@@ -64,7 +64,7 @@ struct subprocess_info { | |||
64 | int (*init)(struct subprocess_info *info, struct cred *new); | 64 | int (*init)(struct subprocess_info *info, struct cred *new); |
65 | void (*cleanup)(struct subprocess_info *info); | 65 | void (*cleanup)(struct subprocess_info *info); |
66 | void *data; | 66 | void *data; |
67 | }; | 67 | } __randomize_layout; |
68 | 68 | ||
69 | extern int | 69 | extern int |
70 | call_usermodehelper(const char *path, char **argv, char **envp, int wait); | 70 | call_usermodehelper(const char *path, char **argv, char **envp, int wait); |
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index eeab34b0f589..4d800c79475a 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h | |||
@@ -172,7 +172,7 @@ struct kset { | |||
172 | spinlock_t list_lock; | 172 | spinlock_t list_lock; |
173 | struct kobject kobj; | 173 | struct kobject kobj; |
174 | const struct kset_uevent_ops *uevent_ops; | 174 | const struct kset_uevent_ops *uevent_ops; |
175 | }; | 175 | } __randomize_layout; |
176 | 176 | ||
177 | extern void kset_init(struct kset *kset); | 177 | extern void kset_init(struct kset *kset); |
178 | extern int __must_check kset_register(struct kset *kset); | 178 | extern int __must_check kset_register(struct kset *kset); |
diff --git a/include/linux/llist.h b/include/linux/llist.h index d11738110a7a..1957635e6d5f 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h | |||
@@ -93,6 +93,23 @@ static inline void init_llist_head(struct llist_head *list) | |||
93 | container_of(ptr, type, member) | 93 | container_of(ptr, type, member) |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * member_address_is_nonnull - check whether the member address is not NULL | ||
97 | * @ptr: the object pointer (struct type * that contains the llist_node) | ||
98 | * @member: the name of the llist_node within the struct. | ||
99 | * | ||
100 | * This macro is conceptually the same as | ||
101 | * &ptr->member != NULL | ||
102 | * but it works around the fact that compilers can decide that taking a member | ||
103 | * address is never a NULL pointer. | ||
104 | * | ||
105 | * Real objects that start at a high address and have a member at NULL are | ||
106 | * unlikely to exist, but such pointers may be returned e.g. by the | ||
107 | * container_of() macro. | ||
108 | */ | ||
109 | #define member_address_is_nonnull(ptr, member) \ | ||
110 | ((uintptr_t)(ptr) + offsetof(typeof(*(ptr)), member) != 0) | ||
111 | |||
112 | /** | ||
96 | * llist_for_each - iterate over some deleted entries of a lock-less list | 113 | * llist_for_each - iterate over some deleted entries of a lock-less list |
97 | * @pos: the &struct llist_node to use as a loop cursor | 114 | * @pos: the &struct llist_node to use as a loop cursor |
98 | * @node: the first entry of deleted list entries | 115 | * @node: the first entry of deleted list entries |
@@ -145,7 +162,7 @@ static inline void init_llist_head(struct llist_head *list) | |||
145 | */ | 162 | */ |
146 | #define llist_for_each_entry(pos, node, member) \ | 163 | #define llist_for_each_entry(pos, node, member) \ |
147 | for ((pos) = llist_entry((node), typeof(*(pos)), member); \ | 164 | for ((pos) = llist_entry((node), typeof(*(pos)), member); \ |
148 | &(pos)->member != NULL; \ | 165 | member_address_is_nonnull(pos, member); \ |
149 | (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member)) | 166 | (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member)) |
150 | 167 | ||
151 | /** | 168 | /** |
@@ -167,7 +184,7 @@ static inline void init_llist_head(struct llist_head *list) | |||
167 | */ | 184 | */ |
168 | #define llist_for_each_entry_safe(pos, n, node, member) \ | 185 | #define llist_for_each_entry_safe(pos, n, node, member) \ |
169 | for (pos = llist_entry((node), typeof(*pos), member); \ | 186 | for (pos = llist_entry((node), typeof(*pos), member); \ |
170 | &pos->member != NULL && \ | 187 | member_address_is_nonnull(pos, member) && \ |
171 | (n = llist_entry(pos->member.next, typeof(*n), member), true); \ | 188 | (n = llist_entry(pos->member.next, typeof(*n), member), true); \ |
172 | pos = n) | 189 | pos = n) |
173 | 190 | ||
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 7a86925ba8f3..3a90febadbe2 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h | |||
@@ -1912,7 +1912,7 @@ struct security_hook_heads { | |||
1912 | struct list_head audit_rule_match; | 1912 | struct list_head audit_rule_match; |
1913 | struct list_head audit_rule_free; | 1913 | struct list_head audit_rule_free; |
1914 | #endif /* CONFIG_AUDIT */ | 1914 | #endif /* CONFIG_AUDIT */ |
1915 | }; | 1915 | } __randomize_layout; |
1916 | 1916 | ||
1917 | /* | 1917 | /* |
1918 | * Security module hook list structure. | 1918 | * Security module hook list structure. |
@@ -1923,7 +1923,7 @@ struct security_hook_list { | |||
1923 | struct list_head *head; | 1923 | struct list_head *head; |
1924 | union security_list_options hook; | 1924 | union security_list_options hook; |
1925 | char *lsm; | 1925 | char *lsm; |
1926 | }; | 1926 | } __randomize_layout; |
1927 | 1927 | ||
1928 | /* | 1928 | /* |
1929 | * Initializing a security_hook_list structure takes | 1929 | * Initializing a security_hook_list structure takes |
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index d5bed0875d30..aad5d81dfb44 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h | |||
@@ -1068,7 +1068,7 @@ static inline int mlx4_is_eth(struct mlx4_dev *dev, int port) | |||
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, | 1070 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, |
1071 | struct mlx4_buf *buf, gfp_t gfp); | 1071 | struct mlx4_buf *buf); |
1072 | void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); | 1072 | void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); |
1073 | static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset) | 1073 | static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset) |
1074 | { | 1074 | { |
@@ -1105,10 +1105,9 @@ int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw); | |||
1105 | int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | 1105 | int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, |
1106 | int start_index, int npages, u64 *page_list); | 1106 | int start_index, int npages, u64 *page_list); |
1107 | int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | 1107 | int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, |
1108 | struct mlx4_buf *buf, gfp_t gfp); | 1108 | struct mlx4_buf *buf); |
1109 | 1109 | ||
1110 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order, | 1110 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order); |
1111 | gfp_t gfp); | ||
1112 | void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db); | 1111 | void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db); |
1113 | 1112 | ||
1114 | int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | 1113 | int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, |
@@ -1124,8 +1123,7 @@ int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, | |||
1124 | int *base, u8 flags); | 1123 | int *base, u8 flags); |
1125 | void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt); | 1124 | void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt); |
1126 | 1125 | ||
1127 | int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp, | 1126 | int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp); |
1128 | gfp_t gfp); | ||
1129 | void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp); | 1127 | void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp); |
1130 | 1128 | ||
1131 | int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, u32 cqn, u16 xrcdn, | 1129 | int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, u32 cqn, u16 xrcdn, |
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 45cdb27791a3..ff151814a02d 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h | |||
@@ -342,7 +342,7 @@ struct vm_area_struct { | |||
342 | struct mempolicy *vm_policy; /* NUMA policy for the VMA */ | 342 | struct mempolicy *vm_policy; /* NUMA policy for the VMA */ |
343 | #endif | 343 | #endif |
344 | struct vm_userfaultfd_ctx vm_userfaultfd_ctx; | 344 | struct vm_userfaultfd_ctx vm_userfaultfd_ctx; |
345 | }; | 345 | } __randomize_layout; |
346 | 346 | ||
347 | struct core_thread { | 347 | struct core_thread { |
348 | struct task_struct *task; | 348 | struct task_struct *task; |
@@ -500,7 +500,7 @@ struct mm_struct { | |||
500 | atomic_long_t hugetlb_usage; | 500 | atomic_long_t hugetlb_usage; |
501 | #endif | 501 | #endif |
502 | struct work_struct async_put_work; | 502 | struct work_struct async_put_work; |
503 | }; | 503 | } __randomize_layout; |
504 | 504 | ||
505 | extern struct mm_struct init_mm; | 505 | extern struct mm_struct init_mm; |
506 | 506 | ||
diff --git a/include/linux/module.h b/include/linux/module.h index 8eb9a1e693e5..e7bdd549e527 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -45,7 +45,7 @@ struct module_kobject { | |||
45 | struct kobject *drivers_dir; | 45 | struct kobject *drivers_dir; |
46 | struct module_param_attrs *mp; | 46 | struct module_param_attrs *mp; |
47 | struct completion *kobj_completion; | 47 | struct completion *kobj_completion; |
48 | }; | 48 | } __randomize_layout; |
49 | 49 | ||
50 | struct module_attribute { | 50 | struct module_attribute { |
51 | struct attribute attr; | 51 | struct attribute attr; |
@@ -475,7 +475,7 @@ struct module { | |||
475 | ctor_fn_t *ctors; | 475 | ctor_fn_t *ctors; |
476 | unsigned int num_ctors; | 476 | unsigned int num_ctors; |
477 | #endif | 477 | #endif |
478 | } ____cacheline_aligned; | 478 | } ____cacheline_aligned __randomize_layout; |
479 | #ifndef MODULE_ARCH_INIT | 479 | #ifndef MODULE_ARCH_INIT |
480 | #define MODULE_ARCH_INIT {} | 480 | #define MODULE_ARCH_INIT {} |
481 | #endif | 481 | #endif |
diff --git a/include/linux/mount.h b/include/linux/mount.h index 8e0352af06b7..1ce85e6fd95f 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h | |||
@@ -67,7 +67,7 @@ struct vfsmount { | |||
67 | struct dentry *mnt_root; /* root of the mounted tree */ | 67 | struct dentry *mnt_root; /* root of the mounted tree */ |
68 | struct super_block *mnt_sb; /* pointer to superblock */ | 68 | struct super_block *mnt_sb; /* pointer to superblock */ |
69 | int mnt_flags; | 69 | int mnt_flags; |
70 | }; | 70 | } __randomize_layout; |
71 | 71 | ||
72 | struct file; /* forward dec */ | 72 | struct file; /* forward dec */ |
73 | struct path; | 73 | struct path; |
diff --git a/include/linux/msg.h b/include/linux/msg.h index f3f302f9c197..a001305f5a79 100644 --- a/include/linux/msg.h +++ b/include/linux/msg.h | |||
@@ -29,7 +29,7 @@ struct msg_queue { | |||
29 | struct list_head q_messages; | 29 | struct list_head q_messages; |
30 | struct list_head q_receivers; | 30 | struct list_head q_receivers; |
31 | struct list_head q_senders; | 31 | struct list_head q_senders; |
32 | }; | 32 | } __randomize_layout; |
33 | 33 | ||
34 | /* Helper routines for sys_msgsnd and sys_msgrcv */ | 34 | /* Helper routines for sys_msgsnd and sys_msgrcv */ |
35 | extern long do_msgsnd(int msqid, long mtype, void __user *mtext, | 35 | extern long do_msgsnd(int msqid, long mtype, void __user *mtext, |
diff --git a/include/linux/path.h b/include/linux/path.h index d1372186f431..cde895cc4af4 100644 --- a/include/linux/path.h +++ b/include/linux/path.h | |||
@@ -7,7 +7,7 @@ struct vfsmount; | |||
7 | struct path { | 7 | struct path { |
8 | struct vfsmount *mnt; | 8 | struct vfsmount *mnt; |
9 | struct dentry *dentry; | 9 | struct dentry *dentry; |
10 | }; | 10 | } __randomize_layout; |
11 | 11 | ||
12 | extern void path_get(const struct path *); | 12 | extern void path_get(const struct path *); |
13 | extern void path_put(const struct path *); | 13 | extern void path_put(const struct path *); |
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h index c2a989dee876..b09136f88cf4 100644 --- a/include/linux/pid_namespace.h +++ b/include/linux/pid_namespace.h | |||
@@ -52,7 +52,7 @@ struct pid_namespace { | |||
52 | int hide_pid; | 52 | int hide_pid; |
53 | int reboot; /* group exit code if this pidns was rebooted */ | 53 | int reboot; /* group exit code if this pidns was rebooted */ |
54 | struct ns_common ns; | 54 | struct ns_common ns; |
55 | }; | 55 | } __randomize_layout; |
56 | 56 | ||
57 | extern struct pid_namespace init_pid_ns; | 57 | extern struct pid_namespace init_pid_ns; |
58 | 58 | ||
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index 58ab28d81fc2..06844b54dfc1 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h | |||
@@ -21,7 +21,7 @@ struct proc_ns_operations { | |||
21 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); | 21 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); |
22 | struct user_namespace *(*owner)(struct ns_common *ns); | 22 | struct user_namespace *(*owner)(struct ns_common *ns); |
23 | struct ns_common *(*get_parent)(struct ns_common *ns); | 23 | struct ns_common *(*get_parent)(struct ns_common *ns); |
24 | }; | 24 | } __randomize_layout; |
25 | 25 | ||
26 | extern const struct proc_ns_operations netns_operations; | 26 | extern const struct proc_ns_operations netns_operations; |
27 | extern const struct proc_ns_operations utsns_operations; | 27 | extern const struct proc_ns_operations utsns_operations; |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 2ba9ec93423f..8337e2db0bb2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -426,7 +426,7 @@ struct sched_rt_entity { | |||
426 | /* rq "owned" by this entity/group: */ | 426 | /* rq "owned" by this entity/group: */ |
427 | struct rt_rq *my_q; | 427 | struct rt_rq *my_q; |
428 | #endif | 428 | #endif |
429 | }; | 429 | } __randomize_layout; |
430 | 430 | ||
431 | struct sched_dl_entity { | 431 | struct sched_dl_entity { |
432 | struct rb_node rb_node; | 432 | struct rb_node rb_node; |
@@ -526,6 +526,13 @@ struct task_struct { | |||
526 | #endif | 526 | #endif |
527 | /* -1 unrunnable, 0 runnable, >0 stopped: */ | 527 | /* -1 unrunnable, 0 runnable, >0 stopped: */ |
528 | volatile long state; | 528 | volatile long state; |
529 | |||
530 | /* | ||
531 | * This begins the randomizable portion of task_struct. Only | ||
532 | * scheduling-critical items should be added above here. | ||
533 | */ | ||
534 | randomized_struct_fields_start | ||
535 | |||
529 | void *stack; | 536 | void *stack; |
530 | atomic_t usage; | 537 | atomic_t usage; |
531 | /* Per task flags (PF_*), defined further below: */ | 538 | /* Per task flags (PF_*), defined further below: */ |
@@ -1079,6 +1086,13 @@ struct task_struct { | |||
1079 | /* Used by LSM modules for access restriction: */ | 1086 | /* Used by LSM modules for access restriction: */ |
1080 | void *security; | 1087 | void *security; |
1081 | #endif | 1088 | #endif |
1089 | |||
1090 | /* | ||
1091 | * New fields for task_struct should be added above here, so that | ||
1092 | * they are included in the randomized portion of task_struct. | ||
1093 | */ | ||
1094 | randomized_struct_fields_end | ||
1095 | |||
1082 | /* CPU-specific state of this task: */ | 1096 | /* CPU-specific state of this task: */ |
1083 | struct thread_struct thread; | 1097 | struct thread_struct thread; |
1084 | 1098 | ||
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index c06d63b3a583..2a0dd40b15db 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h | |||
@@ -222,7 +222,7 @@ struct signal_struct { | |||
222 | struct mutex cred_guard_mutex; /* guard against foreign influences on | 222 | struct mutex cred_guard_mutex; /* guard against foreign influences on |
223 | * credential calculations | 223 | * credential calculations |
224 | * (notably. ptrace) */ | 224 | * (notably. ptrace) */ |
225 | }; | 225 | } __randomize_layout; |
226 | 226 | ||
227 | /* | 227 | /* |
228 | * Bits in flags field of signal_struct. | 228 | * Bits in flags field of signal_struct. |
diff --git a/include/linux/sem.h b/include/linux/sem.h index be5cf2ea14ad..de2deb8676bd 100644 --- a/include/linux/sem.h +++ b/include/linux/sem.h | |||
@@ -41,7 +41,7 @@ struct sem_array { | |||
41 | unsigned int use_global_lock;/* >0: global lock required */ | 41 | unsigned int use_global_lock;/* >0: global lock required */ |
42 | 42 | ||
43 | struct sem sems[]; | 43 | struct sem sems[]; |
44 | }; | 44 | } __randomize_layout; |
45 | 45 | ||
46 | #ifdef CONFIG_SYSVIPC | 46 | #ifdef CONFIG_SYSVIPC |
47 | 47 | ||
diff --git a/include/linux/shm.h b/include/linux/shm.h index 04e881829625..0fb7061ec54c 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h | |||
@@ -22,7 +22,7 @@ struct shmid_kernel /* private to the kernel */ | |||
22 | /* The task created the shm object. NULL if the task is dead. */ | 22 | /* The task created the shm object. NULL if the task is dead. */ |
23 | struct task_struct *shm_creator; | 23 | struct task_struct *shm_creator; |
24 | struct list_head shm_clist; /* list by creator */ | 24 | struct list_head shm_clist; /* list by creator */ |
25 | }; | 25 | } __randomize_layout; |
26 | 26 | ||
27 | /* shm_mode upper byte flags */ | 27 | /* shm_mode upper byte flags */ |
28 | #define SHM_DEST 01000 /* segment will be destroyed on last detach */ | 28 | #define SHM_DEST 01000 /* segment will be destroyed on last detach */ |
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 3a89b9ff4cdc..1d4dba490fb6 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h | |||
@@ -120,7 +120,7 @@ struct ctl_table | |||
120 | struct ctl_table_poll *poll; | 120 | struct ctl_table_poll *poll; |
121 | void *extra1; | 121 | void *extra1; |
122 | void *extra2; | 122 | void *extra2; |
123 | }; | 123 | } __randomize_layout; |
124 | 124 | ||
125 | struct ctl_node { | 125 | struct ctl_node { |
126 | struct rb_node node; | 126 | struct rb_node node; |
diff --git a/include/linux/tty.h b/include/linux/tty.h index 69464c0d8068..79c30daf46a9 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -332,7 +332,7 @@ struct tty_struct { | |||
332 | /* If the tty has a pending do_SAK, queue it here - akpm */ | 332 | /* If the tty has a pending do_SAK, queue it here - akpm */ |
333 | struct work_struct SAK_work; | 333 | struct work_struct SAK_work; |
334 | struct tty_port *port; | 334 | struct tty_port *port; |
335 | }; | 335 | } __randomize_layout; |
336 | 336 | ||
337 | /* Each of a tty's open files has private_data pointing to tty_file_private */ | 337 | /* Each of a tty's open files has private_data pointing to tty_file_private */ |
338 | struct tty_file_private { | 338 | struct tty_file_private { |
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e47cc2..00b2213f6a35 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h | |||
@@ -291,7 +291,7 @@ struct tty_operations { | |||
291 | void (*poll_put_char)(struct tty_driver *driver, int line, char ch); | 291 | void (*poll_put_char)(struct tty_driver *driver, int line, char ch); |
292 | #endif | 292 | #endif |
293 | const struct file_operations *proc_fops; | 293 | const struct file_operations *proc_fops; |
294 | }; | 294 | } __randomize_layout; |
295 | 295 | ||
296 | struct tty_driver { | 296 | struct tty_driver { |
297 | int magic; /* magic number for this structure */ | 297 | int magic; /* magic number for this structure */ |
@@ -325,7 +325,7 @@ struct tty_driver { | |||
325 | 325 | ||
326 | const struct tty_operations *ops; | 326 | const struct tty_operations *ops; |
327 | struct list_head tty_drivers; | 327 | struct list_head tty_drivers; |
328 | }; | 328 | } __randomize_layout; |
329 | 329 | ||
330 | extern struct list_head tty_drivers; | 330 | extern struct list_head tty_drivers; |
331 | 331 | ||
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index 32354b4b4b2b..b3575ce29148 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h | |||
@@ -66,7 +66,7 @@ struct user_namespace { | |||
66 | #endif | 66 | #endif |
67 | struct ucounts *ucounts; | 67 | struct ucounts *ucounts; |
68 | int ucount_max[UCOUNT_COUNTS]; | 68 | int ucount_max[UCOUNT_COUNTS]; |
69 | }; | 69 | } __randomize_layout; |
70 | 70 | ||
71 | struct ucounts { | 71 | struct ucounts { |
72 | struct hlist_node node; | 72 | struct hlist_node node; |
diff --git a/include/linux/utsname.h b/include/linux/utsname.h index 60f0bb83b313..da826ed059cf 100644 --- a/include/linux/utsname.h +++ b/include/linux/utsname.h | |||
@@ -26,7 +26,7 @@ struct uts_namespace { | |||
26 | struct user_namespace *user_ns; | 26 | struct user_namespace *user_ns; |
27 | struct ucounts *ucounts; | 27 | struct ucounts *ucounts; |
28 | struct ns_common ns; | 28 | struct ns_common ns; |
29 | }; | 29 | } __randomize_layout; |
30 | extern struct uts_namespace init_uts_ns; | 30 | extern struct uts_namespace init_uts_ns; |
31 | 31 | ||
32 | #ifdef CONFIG_UTS_NS | 32 | #ifdef CONFIG_UTS_NS |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 678e4d6fa317..53b1a2cca421 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -37,7 +37,7 @@ struct unix_skb_parms { | |||
37 | u32 secid; /* Security ID */ | 37 | u32 secid; /* Security ID */ |
38 | #endif | 38 | #endif |
39 | u32 consumed; | 39 | u32 consumed; |
40 | }; | 40 | } __randomize_layout; |
41 | 41 | ||
42 | #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) | 42 | #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) |
43 | 43 | ||
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index afc39e3a3f7c..9816df225af3 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -156,7 +156,7 @@ struct neighbour { | |||
156 | struct rcu_head rcu; | 156 | struct rcu_head rcu; |
157 | struct net_device *dev; | 157 | struct net_device *dev; |
158 | u8 primary_key[0]; | 158 | u8 primary_key[0]; |
159 | }; | 159 | } __randomize_layout; |
160 | 160 | ||
161 | struct neigh_ops { | 161 | struct neigh_ops { |
162 | int family; | 162 | int family; |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 31a2b51bef2c..1c401bd4c2e0 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -148,7 +148,7 @@ struct net { | |||
148 | #endif | 148 | #endif |
149 | struct sock *diag_nlsk; | 149 | struct sock *diag_nlsk; |
150 | atomic_t fnhe_genid; | 150 | atomic_t fnhe_genid; |
151 | }; | 151 | } __randomize_layout; |
152 | 152 | ||
153 | #include <linux/seq_file_net.h> | 153 | #include <linux/seq_file_net.h> |
154 | 154 | ||
diff --git a/include/net/sock.h b/include/net/sock.h index f69c8c2782df..7c0632c7e870 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -1128,7 +1128,7 @@ struct proto { | |||
1128 | atomic_t socks; | 1128 | atomic_t socks; |
1129 | #endif | 1129 | #endif |
1130 | int (*diag_destroy)(struct sock *sk, int err); | 1130 | int (*diag_destroy)(struct sock *sk, int err); |
1131 | }; | 1131 | } __randomize_layout; |
1132 | 1132 | ||
1133 | int proto_register(struct proto *prot, int alloc_slab); | 1133 | int proto_register(struct proto *prot, int alloc_slab); |
1134 | void proto_unregister(struct proto *prot); | 1134 | void proto_unregister(struct proto *prot); |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 356953d3dbd1..b5732432bb29 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -1056,7 +1056,7 @@ enum ib_qp_create_flags { | |||
1056 | IB_QP_CREATE_MANAGED_RECV = 1 << 4, | 1056 | IB_QP_CREATE_MANAGED_RECV = 1 << 4, |
1057 | IB_QP_CREATE_NETIF_QP = 1 << 5, | 1057 | IB_QP_CREATE_NETIF_QP = 1 << 5, |
1058 | IB_QP_CREATE_SIGNATURE_EN = 1 << 6, | 1058 | IB_QP_CREATE_SIGNATURE_EN = 1 << 6, |
1059 | IB_QP_CREATE_USE_GFP_NOIO = 1 << 7, | 1059 | /* FREE = 1 << 7, */ |
1060 | IB_QP_CREATE_SCATTER_FCS = 1 << 8, | 1060 | IB_QP_CREATE_SCATTER_FCS = 1 << 8, |
1061 | IB_QP_CREATE_CVLAN_STRIPPING = 1 << 9, | 1061 | IB_QP_CREATE_CVLAN_STRIPPING = 1 << 9, |
1062 | /* reserve bits 26-31 for low level drivers' internal use */ | 1062 | /* reserve bits 26-31 for low level drivers' internal use */ |
@@ -2948,6 +2948,22 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd, | |||
2948 | struct ib_qp_init_attr *qp_init_attr); | 2948 | struct ib_qp_init_attr *qp_init_attr); |
2949 | 2949 | ||
2950 | /** | 2950 | /** |
2951 | * ib_modify_qp_with_udata - Modifies the attributes for the specified QP. | ||
2952 | * @qp: The QP to modify. | ||
2953 | * @attr: On input, specifies the QP attributes to modify. On output, | ||
2954 | * the current values of selected QP attributes are returned. | ||
2955 | * @attr_mask: A bit-mask used to specify which attributes of the QP | ||
2956 | * are being modified. | ||
2957 | * @udata: pointer to user's input output buffer information | ||
2958 | * are being modified. | ||
2959 | * It returns 0 on success and returns appropriate error code on error. | ||
2960 | */ | ||
2961 | int ib_modify_qp_with_udata(struct ib_qp *qp, | ||
2962 | struct ib_qp_attr *attr, | ||
2963 | int attr_mask, | ||
2964 | struct ib_udata *udata); | ||
2965 | |||
2966 | /** | ||
2951 | * ib_modify_qp - Modifies the attributes for the specified QP and then | 2967 | * ib_modify_qp - Modifies the attributes for the specified QP and then |
2952 | * transitions the QP to the given state. | 2968 | * transitions the QP to the given state. |
2953 | * @qp: The QP to modify. | 2969 | * @qp: The QP to modify. |
diff --git a/include/rdma/rdma_vt.h b/include/rdma/rdma_vt.h index 4878aaf7bdff..55af69271053 100644 --- a/include/rdma/rdma_vt.h +++ b/include/rdma/rdma_vt.h | |||
@@ -229,8 +229,7 @@ struct rvt_driver_provided { | |||
229 | * ERR_PTR(err). The driver is free to return NULL or a valid | 229 | * ERR_PTR(err). The driver is free to return NULL or a valid |
230 | * pointer. | 230 | * pointer. |
231 | */ | 231 | */ |
232 | void * (*qp_priv_alloc)(struct rvt_dev_info *rdi, struct rvt_qp *qp, | 232 | void * (*qp_priv_alloc)(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
233 | gfp_t gfp); | ||
234 | 233 | ||
235 | /* | 234 | /* |
236 | * Free the driver's private qp structure. | 235 | * Free the driver's private qp structure. |
@@ -319,7 +318,7 @@ struct rvt_driver_provided { | |||
319 | 318 | ||
320 | /* Let the driver pick the next queue pair number*/ | 319 | /* Let the driver pick the next queue pair number*/ |
321 | int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | 320 | int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, |
322 | enum ib_qp_type type, u8 port_num, gfp_t gfp); | 321 | enum ib_qp_type type, u8 port_num); |
323 | 322 | ||
324 | /* Determine if its safe or allowed to modify the qp */ | 323 | /* Determine if its safe or allowed to modify the qp */ |
325 | int (*check_modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr, | 324 | int (*check_modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr, |
diff --git a/kernel/audit.c b/kernel/audit.c index 833267bbd80b..6dd556931739 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -641,6 +641,7 @@ static int auditd_send_unicast_skb(struct sk_buff *skb) | |||
641 | ac = rcu_dereference(auditd_conn); | 641 | ac = rcu_dereference(auditd_conn); |
642 | if (!ac) { | 642 | if (!ac) { |
643 | rcu_read_unlock(); | 643 | rcu_read_unlock(); |
644 | kfree_skb(skb); | ||
644 | rc = -ECONNREFUSED; | 645 | rc = -ECONNREFUSED; |
645 | goto err; | 646 | goto err; |
646 | } | 647 | } |
diff --git a/kernel/cpu.c b/kernel/cpu.c index ab860453841d..eee033134262 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -279,7 +279,8 @@ static int bringup_wait_for_ap(unsigned int cpu) | |||
279 | 279 | ||
280 | /* Wait for the CPU to reach CPUHP_AP_ONLINE_IDLE */ | 280 | /* Wait for the CPU to reach CPUHP_AP_ONLINE_IDLE */ |
281 | wait_for_completion(&st->done); | 281 | wait_for_completion(&st->done); |
282 | BUG_ON(!cpu_online(cpu)); | 282 | if (WARN_ON_ONCE((!cpu_online(cpu)))) |
283 | return -ECANCELED; | ||
283 | 284 | ||
284 | /* Unpark the stopper thread and the hotplug thread of the target cpu */ | 285 | /* Unpark the stopper thread and the hotplug thread of the target cpu */ |
285 | stop_machine_unpark(cpu); | 286 | stop_machine_unpark(cpu); |
diff --git a/kernel/futex.c b/kernel/futex.c index c934689043b2..16dbe4c93895 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -212,7 +212,7 @@ struct futex_pi_state { | |||
212 | atomic_t refcount; | 212 | atomic_t refcount; |
213 | 213 | ||
214 | union futex_key key; | 214 | union futex_key key; |
215 | }; | 215 | } __randomize_layout; |
216 | 216 | ||
217 | /** | 217 | /** |
218 | * struct futex_q - The hashed futex queue entry, one per waiting task | 218 | * struct futex_q - The hashed futex queue entry, one per waiting task |
@@ -246,7 +246,7 @@ struct futex_q { | |||
246 | struct rt_mutex_waiter *rt_waiter; | 246 | struct rt_mutex_waiter *rt_waiter; |
247 | union futex_key *requeue_pi_key; | 247 | union futex_key *requeue_pi_key; |
248 | u32 bitset; | 248 | u32 bitset; |
249 | }; | 249 | } __randomize_layout; |
250 | 250 | ||
251 | static const struct futex_q futex_q_init = { | 251 | static const struct futex_q futex_q_init = { |
252 | /* list gets initialized in queue_me()*/ | 252 | /* list gets initialized in queue_me()*/ |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 5624b2dd6b58..1d1a5b945ab4 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -1090,6 +1090,16 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) | |||
1090 | /* | 1090 | /* |
1091 | * Internal function to register an irqaction - typically used to | 1091 | * Internal function to register an irqaction - typically used to |
1092 | * allocate special interrupts that are part of the architecture. | 1092 | * allocate special interrupts that are part of the architecture. |
1093 | * | ||
1094 | * Locking rules: | ||
1095 | * | ||
1096 | * desc->request_mutex Provides serialization against a concurrent free_irq() | ||
1097 | * chip_bus_lock Provides serialization for slow bus operations | ||
1098 | * desc->lock Provides serialization against hard interrupts | ||
1099 | * | ||
1100 | * chip_bus_lock and desc->lock are sufficient for all other management and | ||
1101 | * interrupt related functions. desc->request_mutex solely serializes | ||
1102 | * request/free_irq(). | ||
1093 | */ | 1103 | */ |
1094 | static int | 1104 | static int |
1095 | __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | 1105 | __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) |
@@ -1167,20 +1177,35 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
1167 | if (desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE) | 1177 | if (desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE) |
1168 | new->flags &= ~IRQF_ONESHOT; | 1178 | new->flags &= ~IRQF_ONESHOT; |
1169 | 1179 | ||
1180 | /* | ||
1181 | * Protects against a concurrent __free_irq() call which might wait | ||
1182 | * for synchronize_irq() to complete without holding the optional | ||
1183 | * chip bus lock and desc->lock. | ||
1184 | */ | ||
1170 | mutex_lock(&desc->request_mutex); | 1185 | mutex_lock(&desc->request_mutex); |
1186 | |||
1187 | /* | ||
1188 | * Acquire bus lock as the irq_request_resources() callback below | ||
1189 | * might rely on the serialization or the magic power management | ||
1190 | * functions which are abusing the irq_bus_lock() callback, | ||
1191 | */ | ||
1192 | chip_bus_lock(desc); | ||
1193 | |||
1194 | /* First installed action requests resources. */ | ||
1171 | if (!desc->action) { | 1195 | if (!desc->action) { |
1172 | ret = irq_request_resources(desc); | 1196 | ret = irq_request_resources(desc); |
1173 | if (ret) { | 1197 | if (ret) { |
1174 | pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", | 1198 | pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", |
1175 | new->name, irq, desc->irq_data.chip->name); | 1199 | new->name, irq, desc->irq_data.chip->name); |
1176 | goto out_mutex; | 1200 | goto out_bus_unlock; |
1177 | } | 1201 | } |
1178 | } | 1202 | } |
1179 | 1203 | ||
1180 | chip_bus_lock(desc); | ||
1181 | |||
1182 | /* | 1204 | /* |
1183 | * The following block of code has to be executed atomically | 1205 | * The following block of code has to be executed atomically |
1206 | * protected against a concurrent interrupt and any of the other | ||
1207 | * management calls which are not serialized via | ||
1208 | * desc->request_mutex or the optional bus lock. | ||
1184 | */ | 1209 | */ |
1185 | raw_spin_lock_irqsave(&desc->lock, flags); | 1210 | raw_spin_lock_irqsave(&desc->lock, flags); |
1186 | old_ptr = &desc->action; | 1211 | old_ptr = &desc->action; |
@@ -1286,10 +1311,8 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
1286 | ret = __irq_set_trigger(desc, | 1311 | ret = __irq_set_trigger(desc, |
1287 | new->flags & IRQF_TRIGGER_MASK); | 1312 | new->flags & IRQF_TRIGGER_MASK); |
1288 | 1313 | ||
1289 | if (ret) { | 1314 | if (ret) |
1290 | irq_release_resources(desc); | ||
1291 | goto out_unlock; | 1315 | goto out_unlock; |
1292 | } | ||
1293 | } | 1316 | } |
1294 | 1317 | ||
1295 | desc->istate &= ~(IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED | \ | 1318 | desc->istate &= ~(IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED | \ |
@@ -1385,12 +1408,10 @@ mismatch: | |||
1385 | out_unlock: | 1408 | out_unlock: |
1386 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 1409 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
1387 | 1410 | ||
1388 | chip_bus_sync_unlock(desc); | ||
1389 | |||
1390 | if (!desc->action) | 1411 | if (!desc->action) |
1391 | irq_release_resources(desc); | 1412 | irq_release_resources(desc); |
1392 | 1413 | out_bus_unlock: | |
1393 | out_mutex: | 1414 | chip_bus_sync_unlock(desc); |
1394 | mutex_unlock(&desc->request_mutex); | 1415 | mutex_unlock(&desc->request_mutex); |
1395 | 1416 | ||
1396 | out_thread: | 1417 | out_thread: |
@@ -1472,6 +1493,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
1472 | WARN(1, "Trying to free already-free IRQ %d\n", irq); | 1493 | WARN(1, "Trying to free already-free IRQ %d\n", irq); |
1473 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 1494 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
1474 | chip_bus_sync_unlock(desc); | 1495 | chip_bus_sync_unlock(desc); |
1496 | mutex_unlock(&desc->request_mutex); | ||
1475 | return NULL; | 1497 | return NULL; |
1476 | } | 1498 | } |
1477 | 1499 | ||
@@ -1498,6 +1520,20 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
1498 | #endif | 1520 | #endif |
1499 | 1521 | ||
1500 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 1522 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
1523 | /* | ||
1524 | * Drop bus_lock here so the changes which were done in the chip | ||
1525 | * callbacks above are synced out to the irq chips which hang | ||
1526 | * behind a slow bus (I2C, SPI) before calling synchronize_irq(). | ||
1527 | * | ||
1528 | * Aside of that the bus_lock can also be taken from the threaded | ||
1529 | * handler in irq_finalize_oneshot() which results in a deadlock | ||
1530 | * because synchronize_irq() would wait forever for the thread to | ||
1531 | * complete, which is blocked on the bus lock. | ||
1532 | * | ||
1533 | * The still held desc->request_mutex() protects against a | ||
1534 | * concurrent request_irq() of this irq so the release of resources | ||
1535 | * and timing data is properly serialized. | ||
1536 | */ | ||
1501 | chip_bus_sync_unlock(desc); | 1537 | chip_bus_sync_unlock(desc); |
1502 | 1538 | ||
1503 | unregister_handler_proc(irq, action); | 1539 | unregister_handler_proc(irq, action); |
@@ -1530,8 +1566,15 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
1530 | } | 1566 | } |
1531 | } | 1567 | } |
1532 | 1568 | ||
1569 | /* Last action releases resources */ | ||
1533 | if (!desc->action) { | 1570 | if (!desc->action) { |
1571 | /* | ||
1572 | * Reaquire bus lock as irq_release_resources() might | ||
1573 | * require it to deallocate resources over the slow bus. | ||
1574 | */ | ||
1575 | chip_bus_lock(desc); | ||
1534 | irq_release_resources(desc); | 1576 | irq_release_resources(desc); |
1577 | chip_bus_sync_unlock(desc); | ||
1535 | irq_remove_timings(desc); | 1578 | irq_remove_timings(desc); |
1536 | } | 1579 | } |
1537 | 1580 | ||
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 0c31035bbfee..b7cc615d42ef 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -3203,8 +3203,10 @@ static struct ceph_msg_data *ceph_msg_data_create(enum ceph_msg_data_type type) | |||
3203 | return NULL; | 3203 | return NULL; |
3204 | 3204 | ||
3205 | data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS); | 3205 | data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS); |
3206 | if (data) | 3206 | if (!data) |
3207 | data->type = type; | 3207 | return NULL; |
3208 | |||
3209 | data->type = type; | ||
3208 | INIT_LIST_HEAD(&data->links); | 3210 | INIT_LIST_HEAD(&data->links); |
3209 | 3211 | ||
3210 | return data; | 3212 | return data; |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 86a9737d8e3f..901bb8221366 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -5310,7 +5310,10 @@ static int invalidate_authorizer(struct ceph_connection *con) | |||
5310 | 5310 | ||
5311 | static void osd_reencode_message(struct ceph_msg *msg) | 5311 | static void osd_reencode_message(struct ceph_msg *msg) |
5312 | { | 5312 | { |
5313 | encode_request_finish(msg); | 5313 | int type = le16_to_cpu(msg->hdr.type); |
5314 | |||
5315 | if (type == CEPH_MSG_OSD_OP) | ||
5316 | encode_request_finish(msg); | ||
5314 | } | 5317 | } |
5315 | 5318 | ||
5316 | static int osd_sign_message(struct ceph_msg *msg) | 5319 | static int osd_sign_message(struct ceph_msg *msg) |
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 864789c5974e..64ae9f89773a 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -338,7 +338,7 @@ static void crush_finalize(struct crush_map *c) | |||
338 | static struct crush_map *crush_decode(void *pbyval, void *end) | 338 | static struct crush_map *crush_decode(void *pbyval, void *end) |
339 | { | 339 | { |
340 | struct crush_map *c; | 340 | struct crush_map *c; |
341 | int err = -EINVAL; | 341 | int err; |
342 | int i, j; | 342 | int i, j; |
343 | void **p = &pbyval; | 343 | void **p = &pbyval; |
344 | void *start = pbyval; | 344 | void *start = pbyval; |
@@ -407,7 +407,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
407 | size = sizeof(struct crush_bucket_straw2); | 407 | size = sizeof(struct crush_bucket_straw2); |
408 | break; | 408 | break; |
409 | default: | 409 | default: |
410 | err = -EINVAL; | ||
411 | goto bad; | 410 | goto bad; |
412 | } | 411 | } |
413 | BUG_ON(size == 0); | 412 | BUG_ON(size == 0); |
@@ -439,31 +438,31 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
439 | err = crush_decode_uniform_bucket(p, end, | 438 | err = crush_decode_uniform_bucket(p, end, |
440 | (struct crush_bucket_uniform *)b); | 439 | (struct crush_bucket_uniform *)b); |
441 | if (err < 0) | 440 | if (err < 0) |
442 | goto bad; | 441 | goto fail; |
443 | break; | 442 | break; |
444 | case CRUSH_BUCKET_LIST: | 443 | case CRUSH_BUCKET_LIST: |
445 | err = crush_decode_list_bucket(p, end, | 444 | err = crush_decode_list_bucket(p, end, |
446 | (struct crush_bucket_list *)b); | 445 | (struct crush_bucket_list *)b); |
447 | if (err < 0) | 446 | if (err < 0) |
448 | goto bad; | 447 | goto fail; |
449 | break; | 448 | break; |
450 | case CRUSH_BUCKET_TREE: | 449 | case CRUSH_BUCKET_TREE: |
451 | err = crush_decode_tree_bucket(p, end, | 450 | err = crush_decode_tree_bucket(p, end, |
452 | (struct crush_bucket_tree *)b); | 451 | (struct crush_bucket_tree *)b); |
453 | if (err < 0) | 452 | if (err < 0) |
454 | goto bad; | 453 | goto fail; |
455 | break; | 454 | break; |
456 | case CRUSH_BUCKET_STRAW: | 455 | case CRUSH_BUCKET_STRAW: |
457 | err = crush_decode_straw_bucket(p, end, | 456 | err = crush_decode_straw_bucket(p, end, |
458 | (struct crush_bucket_straw *)b); | 457 | (struct crush_bucket_straw *)b); |
459 | if (err < 0) | 458 | if (err < 0) |
460 | goto bad; | 459 | goto fail; |
461 | break; | 460 | break; |
462 | case CRUSH_BUCKET_STRAW2: | 461 | case CRUSH_BUCKET_STRAW2: |
463 | err = crush_decode_straw2_bucket(p, end, | 462 | err = crush_decode_straw2_bucket(p, end, |
464 | (struct crush_bucket_straw2 *)b); | 463 | (struct crush_bucket_straw2 *)b); |
465 | if (err < 0) | 464 | if (err < 0) |
466 | goto bad; | 465 | goto fail; |
467 | break; | 466 | break; |
468 | } | 467 | } |
469 | } | 468 | } |
@@ -474,7 +473,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
474 | u32 yes; | 473 | u32 yes; |
475 | struct crush_rule *r; | 474 | struct crush_rule *r; |
476 | 475 | ||
477 | err = -EINVAL; | ||
478 | ceph_decode_32_safe(p, end, yes, bad); | 476 | ceph_decode_32_safe(p, end, yes, bad); |
479 | if (!yes) { | 477 | if (!yes) { |
480 | dout("crush_decode NO rule %d off %x %p to %p\n", | 478 | dout("crush_decode NO rule %d off %x %p to %p\n", |
@@ -489,7 +487,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
489 | /* len */ | 487 | /* len */ |
490 | ceph_decode_32_safe(p, end, yes, bad); | 488 | ceph_decode_32_safe(p, end, yes, bad); |
491 | #if BITS_PER_LONG == 32 | 489 | #if BITS_PER_LONG == 32 |
492 | err = -EINVAL; | ||
493 | if (yes > (ULONG_MAX - sizeof(*r)) | 490 | if (yes > (ULONG_MAX - sizeof(*r)) |
494 | / sizeof(struct crush_rule_step)) | 491 | / sizeof(struct crush_rule_step)) |
495 | goto bad; | 492 | goto bad; |
@@ -557,7 +554,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
557 | if (*p != end) { | 554 | if (*p != end) { |
558 | err = decode_choose_args(p, end, c); | 555 | err = decode_choose_args(p, end, c); |
559 | if (err) | 556 | if (err) |
560 | goto bad; | 557 | goto fail; |
561 | } | 558 | } |
562 | 559 | ||
563 | done: | 560 | done: |
@@ -567,10 +564,14 @@ done: | |||
567 | 564 | ||
568 | badmem: | 565 | badmem: |
569 | err = -ENOMEM; | 566 | err = -ENOMEM; |
570 | bad: | 567 | fail: |
571 | dout("crush_decode fail %d\n", err); | 568 | dout("crush_decode fail %d\n", err); |
572 | crush_destroy(c); | 569 | crush_destroy(c); |
573 | return ERR_PTR(err); | 570 | return ERR_PTR(err); |
571 | |||
572 | bad: | ||
573 | err = -EINVAL; | ||
574 | goto fail; | ||
574 | } | 575 | } |
575 | 576 | ||
576 | int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs) | 577 | int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs) |
@@ -1399,7 +1400,7 @@ static struct ceph_pg_mapping *__decode_pg_upmap_items(void **p, void *end, | |||
1399 | return ERR_PTR(-EINVAL); | 1400 | return ERR_PTR(-EINVAL); |
1400 | 1401 | ||
1401 | ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval); | 1402 | ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval); |
1402 | pg = kzalloc(sizeof(*pg) + 2 * len * sizeof(u32), GFP_NOIO); | 1403 | pg = alloc_pg_mapping(2 * len * sizeof(u32)); |
1403 | if (!pg) | 1404 | if (!pg) |
1404 | return ERR_PTR(-ENOMEM); | 1405 | return ERR_PTR(-ENOMEM); |
1405 | 1406 | ||
@@ -1544,7 +1545,7 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map) | |||
1544 | if (struct_v >= 3) { | 1545 | if (struct_v >= 3) { |
1545 | /* erasure_code_profiles */ | 1546 | /* erasure_code_profiles */ |
1546 | ceph_decode_skip_map_of_map(p, end, string, string, string, | 1547 | ceph_decode_skip_map_of_map(p, end, string, string, string, |
1547 | bad); | 1548 | e_inval); |
1548 | } | 1549 | } |
1549 | 1550 | ||
1550 | if (struct_v >= 4) { | 1551 | if (struct_v >= 4) { |
@@ -1825,9 +1826,9 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, | |||
1825 | if (struct_v >= 3) { | 1826 | if (struct_v >= 3) { |
1826 | /* new_erasure_code_profiles */ | 1827 | /* new_erasure_code_profiles */ |
1827 | ceph_decode_skip_map_of_map(p, end, string, string, string, | 1828 | ceph_decode_skip_map_of_map(p, end, string, string, string, |
1828 | bad); | 1829 | e_inval); |
1829 | /* old_erasure_code_profiles */ | 1830 | /* old_erasure_code_profiles */ |
1830 | ceph_decode_skip_set(p, end, string, bad); | 1831 | ceph_decode_skip_set(p, end, string, e_inval); |
1831 | } | 1832 | } |
1832 | 1833 | ||
1833 | if (struct_v >= 4) { | 1834 | if (struct_v >= 4) { |
diff --git a/security/keys/internal.h b/security/keys/internal.h index 91bc6214ae57..1c02c6547038 100644 --- a/security/keys/internal.h +++ b/security/keys/internal.h | |||
@@ -198,7 +198,7 @@ struct request_key_auth { | |||
198 | void *callout_info; | 198 | void *callout_info; |
199 | size_t callout_len; | 199 | size_t callout_len; |
200 | pid_t pid; | 200 | pid_t pid; |
201 | }; | 201 | } __randomize_layout; |
202 | 202 | ||
203 | extern struct key_type key_type_request_key_auth; | 203 | extern struct key_type key_type_request_key_auth; |
204 | extern struct key *request_key_auth_new(struct key *target, | 204 | extern struct key *request_key_auth_new(struct key *target, |