Skip to contentSkip to conversation

mmc: bcm2835: Add new driver for the sdhost controller

PATCH Applied Gerd Hoffmann 4 participants 25 messages Mar 8, 2017 – Mar 18, 2017

Subsystems (9)
lore
Share & tools
lore

Gerd Hoffmann

author maintainer
#0 lore raw

v4 cover mmc: bcm2835: Add new driver for the sdhost controller

Hi,

Next version if the bcm2835 sdhost patch series.

New in v4:
* squashed in more cleanups by Stefan.
* removed the long cleanup patch list
from commit message (patch 2).
* rebased to (and tested with) 4.11-rc1.
* minor fixes pointed out in review.

New in v3:
* squashed in cleanups by Stefan.
* use one dma channel only.
* improve commit messages.

New in v2:
* DMA fixed.
* updated docs (kconfig, file comment, commit message) clarifying the two sd controller situation.
* some code cleanups, as pointed out by Stefan.
* dt bindings use mmc at ... now.
* added patches to update defconfigs.
* added patch for rpi3 device tree, so wifi is actually enabled.

please review & test,
Gerd

Eric Anholt (2):
dt-bindings: Add binding for brcm,bcm2835-sdhost.
mmc: bcm2835: Add new driver for the sdhost controller.

Gerd Hoffmann (5):
mmc: bcm2835: add sdhost controller to devicetree
arm: set CONFIG_MMC_BCM2835=y in bcm2835_defconfig and
multi_v7_defconfig
arm64: set CONFIG_MMC_BCM2835=y in defconfig
arm: dts: bcm283x: switch from &sdhci to &sdhost
arm64: dts: bcm2837: add &sdhci and &sdhost

 .../bindings/mmc/brcm,bcm2835-sdhost.txt           |   23 +
 arch/arm/boot/dts/bcm2835-rpi.dtsi                 |    6 +
 arch/arm/boot/dts/bcm283x.dtsi                     |   10 +
 arch/arm/configs/bcm2835_defconfig                 |    1 +
 arch/arm/configs/multi_v7_defconfig                |    1 +
 arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts   |   17 +
 arch/arm64/configs/defconfig                       |    1 +
 drivers/mmc/host/Kconfig                           |   14 +
 drivers/mmc/host/Makefile                          |    1 +
 drivers/mmc/host/bcm2835.c                         | 1465 ++++++++++++++++++++
 10 files changed, 1539 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/brcm,bcm2835-sdhost.txt
 create mode 100644 drivers/mmc/host/bcm2835.c
Signature · 1 line
1.8.3.1
author maintainer
#1 lore raw

PATCH v4 1/7 dt-bindings: Add binding for brcm,bcm2835-sdhost.

From: Eric Anholt <[email protected]>

This is the other SD controller on the platform, which can be swapped to the role of SD card host using pin muxing.

---
 .../bindings/mmc/brcm,bcm2835-sdhost.txt           | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/brcm,bcm2835-sdhost.txt
Documentation/devicetree/bindings/mmc/brcm,bcm2835-sdhost.txt new file +23 -0
new file mode 100644
index 0000000..d876580
@@ -0,0 +1,23 @@
+Broadcom BCM2835 SDHOST controller
+
+This file documents differences between the core properties described
+by mmc.txt and the properties that represent the BCM2835 controller.
+
+Required properties:
+- compatible: Should be "brcm,bcm2835-sdhost".
+- clocks: The clock feeding the SDHOST controller.
+
+Optional properties:
+- dmas: DMA channel for read and write.
+          See Documentation/devicetree/bindings/dma/dma.txt for details
+
+Example:
+
+sdhost: mmc at 7e202000 {
+	compatible = "brcm,bcm2835-sdhost";
+	reg = <0x7e202000 0x100>;
+	interrupts = <2 24>;
+	clocks = <&clocks BCM2835_CLOCK_VPU>;
+	dmas = <&dma 13>;
+	dma-names = "rx-tx";
+};
Signature · 1 line
1.8.3.1
author maintainer
#2 lore raw

PATCH 1/4 qxl: drop mode_info.modes & related code.

In reply to Gerd Hoffmann

very old qxl hardware revisions (predating qxl ksm support by a few years) supported a fixed list of video modes only. The list is still provided by the virtual hardware, for backward compatibility reasons.

The qxl kms driver never ever looks at it, except for dumping it to the kernel log at load time in case debug logging is enabled. Drop that pointless code.

---
 drivers/gpu/drm/qxl/qxl_drv.h |  2 --
 drivers/gpu/drm/qxl/qxl_kms.c | 22 ----------------------
 2 files changed, 24 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -2
