diff options
| author | Gilad Ben-Yossef <gilad@benyossef.com> | 2017-11-02 04:10:22 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-11-06 10:46:03 -0500 |
| commit | 414a48e88d9a840ba110e4ade938236216cf06bf (patch) | |
| tree | 2001755cf9a3ae8a533b83e8331ab68799a091aa | |
| parent | e7cdcba451b3ddd68e714875be13e782577c9e4a (diff) | |
staging: ccree: handle limiting of DMA masks
Properly handle limiting of DMA masks based on device and bus
capabilities.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/staging/ccree/ssi_driver.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 5f03c2596f45..1d4c7bb78884 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c | |||
| @@ -208,6 +208,7 @@ static int init_cc_resources(struct platform_device *plat_dev) | |||
| 208 | struct device *dev = &plat_dev->dev; | 208 | struct device *dev = &plat_dev->dev; |
| 209 | struct device_node *np = dev->of_node; | 209 | struct device_node *np = dev->of_node; |
| 210 | u32 signature_val; | 210 | u32 signature_val; |
| 211 | dma_addr_t dma_mask; | ||
| 211 | int rc = 0; | 212 | int rc = 0; |
| 212 | 213 | ||
| 213 | new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL); | 214 | new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL); |
| @@ -256,15 +257,29 @@ static int init_cc_resources(struct platform_device *plat_dev) | |||
| 256 | } | 257 | } |
| 257 | dev_dbg(dev, "Registered to IRQ: %d\n", new_drvdata->irq); | 258 | dev_dbg(dev, "Registered to IRQ: %d\n", new_drvdata->irq); |
| 258 | 259 | ||
| 260 | if (!plat_dev->dev.dma_mask) | ||
| 261 | plat_dev->dev.dma_mask = &plat_dev->dev.coherent_dma_mask; | ||
| 262 | |||
| 263 | dma_mask = (dma_addr_t)(DMA_BIT_MASK(DMA_BIT_MASK_LEN)); | ||
| 264 | while (dma_mask > 0x7fffffffUL) { | ||
| 265 | if (dma_supported(&plat_dev->dev, dma_mask)) { | ||
| 266 | rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask); | ||
| 267 | if (!rc) | ||
| 268 | break; | ||
| 269 | } | ||
| 270 | dma_mask >>= 1; | ||
| 271 | } | ||
| 272 | |||
| 273 | if (rc) { | ||
| 274 | dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n", | ||
| 275 | &dma_mask); | ||
| 276 | goto post_drvdata_err; | ||
| 277 | } | ||
| 278 | |||
| 259 | rc = cc_clk_on(new_drvdata); | 279 | rc = cc_clk_on(new_drvdata); |
| 260 | if (rc) | 280 | if (rc) |
| 261 | goto post_drvdata_err; | 281 | goto post_drvdata_err; |
| 262 | 282 | ||
| 263 | if (!dev->dma_mask) | ||
| 264 | dev->dma_mask = &dev->coherent_dma_mask; | ||
| 265 | |||
| 266 | if (!dev->coherent_dma_mask) | ||
| 267 | dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN); | ||
| 268 | 283 | ||
| 269 | /* Verify correct mapping */ | 284 | /* Verify correct mapping */ |
| 270 | signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE)); | 285 | signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE)); |
