042-0003-mtd-bcm47xxsflash-use-uncached-MMIO-access-for-BCM53.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 64ad46379fcf14f437553f654d1adcd3d0e0d7f9 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Mon, 15 Aug 2016 14:21:28 +0200
  4. Subject: [PATCH] mtd: bcm47xxsflash: use uncached MMIO access for BCM53573
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. BCM53573 is a new series of Broadcom's SoCs. It's based on ARM and uses
  9. this old ChipCommon-based flash access. Early tests resulted in flash
  10. corruptions that were tracked down to using cached MMIO for flash read
  11. access. Switch to ioremap_nocache conditionally to support BCM53573 and
  12. don't break performance on old MIPS devices.
  13. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  14. Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
  15. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
  16. ---
  17. drivers/mtd/devices/bcm47xxsflash.c | 24 +++++++++++++++++++-----
  18. 1 file changed, 19 insertions(+), 5 deletions(-)
  19. --- a/drivers/mtd/devices/bcm47xxsflash.c
  20. +++ b/drivers/mtd/devices/bcm47xxsflash.c
  21. @@ -296,16 +296,30 @@ static int bcm47xxsflash_bcma_probe(stru
  22. dev_err(dev, "can't request region for resource %pR\n", res);
  23. return -EBUSY;
  24. }
  25. - b47s->window = ioremap_cache(res->start, resource_size(res));
  26. - if (!b47s->window) {
  27. - dev_err(dev, "ioremap failed for resource %pR\n", res);
  28. - return -ENOMEM;
  29. - }
  30. b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
  31. b47s->cc_read = bcm47xxsflash_bcma_cc_read;
  32. b47s->cc_write = bcm47xxsflash_bcma_cc_write;
  33. + /*
  34. + * On old MIPS devices cache was magically invalidated when needed,
  35. + * allowing us to use cached access and gain some performance. Trying
  36. + * the same on ARM based BCM53573 results in flash corruptions, we need
  37. + * to use uncached access for it.
  38. + *
  39. + * It may be arch specific, but right now there is only 1 ARM SoC using
  40. + * this driver, so let's follow Broadcom's reference code and check
  41. + * ChipCommon revision.
  42. + */
  43. + if (b47s->bcma_cc->core->id.rev == 54)
  44. + b47s->window = ioremap_nocache(res->start, resource_size(res));
  45. + else
  46. + b47s->window = ioremap_cache(res->start, resource_size(res));
  47. + if (!b47s->window) {
  48. + dev_err(dev, "ioremap failed for resource %pR\n", res);
  49. + return -ENOMEM;
  50. + }
  51. +
  52. switch (b47s->bcma_cc->capabilities & BCMA_CC_CAP_FLASHT) {
  53. case BCMA_CC_FLASHT_STSER:
  54. b47s->type = BCM47XXSFLASH_TYPE_ST;