index 0c313e5..fe90b36 100644
@@ -160,8 +160,6 @@ struct qxl_mman {
 };
 
 struct qxl_mode_info {
-	int num_modes;
-	struct qxl_mode *modes;
 	bool mode_config_initialized;
 
 	/* pointer to fbdev info structure */
drivers/gpu/drm/qxl/qxl_kms.c +0 -22
index 2b1e1f3..a9a741c 100644
@@ -31,19 +31,9 @@
 
 int qxl_log_level;
 
-static void qxl_dump_mode(struct qxl_device *qdev, void *p)
-{
-	struct qxl_mode *m = p;
-	DRM_DEBUG_KMS("%d: %dx%d %d bits, stride %d, %dmm x %dmm, orientation %d\n",
-		      m->id, m->x_res, m->y_res, m->bits, m->stride, m->x_mili,
-		      m->y_mili, m->orientation);
-}
-
 static bool qxl_check_device(struct qxl_device *qdev)
 {
 	struct qxl_rom *rom = qdev->rom;
-	int mode_offset;
-	int i;
 
 	if (rom->magic != 0x4f525851) {
 		DRM_ERROR("bad rom signature %x\n", rom->magic);
@@ -53,8 +43,6 @@ static bool qxl_check_device(struct qxl_device *qdev)
 	DRM_INFO("Device Version %d.%d\n", rom->id, rom->update_id);
 	DRM_INFO("Compression level %d log level %d\n", rom->compression_level,
 		 rom->log_level);
-	DRM_INFO("Currently using mode #%d, list at 0x%x\n",
-		 rom->mode, rom->modes_offset);
 	DRM_INFO("%d io pages at offset 0x%x\n",
 		 rom->num_io_pages, rom->pages_offset);
 	DRM_INFO("%d byte draw area at offset 0x%x\n",
@@ -62,14 +50,6 @@ static bool qxl_check_device(struct qxl_device *qdev)
 
 	qdev->vram_size = rom->surface0_area_size;
 	DRM_INFO("RAM header offset: 0x%x\n", rom->ram_header_offset);
-
-	mode_offset = rom->modes_offset / 4;
-	qdev->mode_info.num_modes = ((u32 *)rom)[mode_offset];
-	DRM_INFO("rom modes offset 0x%x for %d modes\n", rom->modes_offset,
-		 qdev->mode_info.num_modes);
-	qdev->mode_info.modes = (void *)((uint32_t *)rom + mode_offset + 1);
-	for (i = 0; i < qdev->mode_info.num_modes; i++)
-		qxl_dump_mode(qdev, qdev->mode_info.modes + i);
 	return true;
 }
 
@@ -282,7 +262,5 @@ void qxl_device_fini(struct qxl_device *qdev)
 	iounmap(qdev->ram_header);
 	iounmap(qdev->rom);
 	qdev->rom = NULL;
-	qdev->mode_info.modes = NULL;
-	qdev->mode_info.num_modes = 0;
 	qxl_debugfs_remove_files(qdev);
 }
Signature · 1 line
1.8.3.1
author maintainer
#3 lore raw

PATCH 1/4 qxl: drop mode_info.modes & related code.

In reply to Gerd Hoffmann

very old qxl hardware revisions (predating qxl ksm support by a few years) supported a fixed list of video modes only. The list is still provided by the virtual hardware, for backward compatibility reasons.

The qxl kms driver never ever looks at it, except for dumping it to the kernel log at load time in case debug logging is enabled. Drop that pointless code.

---
 drivers/gpu/drm/qxl/qxl_drv.h |  2 --
 drivers/gpu/drm/qxl/qxl_kms.c | 22 ----------------------
 2 files changed, 24 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -2
index 0c313e5..fe90b36 100644
@@ -160,8 +160,6 @@ struct qxl_mman {
 };
 
 struct qxl_mode_info {
-	int num_modes;
-	struct qxl_mode *modes;
 	bool mode_config_initialized;
 
 	/* pointer to fbdev info structure */
drivers/gpu/drm/qxl/qxl_kms.c +0 -22
index 2b1e1f3..a9a741c 100644
@@ -31,19 +31,9 @@
 
 int qxl_log_level;
 
-static void qxl_dump_mode(struct qxl_device *qdev, void *p)
-{
-	struct qxl_mode *m = p;
-	DRM_DEBUG_KMS("%d: %dx%d %d bits, stride %d, %dmm x %dmm, orientation %d\n",
-		      m->id, m->x_res, m->y_res, m->bits, m->stride, m->x_mili,
-		      m->y_mili, m->orientation);
-}
-
 static bool qxl_check_device(struct qxl_device *qdev)
 {
 	struct qxl_rom *rom = qdev->rom;
-	int mode_offset;
-	int i;
 
 	if (rom->magic != 0x4f525851) {
 		DRM_ERROR("bad rom signature %x\n", rom->magic);
@@ -53,8 +43,6 @@ static bool qxl_check_device(struct qxl_device *qdev)
 	DRM_INFO("Device Version %d.%d\n", rom->id, rom->update_id);
 	DRM_INFO("Compression level %d log level %d\n", rom->compression_level,
 		 rom->log_level);
-	DRM_INFO("Currently using mode #%d, list at 0x%x\n",
-		 rom->mode, rom->modes_offset);
 	DRM_INFO("%d io pages at offset 0x%x\n",
 		 rom->num_io_pages, rom->pages_offset);
 	DRM_INFO("%d byte draw area at offset 0x%x\n",
@@ -62,14 +50,6 @@ static bool qxl_check_device(struct qxl_device *qdev)
 
 	qdev->vram_size = rom->surface0_area_size;
 	DRM_INFO("RAM header offset: 0x%x\n", rom->ram_header_offset);
-
-	mode_offset = rom->modes_offset / 4;
-	qdev->mode_info.num_modes = ((u32 *)rom)[mode_offset];
-	DRM_INFO("rom modes offset 0x%x for %d modes\n", rom->modes_offset,
-		 qdev->mode_info.num_modes);
-	qdev->mode_info.modes = (void *)((uint32_t *)rom + mode_offset + 1);
-	for (i = 0; i < qdev->mode_info.num_modes; i++)
-		qxl_dump_mode(qdev, qdev->mode_info.modes + i);
 	return true;
 }
 
@@ -282,7 +262,5 @@ void qxl_device_fini(struct qxl_device *qdev)
 	iounmap(qdev->ram_header);
 	iounmap(qdev->rom);
 	qdev->rom = NULL;
-	qdev->mode_info.modes = NULL;
-	qdev->mode_info.num_modes = 0;
 	qxl_debugfs_remove_files(qdev);
 }
Signature · 1 line
1.8.3.1
author maintainer
#4 lore raw

PATCH v4 2/7 mmc: bcm2835: Add new driver for the sdhost controller.

In reply to Gerd Hoffmann

From: Eric Anholt <[email protected]>

The 2835 has two SD controllers: The Arasan sdhci controller (supported by the iproc driver) and a custom sdhost controller. This patch adds a driver for the latter.

The sdhci controller supports both sdcard and sdio. The sdhost controller supports the sdcard only, but has better performance. Also note that the rpi3 has sdio wifi, so driving the sdcard with the sdhost controller allows to use the sdhci controller for wifi support.

The configuration is done by devicetree via pin muxing. Both SD controller are available on the same pins (2 pin groups = pin 22 to 27 + pin 48 to 53). So it's possible to use both SD controllers at the same time with different pin groups.

The code was originally written by Phil Elwell in the downstream
Rasbperry Pi tree. In preparation for the upstream merge it was
cleaned up and the code base was moderized by Eric Anholt, Stefan Wahren and Gerd Hoffmann.

---
 drivers/mmc/host/Kconfig   |   14 +
 drivers/mmc/host/Makefile  |    1 +
 drivers/mmc/host/bcm2835.c | 1465 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1480 insertions(+)
 create mode 100644 drivers/mmc/host/bcm2835.c
drivers/mmc/host/Kconfig +14 -0
index f08691a..a638cd0 100644
@@ -799,6 +799,20 @@ config MMC_TOSHIBA_PCI
 	depends on PCI
 	help
 
+config MMC_BCM2835
+	tristate "Broadcom BCM2835 SDHOST MMC Controller support"
+	depends on ARCH_BCM2835 || COMPILE_TEST
+	depends on HAS_DMA
+	help
+	  This selects the BCM2835 SDHOST MMC controller. If you have
+	  a BCM2835 platform with SD or MMC devices, say Y or M here.
+
+	  Note that the BCM2835 has two SD controllers: The Arasan
+	  sdhci controller (supported by MMC_SDHCI_IPROC) and a custom
+	  sdhost controller (supported by this driver).
+
+	  If unsure, say N.
+
 config MMC_MTK
 	tristate "MediaTek SD/MMC Card Interface support"
 	depends on HAS_DMA
drivers/mmc/host/Makefile +1 -0
index 6d548c4..bc2c2e2 100644
@@ -59,6 +59,7 @@ obj-$(CONFIG_MMC_MOXART)	+= moxart-mmc.o
 obj-$(CONFIG_MMC_SUNXI)		+= sunxi-mmc.o
 obj-$(CONFIG_MMC_USDHI6ROL0)	+= usdhi6rol0.o
 obj-$(CONFIG_MMC_TOSHIBA_PCI)	+= toshsd.o
+obj-$(CONFIG_MMC_BCM2835)	+= bcm2835.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)	+= rtsx_pci_sdmmc.o
 obj-$(CONFIG_MMC_REALTEK_USB)	+= rtsx_usb_sdmmc.o
drivers/mmc/host/bcm2835.c new file +1465 -0

1,465 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author maintainer
#5 lore raw

PATCH 2/4 qxl: limit monitor config read retries

In reply to Gerd Hoffmann

When reading the monitor config fails, don't retry forever. If it fails ten times in a row just give up to avoid the driver hangs. Also add a small delay after each attempt, so the host has a chance to complete a partial update.

---
 drivers/gpu/drm/qxl/qxl_display.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +12 -8
index 2cd14be..2b99496 100644
@@ -157,19 +157,23 @@ static void qxl_update_offset_props(struct qxl_device *qdev)
 
 void qxl_display_read_client_monitors_config(struct qxl_device *qdev)
 {
-
 	struct drm_device *dev = &qdev->ddev;
-	int status;
+	int status, retries;
 
-	status = qxl_display_copy_rom_client_monitors_config(qdev);
-	while (status == MONITORS_CONFIG_BAD_CRC) {
-		qxl_io_log(qdev, "failed crc check for client_monitors_config,"
-				 " retrying\n");
+	for (retries = 0; retries < 10; retries++) {
 		status = qxl_display_copy_rom_client_monitors_config(qdev);
+		if (status != MONITORS_CONFIG_BAD_CRC)
+			break;
+		udelay(5);
+	}
+	if (status == MONITORS_CONFIG_BAD_CRC) {
+		qxl_io_log(qdev, "config: bad crc\n");
+		DRM_DEBUG_KMS("ignoring client monitors config: bad crc");
+		return;
 	}
 	if (status == MONITORS_CONFIG_UNCHANGED) {
-		qxl_io_log(qdev, "config unchanged\n");
-		DRM_DEBUG("ignoring unchanged client monitors config");
+		qxl_io_log(qdev, "config: unchanged\n");
+		DRM_DEBUG_KMS("ignoring client monitors config: unchanged");
 		return;
 	}
 
Signature · 1 line
1.8.3.1
author maintainer
#6 lore raw

PATCH 2/4 qxl: limit monitor config read retries

In reply to Gerd Hoffmann

When reading the monitor config fails, don't retry forever. If it fails ten times in a row just give up to avoid the driver hangs. Also add a small delay after each attempt, so the host has a chance to complete a partial update.

---
 drivers/gpu/drm/qxl/qxl_display.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +12 -8
index 2cd14be..2b99496 100644
@@ -157,19 +157,23 @@ static void qxl_update_offset_props(struct qxl_device *qdev)
 
 void qxl_display_read_client_monitors_config(struct qxl_device *qdev)
 {
-
 	struct drm_device *dev = &qdev->ddev;
-	int status;
+	int status, retries;
 
-	status = qxl_display_copy_rom_client_monitors_config(qdev);
-	while (status == MONITORS_CONFIG_BAD_CRC) {
-		qxl_io_log(qdev, "failed crc check for client_monitors_config,"
-				 " retrying\n");
+	for (retries = 0; retries < 10; retries++) {
 		status = qxl_display_copy_rom_client_monitors_config(qdev);
+		if (status != MONITORS_CONFIG_BAD_CRC)
+			break;
+		udelay(5);
+	}
+	if (status == MONITORS_CONFIG_BAD_CRC) {
+		qxl_io_log(qdev, "config: bad crc\n");
+		DRM_DEBUG_KMS("ignoring client monitors config: bad crc");
+		return;
 	}
 	if (status == MONITORS_CONFIG_UNCHANGED) {
-		qxl_io_log(qdev, "config unchanged\n");
-		DRM_DEBUG("ignoring unchanged client monitors config");
+		qxl_io_log(qdev, "config: unchanged\n");
+		DRM_DEBUG_KMS("ignoring client monitors config: unchanged");
 		return;
 	}
 
Signature · 1 line
1.8.3.1
author maintainer
#7 lore raw

PATCH v4 3/7 mmc: bcm2835: add sdhost controller to devicetree

In reply to Gerd Hoffmann
---
 arch/arm/boot/dts/bcm2835-rpi.dtsi |  6 ++++++
 arch/arm/boot/dts/bcm283x.dtsi     | 10 ++++++++++
 2 files changed, 16 insertions(+)
arch/arm/boot/dts/bcm2835-rpi.dtsi +6 -0
index 1e00a28..8b95832 100644
@@ -69,6 +69,12 @@
 	bus-width = <4>;
 };
 
+&sdhost {
+	pinctrl-names = "default";
+	pinctrl-0 = <&sdhost_gpio48>;
+	bus-width = <4>;
+};
+
 &pwm {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
arch/arm/boot/dts/bcm283x.dtsi +10 -0
index 9798bc9..19099a5 100644
@@ -350,6 +350,16 @@
 			arm,primecell-periphid = <0x00241011>;
 		};
 
+		sdhost: mmc at 7e202000 {
+			compatible = "brcm,bcm2835-sdhost";
+			reg = <0x7e202000 0x100>;
+			interrupts = <2 24>;
+			clocks = <&clocks BCM2835_CLOCK_VPU>;
+			dmas = <&dma 13>;
+			dma-names = "rx-tx";
+			status = "disabled";
+		};
+
 		i2s: i2s at 7e203000 {
 			compatible = "brcm,bcm2835-i2s";
 			reg = <0x7e203000 0x20>,
Signature · 1 line
1.8.3.1
author maintainer
#10 lore raw

PATCH 3/4 qxl: read monitors config at boot

In reply to Gerd Hoffmann

Try to read the client monitors config at driver load time, even without explicit notification. So in case that info was filled before the driver loaded and we've missed the notifications because of that the settings will still be used.

With that place we now have to take care to properly handle a empty client monitors config, so we don't trip over an uninitialized client monitors config.

---
 drivers/gpu/drm/qxl/qxl_display.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/qxl/qxl_display.c +5 -0
index 2b99496..cf99ace 100644
@@ -81,6 +81,10 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)
 			   qdev->rom->client_monitors_config_crc);
 		return MONITORS_CONFIG_BAD_CRC;
 	}
+	if (!num_monitors) {
+		DRM_DEBUG_KMS("no client monitors configured\n");
+		return status;
+	}
 	if (num_monitors > qdev->monitors_config->max_allowed) {
 		DRM_DEBUG_KMS("client monitors list will be truncated: %d < %d\n",
 			      qdev->monitors_config->max_allowed, num_monitors);
@@ -1192,6 +1196,7 @@ int qxl_modeset_init(struct qxl_device *qdev)
 		qdev_output_init(&qdev->ddev, i);
 	}
 
+	qxl_display_read_client_monitors_config(qdev);
 	qdev->mode_info.mode_config_initialized = true;
 
 	drm_mode_config_reset(&qdev->ddev);
Signature · 1 line
1.8.3.1
author maintainer
#11 lore raw

PATCH 3/4 qxl: read monitors config at boot

In reply to Gerd Hoffmann

Try to read the client monitors config at driver load time, even without explicit notification. So in case that info was filled before the driver loaded and we've missed the notifications because of that the settings will still be used.

With that place we now have to take care to properly handle a empty client monitors config, so we don't trip over an uninitialized client monitors config.

---
 drivers/gpu/drm/qxl/qxl_display.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/qxl/qxl_display.c +5 -0
index 2b99496..cf99ace 100644
@@ -81,6 +81,10 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)
 			   qdev->rom->client_monitors_config_crc);
 		return MONITORS_CONFIG_BAD_CRC;
 	}
+	if (!num_monitors) {
+		DRM_DEBUG_KMS("no client monitors configured\n");
+		return status;
+	}
 	if (num_monitors > qdev->monitors_config->max_allowed) {
 		DRM_DEBUG_KMS("client monitors list will be truncated: %d < %d\n",
 			      qdev->monitors_config->max_allowed, num_monitors);
@@ -1192,6 +1196,7 @@ int qxl_modeset_init(struct qxl_device *qdev)
 		qdev_output_init(&qdev->ddev, i);
 	}
 
+	qxl_display_read_client_monitors_config(qdev);
 	qdev->mode_info.mode_config_initialized = true;
 
 	drm_mode_config_reset(&qdev->ddev);
Signature · 1 line
1.8.3.1
author maintainer
#12 lore raw

PATCH v4 4/7 arm: set CONFIG_MMC_BCM2835=y in bcm2835_defconfig and multi_v7_defconfig

In reply to Gerd Hoffmann

We need to enable this controller so that we can switch the SD card's pinmux over to it by default, which will improve storage performance.

Read access (dd with 64k blocks on rpi2):
CONFIG_MMC_SDHCI_IPROC: 11-12 MB/s
CONFIG_MMC_BCM2835: 19-20 MB/s

Differences on write access are pretty much in the noise.

---
 arch/arm/configs/bcm2835_defconfig  | 1 +
 arch/arm/configs/multi_v7_defconfig | 1 +
 2 files changed, 2 insertions(+)
arch/arm/configs/bcm2835_defconfig +1 -0
index 4b89f4e..3767c24 100644
@@ -92,6 +92,7 @@ CONFIG_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SDHCI_IPROC=y
+CONFIG_MMC_BCM2835=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
arch/arm/configs/multi_v7_defconfig +1 -0
index a94126f..63b94d0 100644
@@ -730,6 +730,7 @@ CONFIG_MMC_DW_EXYNOS=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SH_MMCIF=y
 CONFIG_MMC_SUNXI=y
+CONFIG_MMC_BCM2835=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_CLASS_FLASH=m
Signature · 1 line
1.8.3.1
author maintainer
#14 lore raw

PATCH 4/4 qxl: fix qxl_conn_get_modes

In reply to Gerd Hoffmann

Call qxl_add_monitors_config_modes() unconditionally. Do all sanity checks in that function.

Fix sanity checks. monitors_config is the current monitor configuration, whereas client_monitors_config is the configuration requested by the spice client. So when filling the mode list, based on the spice client request, we need to look at client_monitors_config->count not monitors_config->count.

---
 drivers/gpu/drm/qxl/qxl_display.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +12 -10
index cf99ace..9548bb5 100644
@@ -202,9 +202,17 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector,
 	struct drm_display_mode *mode = NULL;
 	struct qxl_head *head;
 
+	if (!qdev->monitors_config)
+		return 0;
+	if (h >= qdev->monitors_config->max_allowed)
+		return 0;
 	if (!qdev->client_monitors_config)
 		return 0;
+	if (h >= qdev->client_monitors_config->count)
+		return 0;
+
 	head = &qdev->client_monitors_config->heads[h];
+	DRM_DEBUG_KMS("head %d is %dx%d\n", h, head->width, head->height);
 
 	mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false,
 			    false);
