aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug16
-rw-r--r--lib/iommu-common.c2
-rw-r--r--lib/mpi/mpicoder.c38
-rw-r--r--lib/pci_iomap.c66
-rw-r--r--lib/vsprintf.c1
5 files changed, 94 insertions, 29 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e2894b23efb6..3e0b662cae09 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1353,20 +1353,6 @@ config RCU_CPU_STALL_TIMEOUT
1353 RCU grace period persists, additional CPU stall warnings are 1353 RCU grace period persists, additional CPU stall warnings are
1354 printed at more widely spaced intervals. 1354 printed at more widely spaced intervals.
1355 1355
1356config RCU_CPU_STALL_INFO
1357 bool "Print additional diagnostics on RCU CPU stall"
1358 depends on (TREE_RCU || PREEMPT_RCU) && DEBUG_KERNEL
1359 default y
1360 help
1361 For each stalled CPU that is aware of the current RCU grace
1362 period, print out additional per-CPU diagnostic information
1363 regarding scheduling-clock ticks, idle state, and,
1364 for RCU_FAST_NO_HZ kernels, idle-entry state.
1365
1366 Say N if you are unsure.
1367
1368 Say Y if you want to enable such diagnostics.
1369
1370config RCU_TRACE 1356config RCU_TRACE
1371 bool "Enable tracing for RCU" 1357 bool "Enable tracing for RCU"
1372 depends on DEBUG_KERNEL 1358 depends on DEBUG_KERNEL
@@ -1379,7 +1365,7 @@ config RCU_TRACE
1379 Say N if you are unsure. 1365 Say N if you are unsure.
1380 1366
1381config RCU_EQS_DEBUG 1367config RCU_EQS_DEBUG
1382 bool "Use this when adding any sort of NO_HZ support to your arch" 1368 bool "Provide debugging asserts for adding NO_HZ support to an arch"
1383 depends on DEBUG_KERNEL 1369 depends on DEBUG_KERNEL
1384 help 1370 help
1385 This option provides consistency checks in RCU's handling of 1371 This option provides consistency checks in RCU's handling of
diff --git a/lib/iommu-common.c b/lib/iommu-common.c
index df30632f0bef..ff19f66d3f7f 100644
--- a/lib/iommu-common.c
+++ b/lib/iommu-common.c
@@ -119,7 +119,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev,
119 unsigned long align_mask = 0; 119 unsigned long align_mask = 0;
120 120
121 if (align_order > 0) 121 if (align_order > 0)
122 align_mask = 0xffffffffffffffffl >> (64 - align_order); 122 align_mask = ~0ul >> (BITS_PER_LONG - align_order);
123 123
124 /* Sanity check */ 124 /* Sanity check */
125 if (unlikely(npages == 0)) { 125 if (unlikely(npages == 0)) {
diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index bc0a1da8afba..95c52a95259e 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -146,18 +146,25 @@ int mpi_read_buffer(MPI a, uint8_t *buf, unsigned buf_len, unsigned *nbytes,
146 uint8_t *p; 146 uint8_t *p;
147 mpi_limb_t alimb; 147 mpi_limb_t alimb;
148 unsigned int n = mpi_get_size(a); 148 unsigned int n = mpi_get_size(a);
149 int i; 149 int i, lzeros = 0;
150 150
151 if (buf_len < n || !buf) 151 if (buf_len < n || !buf || !nbytes)
152 return -EINVAL; 152 return -EINVAL;
153 153
154 if (sign) 154 if (sign)
155 *sign = a->sign; 155 *sign = a->sign;
156 156
157 if (nbytes) 157 p = (void *)&a->d[a->nlimbs] - 1;
158 *nbytes = n; 158
159 for (i = a->nlimbs * sizeof(alimb) - 1; i >= 0; i--, p--) {
160 if (!*p)
161 lzeros++;
162 else
163 break;
164 }
159 165
160 p = buf; 166 p = buf;
167 *nbytes = n - lzeros;
161 168
162 for (i = a->nlimbs - 1; i >= 0; i--) { 169 for (i = a->nlimbs - 1; i >= 0; i--) {
163 alimb = a->d[i]; 170 alimb = a->d[i];
@@ -178,6 +185,19 @@ int mpi_read_buffer(MPI a, uint8_t *buf, unsigned buf_len, unsigned *nbytes,
178#else 185#else
179#error please implement for this limb size. 186#error please implement for this limb size.
180#endif 187#endif
188
189 if (lzeros > 0) {
190 if (lzeros >= sizeof(alimb)) {
191 p -= sizeof(alimb);
192 } else {
193 mpi_limb_t *limb1 = (void *)p - sizeof(alimb);
194 mpi_limb_t *limb2 = (void *)p - sizeof(alimb)
195 + lzeros;
196 *limb1 = *limb2;
197 p -= lzeros;
198 }
199 lzeros -= sizeof(alimb);
200 }
181 } 201 }
182 return 0; 202 return 0;
183} 203}
@@ -197,7 +217,7 @@ EXPORT_SYMBOL_GPL(mpi_read_buffer);
197 */ 217 */
198void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign) 218void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign)
199{ 219{
200 uint8_t *buf, *p; 220 uint8_t *buf;
201 unsigned int n; 221 unsigned int n;
202 int ret; 222 int ret;
203 223
@@ -220,14 +240,6 @@ void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign)
220 kfree(buf); 240 kfree(buf);
221 return NULL; 241 return NULL;
222 } 242 }
223
224 /* this is sub-optimal but we need to do the shift operation
225 * because the caller has to free the returned buffer */
226 for (p = buf; !*p && *nbytes; p++, --*nbytes)
227 ;
228 if (p != buf)
229 memmove(buf, p, *nbytes);
230
231 return buf; 243 return buf;
232} 244}
233EXPORT_SYMBOL_GPL(mpi_get_buffer); 245EXPORT_SYMBOL_GPL(mpi_get_buffer);
diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c
index bcce5f149310..5f5d24d1d53f 100644
--- a/lib/pci_iomap.c
+++ b/lib/pci_iomap.c
@@ -52,6 +52,51 @@ void __iomem *pci_iomap_range(struct pci_dev *dev,
52EXPORT_SYMBOL(pci_iomap_range); 52EXPORT_SYMBOL(pci_iomap_range);
53 53
54/** 54/**
55 * pci_iomap_wc_range - create a virtual WC mapping cookie for a PCI BAR
56 * @dev: PCI device that owns the BAR
57 * @bar: BAR number
58 * @offset: map memory at the given offset in BAR
59 * @maxlen: max length of the memory to map
60 *
61 * Using this function you will get a __iomem address to your device BAR.
62 * You can access it using ioread*() and iowrite*(). These functions hide
63 * the details if this is a MMIO or PIO address space and will just do what
64 * you expect from them in the correct way. When possible write combining
65 * is used.
66 *
67 * @maxlen specifies the maximum length to map. If you want to get access to
68 * the complete BAR from offset to the end, pass %0 here.
69 * */
70void __iomem *pci_iomap_wc_range(struct pci_dev *dev,
71 int bar,
72 unsigned long offset,
73 unsigned long maxlen)
74{
75 resource_size_t start = pci_resource_start(dev, bar);
76 resource_size_t len = pci_resource_len(dev, bar);
77 unsigned long flags = pci_resource_flags(dev, bar);
78
79
80 if (flags & IORESOURCE_IO)
81 return NULL;
82
83 if (len <= offset || !start)
84 return NULL;
85
86 len -= offset;
87 start += offset;
88 if (maxlen && len > maxlen)
89 len = maxlen;
90
91 if (flags & IORESOURCE_MEM)
92 return ioremap_wc(start, len);
93
94 /* What? */
95 return NULL;
96}
97EXPORT_SYMBOL_GPL(pci_iomap_wc_range);
98
99/**
55 * pci_iomap - create a virtual mapping cookie for a PCI BAR 100 * pci_iomap - create a virtual mapping cookie for a PCI BAR
56 * @dev: PCI device that owns the BAR 101 * @dev: PCI device that owns the BAR
57 * @bar: BAR number 102 * @bar: BAR number
@@ -70,4 +115,25 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
70 return pci_iomap_range(dev, bar, 0, maxlen); 115 return pci_iomap_range(dev, bar, 0, maxlen);
71} 116}
72EXPORT_SYMBOL(pci_iomap); 117EXPORT_SYMBOL(pci_iomap);
118
119/**
120 * pci_iomap_wc - create a virtual WC mapping cookie for a PCI BAR
121 * @dev: PCI device that owns the BAR
122 * @bar: BAR number
123 * @maxlen: length of the memory to map
124 *
125 * Using this function you will get a __iomem address to your device BAR.
126 * You can access it using ioread*() and iowrite*(). These functions hide
127 * the details if this is a MMIO or PIO address space and will just do what
128 * you expect from them in the correct way. When possible write combining
129 * is used.
130 *
131 * @maxlen specifies the maximum length to map. If you want to get access to
132 * the complete BAR without checking for its length first, pass %0 here.
133 * */
134void __iomem *pci_iomap_wc(struct pci_dev *dev, int bar, unsigned long maxlen)
135{
136 return pci_iomap_wc_range(dev, bar, 0, maxlen);
137}
138EXPORT_SYMBOL_GPL(pci_iomap_wc);
73#endif /* CONFIG_PCI */ 139#endif /* CONFIG_PCI */
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index da39c608a28c..95cd63b43b99 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <stdarg.h> 19#include <stdarg.h>
20#include <linux/clk.h>
20#include <linux/clk-provider.h> 21#include <linux/clk-provider.h>
21#include <linux/module.h> /* for KSYM_SYMBOL_LEN */ 22#include <linux/module.h> /* for KSYM_SYMBOL_LEN */
22#include <linux/types.h> 23#include <linux/types.h>