diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-11-09 17:41:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-11-09 17:41:58 -0500 |
commit | aa4330e15c26c5ef8dd184f515c0655db8c6df3a (patch) | |
tree | e9c74e94ccc79da0301a80474debdaabced1799e | |
parent | dc5db21865507d0d9f706bd97c4a85315d60d0c5 (diff) | |
parent | 89c38422e072bb453e3045b8f1b962a344c3edea (diff) |
Merge tag 'devicetree-fixes-for-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull Devicetree fixes from Rob Herring:
- Add validation of NUMA distance map to prevent crashes with bad map
- Fix setting of dma_mask
* tag 'devicetree-fixes-for-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux:
of, numa: Validate some distance map rules
of/device: Really only set bus DMA mask when appropriate
-rw-r--r-- | drivers/of/device.c | 4 | ||||
-rw-r--r-- | drivers/of/of_numa.c | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c index 0f27fad9fe94..5592437bb3d1 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c | |||
@@ -149,9 +149,11 @@ int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma) | |||
149 | * set by the driver. | 149 | * set by the driver. |
150 | */ | 150 | */ |
151 | mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1); | 151 | mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1); |
152 | dev->bus_dma_mask = mask; | ||
153 | dev->coherent_dma_mask &= mask; | 152 | dev->coherent_dma_mask &= mask; |
154 | *dev->dma_mask &= mask; | 153 | *dev->dma_mask &= mask; |
154 | /* ...but only set bus mask if we found valid dma-ranges earlier */ | ||
155 | if (!ret) | ||
156 | dev->bus_dma_mask = mask; | ||
155 | 157 | ||
156 | coherent = of_dma_is_coherent(np); | 158 | coherent = of_dma_is_coherent(np); |
157 | dev_dbg(dev, "device is%sdma coherent\n", | 159 | dev_dbg(dev, "device is%sdma coherent\n", |
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c index 35c64a4295e0..fe6b13608e51 100644 --- a/drivers/of/of_numa.c +++ b/drivers/of/of_numa.c | |||
@@ -104,9 +104,14 @@ static int __init of_numa_parse_distance_map_v1(struct device_node *map) | |||
104 | distance = of_read_number(matrix, 1); | 104 | distance = of_read_number(matrix, 1); |
105 | matrix++; | 105 | matrix++; |
106 | 106 | ||
107 | if ((nodea == nodeb && distance != LOCAL_DISTANCE) || | ||
108 | (nodea != nodeb && distance <= LOCAL_DISTANCE)) { | ||
109 | pr_err("Invalid distance[node%d -> node%d] = %d\n", | ||
110 | nodea, nodeb, distance); | ||
111 | return -EINVAL; | ||
112 | } | ||
113 | |||
107 | numa_set_distance(nodea, nodeb, distance); | 114 | numa_set_distance(nodea, nodeb, distance); |
108 | pr_debug("distance[node%d -> node%d] = %d\n", | ||
109 | nodea, nodeb, distance); | ||
110 | 115 | ||
111 | /* Set default distance of node B->A same as A->B */ | 116 | /* Set default distance of node B->A same as A->B */ |
112 | if (nodeb > nodea) | 117 | if (nodeb > nodea) |