@@ -911,19 +919,13 @@ static void qxl_enc_mode_set(struct drm_encoder *encoder,
 
 static int qxl_conn_get_modes(struct drm_connector *connector)
 {
-	int ret = 0;
-	struct qxl_device *qdev = connector->dev->dev_private;
 	unsigned pwidth = 1024;
 	unsigned pheight = 768;
+	int ret = 0;
 
-	DRM_DEBUG_KMS("monitors_config=%p\n", qdev->monitors_config);
-	/* TODO: what should we do here? only show the configured modes for the
-	 * device, or allow the full list, or both? */
-	if (qdev->monitors_config && qdev->monitors_config->count) {
-		ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
-		if (ret < 0)
-			return ret;
-	}
+	ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
+	if (ret < 0)
+		return ret;
 	ret += qxl_add_common_modes(connector, pwidth, pheight);
 	return ret;
 }
Signature · 1 line
1.8.3.1
author maintainer
#15 lore raw

PATCH 4/4 qxl: fix qxl_conn_get_modes

In reply to Gerd Hoffmann

Call qxl_add_monitors_config_modes() unconditionally. Do all sanity checks in that function.

Fix sanity checks. monitors_config is the current monitor configuration, whereas client_monitors_config is the configuration requested by the spice client. So when filling the mode list, based on the spice client request, we need to look at client_monitors_config->count not monitors_config->count.

---
 drivers/gpu/drm/qxl/qxl_display.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +12 -10
index cf99ace..9548bb5 100644
@@ -202,9 +202,17 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector,
 	struct drm_display_mode *mode = NULL;
 	struct qxl_head *head;
 
+	if (!qdev->monitors_config)
+		return 0;
+	if (h >= qdev->monitors_config->max_allowed)
+		return 0;
 	if (!qdev->client_monitors_config)
 		return 0;
+	if (h >= qdev->client_monitors_config->count)
+		return 0;
+
 	head = &qdev->client_monitors_config->heads[h];
+	DRM_DEBUG_KMS("head %d is %dx%d\n", h, head->width, head->height);
 
 	mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false,
 			    false);
@@ -911,19 +919,13 @@ static void qxl_enc_mode_set(struct drm_encoder *encoder,
 
 static int qxl_conn_get_modes(struct drm_connector *connector)
 {
-	int ret = 0;
-	struct qxl_device *qdev = connector->dev->dev_private;
 	unsigned pwidth = 1024;
 	unsigned pheight = 768;
+	int ret = 0;
 
-	DRM_DEBUG_KMS("monitors_config=%p\n", qdev->monitors_config);
-	/* TODO: what should we do here? only show the configured modes for the
-	 * device, or allow the full list, or both? */
-	if (qdev->monitors_config && qdev->monitors_config->count) {
-		ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
-		if (ret < 0)
-			return ret;
-	}
+	ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
+	if (ret < 0)
+		return ret;
 	ret += qxl_add_common_modes(connector, pwidth, pheight);
 	return ret;
 }
Signature · 1 line
1.8.3.1
author maintainer
#16 lore raw

PATCH v4 5/7 arm64: set CONFIG_MMC_BCM2835=y in defconfig

In reply to Gerd Hoffmann

We need to enable this controller so that we can switch the SD card's pinmux over to it by default, which will improve storage performance.

Read access (dd with 64k blocks on rpi2):
CONFIG_MMC_SDHCI_IPROC: 11-12 MB/s
CONFIG_MMC_BCM2835: 19-20 MB/s

Differences on write access are pretty much in the noise.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 7c48028..519a55c 100644
@@ -398,6 +398,7 @@ CONFIG_MMC_DW_EXYNOS=y
 CONFIG_MMC_DW_K3=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SUNXI=y
+CONFIG_MMC_BCM2835=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
Signature · 1 line
1.8.3.1
author maintainer
#19 lore raw

PATCH v4 6/7 arm: dts: bcm283x: switch from &sdhci to &sdhost

In reply to Gerd Hoffmann

sdcard access with the sdhost controller is faster.

Read access (dd with 64k blocks on rpi2):
CONFIG_MMC_SDHCI_IPROC: 11-12 MB/s
CONFIG_MMC_BCM2835: 19-20 MB/s

Differences on write access are pretty much in the noise.

---
 arch/arm/boot/dts/bcm2835-rpi.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/bcm2835-rpi.dtsi +1 -1
index 8b95832..e36c392 100644
@@ -65,13 +65,13 @@
 &sdhci {
 	pinctrl-names = "default";
 	pinctrl-0 = <&emmc_gpio48>;
-	status = "okay";
 	bus-width = <4>;
 };
 
 &sdhost {
 	pinctrl-names = "default";
 	pinctrl-0 = <&sdhost_gpio48>;
+	status = "okay";
 	bus-width = <4>;
 };
 
Signature · 1 line
1.8.3.1
author maintainer
#20 lore raw

PATCH v4 7/7 arm64: dts: bcm2837: add &sdhci and &sdhost

In reply to Gerd Hoffmann

For the raspberry pi 3 we'll need both sdhci (handles sdio wifi) and sdhost (handles sdcard).

---
 arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts +17 -0
index c309633..972f14d 100644
@@ -22,3 +22,20 @@
 &uart1 {
 	status = "okay";
 };
+
+/* SDHCI is used to control the SDIO for wireless */
+&sdhci {
+	pinctrl-names = "default";
+	pinctrl-0 = <&emmc_gpio34>;
+	status = "okay";
+	bus-width = <4>;
+	non-removable;
+};
+
+/* SDHOST is used to drive the SD card */
+&sdhost {
+	pinctrl-names = "default";
+	pinctrl-0 = <&sdhost_gpio48>;
+	status = "okay";
+	bus-width = <4>;
+};
Signature · 1 line
1.8.3.1
author maintainer
#21 lore raw
In reply to Gerd Hoffmann
Quoted 3 lines · Gerd Hoffmann

Hi,

Next version if the bcm2835 sdhost patch series.

Oops, had some stale qxl patch files laying around which got sent with this series by mistake. Just ignore these, and sorry for the spam.

cheers,
Gerd

Acked-by on v4 3/7
#8 lore raw

Re: [PATCH v4 3/7] mmc: bcm2835: add sdhost controller to devicetree

In reply to Gerd Hoffmann

Am 08.03.2017 um 10:19 schrieb Gerd Hoffmann:

Quoted 2 lines
Quoted 43 lines
---
  arch/arm/boot/dts/bcm2835-rpi.dtsi |  6 ++++++
  arch/arm/boot/dts/bcm283x.dtsi     | 10 ++++++++++
  2 files changed, 16 insertions(+)
arch/arm/boot/dts/bcm2835-rpi.dtsi +6 -0
index 1e00a28..8b95832 100644
@@ -69,6 +69,12 @@
  	bus-width = <4>;
  };
 
+&sdhost {
+	pinctrl-names = "default";
+	pinctrl-0 = <&sdhost_gpio48>;
+	bus-width = <4>;
+};
+
  &pwm {
  	pinctrl-names = "default";
  	pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
arch/arm/boot/dts/bcm283x.dtsi +10 -0
index 9798bc9..19099a5 100644
@@ -350,6 +350,16 @@
  			arm,primecell-periphid = <0x00241011>;
  		};
 
+		sdhost: mmc at 7e202000 {
+			compatible = "brcm,bcm2835-sdhost";
+			reg = <0x7e202000 0x100>;
+			interrupts = <2 24>;
+			clocks = <&clocks BCM2835_CLOCK_VPU>;
+			dmas = <&dma 13>;
+			dma-names = "rx-tx";
+			status = "disabled";
+		};
+
  		i2s: i2s at 7e203000 {
  			compatible = "brcm,bcm2835-i2s";
  			reg = <0x7e203000 0x20>,
#22 lore raw
In reply to Gerd Hoffmann
Quoted 3 lines · Gerd Hoffmann

Hi,

Next version if the bcm2835 sdhost patch series.

Still waiting for the subsystem maintainer to merge the driver before
merging the platform side.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170316/6438b326/attachment.sig>

#13 lore raw

PATCH v4 4/7 arm: set CONFIG_MMC_BCM2835=y in bcm2835_defconfig and multi_v7_defconfig

In reply to Gerd Hoffmann

-trimmed cc list

Quoted 10 lines · Gerd Hoffmann

We need to enable this controller so that we can switch the SD card's pinmux over to it by default, which will improve storage performance.

Read access (dd with 64k blocks on rpi2):
CONFIG_MMC_SDHCI_IPROC: 11-12 MB/s
CONFIG_MMC_BCM2835: 19-20 MB/s

Differences on write access are pretty much in the noise.

Normally this change should go via arm soc. However as the new CONFIG_MMC_BCM2835 is added in this series, perhaps it makes sense to that I pick it up. In such case I need an ack from some of the arm soc folkz, like Arnd/Olof.

Kind regards
Uffe

Quoted 32 lines
---
 arch/arm/configs/bcm2835_defconfig  | 1 +
 arch/arm/configs/multi_v7_defconfig | 1 +
 2 files changed, 2 insertions(+)
arch/arm/configs/bcm2835_defconfig +1 -0
index 4b89f4e..3767c24 100644
@@ -92,6 +92,7 @@ CONFIG_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SDHCI_IPROC=y
+CONFIG_MMC_BCM2835=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
arch/arm/configs/multi_v7_defconfig +1 -1
index a94126f..63b94d0 100644
@@ -730,6 +730,7 @@ CONFIG_MMC_DW_EXYNOS=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SH_MMCIF=y
 CONFIG_MMC_SUNXI=y
+CONFIG_MMC_BCM2835=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_CLASS_FLASH=m
--

1.8.3.1

#17 lore raw

PATCH v4 5/7 arm64: set CONFIG_MMC_BCM2835=y in defconfig

In reply to Gerd Hoffmann

- trimmed cc list

Quoted 27 lines · Gerd Hoffmann

We need to enable this controller so that we can switch the SD card's pinmux over to it by default, which will improve storage performance.

Read access (dd with 64k blocks on rpi2):
CONFIG_MMC_SDHCI_IPROC: 11-12 MB/s
CONFIG_MMC_BCM2835: 19-20 MB/s

Differences on write access are pretty much in the noise.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -1
index 7c48028..519a55c 100644
@@ -398,6 +398,7 @@ CONFIG_MMC_DW_EXYNOS=y
 CONFIG_MMC_DW_K3=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SUNXI=y
+CONFIG_MMC_BCM2835=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
--
Quoted 2 lines

1.8.3.1

Normally this change should go via the arm64 tree. However as the new CONFIG_MMC_BCM2835 is added in this series, perhaps it makes sense to that I pick it up. In such case I need an ack from some of the arm64 soc
folkz, like Catalin/Will.

Kind regards
Uffe

#9 lore raw

PATCH v4 3/7 mmc: bcm2835: add sdhost controller to devicetree

In reply to Gerd Hoffmann

- trimmed cc-list

Quoted 2 lines · Gerd Hoffmann

Again this is arm soc material. You need to change the prefix of the commit msg to also reflect that.

*If* I am going to pick this up I need acks.

Kind regards
Uffe

Quoted 46 lines
---
 arch/arm/boot/dts/bcm2835-rpi.dtsi |  6 ++++++
 arch/arm/boot/dts/bcm283x.dtsi     | 10 ++++++++++
 2 files changed, 16 insertions(+)
arch/arm/boot/dts/bcm2835-rpi.dtsi +6 -0
index 1e00a28..8b95832 100644
@@ -69,6 +69,12 @@
        bus-width = <4>;
 };
 
+&sdhost {
+       pinctrl-names = "default";
+       pinctrl-0 = <&sdhost_gpio48>;
+       bus-width = <4>;
+};
+
 &pwm {
        pinctrl-names = "default";
        pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
arch/arm/boot/dts/bcm283x.dtsi +10 -1
index 9798bc9..19099a5 100644
@@ -350,6 +350,16 @@
                        arm,primecell-periphid = <0x00241011>;
                };
 
+               sdhost: mmc at 7e202000 {
+                       compatible = "brcm,bcm2835-sdhost";
+                       reg = <0x7e202000 0x100>;
+                       interrupts = <2 24>;
+                       clocks = <&clocks BCM2835_CLOCK_VPU>;
+                       dmas = <&dma 13>;
+                       dma-names = "rx-tx";
+                       status = "disabled";
+               };
+
                i2s: i2s at 7e203000 {
                        compatible = "brcm,bcm2835-i2s";
                        reg = <0x7e203000 0x20>,
--

1.8.3.1

Applied
#24 lore raw
In reply to Gerd Hoffmann
Quoted 54 lines · Gerd Hoffmann

Hi,

Next version if the bcm2835 sdhost patch series.

New in v4:
* squashed in more cleanups by Stefan.
* removed the long cleanup patch list
from commit message (patch 2).
* rebased to (and tested with) 4.11-rc1.
* minor fixes pointed out in review.

New in v3:
* squashed in cleanups by Stefan.
* use one dma channel only.
* improve commit messages.

New in v2:
* DMA fixed.
* updated docs (kconfig, file comment, commit message) clarifying the two sd controller situation.
* some code cleanups, as pointed out by Stefan.
* dt bindings use mmc at ... now.
* added patches to update defconfigs.
* added patch for rpi3 device tree, so wifi is actually enabled.

please review & test,
Gerd

Eric Anholt (2):
dt-bindings: Add binding for brcm,bcm2835-sdhost.
mmc: bcm2835: Add new driver for the sdhost controller.

Gerd Hoffmann (5):
mmc: bcm2835: add sdhost controller to devicetree
arm: set CONFIG_MMC_BCM2835=y in bcm2835_defconfig and
multi_v7_defconfig
arm64: set CONFIG_MMC_BCM2835=y in defconfig
arm: dts: bcm283x: switch from &sdhci to &sdhost
arm64: dts: bcm2837: add &sdhci and &sdhost

 .../bindings/mmc/brcm,bcm2835-sdhost.txt           |   23 +
 arch/arm/boot/dts/bcm2835-rpi.dtsi                 |    6 +
 arch/arm/boot/dts/bcm283x.dtsi                     |   10 +
 arch/arm/configs/bcm2835_defconfig                 |    1 +
 arch/arm/configs/multi_v7_defconfig                |    1 +
 arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts   |   17 +
 arch/arm64/configs/defconfig                       |    1 +
 drivers/mmc/host/Kconfig                           |   14 +
 drivers/mmc/host/Makefile                          |    1 +
 drivers/mmc/host/bcm2835.c                         | 1465 ++++++++++++++++++++
 10 files changed, 1539 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/brcm,bcm2835-sdhost.txt
 create mode 100644 drivers/mmc/host/bcm2835.c
Quoted 3 lines

--
1.8.3.1

Thanks, applied patch1 and patch2 from the series.

Kind regards
Uffe

#23 lore raw
In reply to Eric Anholt
Quoted 8 lines · Eric Anholt
Quoted 3 lines · Gerd Hoffmann

Hi,

Next version if the bcm2835 sdhost patch series.

Still waiting for the subsystem maintainer to merge the driver before merging the platform side.

Ah, didn't notice this. So Eric, you will take care of the arm soc changes then. Great!

Kind regards
Uffe

#18 lore raw

Re: [PATCH v4 5/7] arm64: set CONFIG_MMC_BCM2835=y in defconfig

In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann

We need to enable this controller so that we can switch the SD card's pinmux over to it by default, which will improve storage performance.

Read access (dd with 64k blocks on rpi2):
CONFIG_MMC_SDHCI_IPROC: 11-12 MB/s
CONFIG_MMC_BCM2835: 19-20 MB/s

Differences on write access are pretty much in the noise.

Now that the driver has been merged, I've merged the platform patches up to this point.

Unfortunately, sending PRs to arm-soc that merge in branches from other
trees has failed in the past, so I won't be able to merge 6 and 7 for
4.12. That said, it's a whole lot less that the various downstream
kernels will need to pull for the Pi3 than they've been carrying around
until now :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170317/0bbbbd3d/attachment.sig>