Skip to contentSkip to conversation

mmc: Add size for caller in init+register

PATCH Superseded Christian Daudt 3 participants 9 messages May 29, 2013

Subsystems (10)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 mmc: Add size for caller in init+register

Add a param to allow users of sdhci_pltfm to allocate private space in calls to sdhci_pltfm_init+sdhci_pltfm_register. This is implemented in the same way as sdhci does for its users.
None of the users have been migrated yet and are passing in zero to
retain their private allocation.

- todo: migrate clients to using allocation this way
- todo: remove priv variable once migration is complete

Also removed unused variable in sdhci_pltfm_init fn

drivers/mmc/host/sdhci-bcm2835.c +1 -1
index d49bc95..0584a1c 100644
@@ -148,7 +148,7 @@ static int bcm2835_sdhci_probe(struct platform_device *pdev)
 	struct sdhci_pltfm_host *pltfm_host;
 	int ret;
 
-	host = sdhci_pltfm_init(pdev, &bcm2835_sdhci_pdata);
+	host = sdhci_pltfm_init(pdev, &bcm2835_sdhci_pdata, 0);
 	if (IS_ERR(host))
 		return PTR_ERR(host);
 
drivers/mmc/host/sdhci-cns3xxx.c +1 -1
index 8ebb6b6..f2cc266 100644
@@ -96,7 +96,7 @@ static const struct sdhci_pltfm_data sdhci_cns3xxx_pdata = {
 
 static int sdhci_cns3xxx_probe(struct platform_device *pdev)
 {
-	return sdhci_pltfm_register(pdev, &sdhci_cns3xxx_pdata);
+	return sdhci_pltfm_register(pdev, &sdhci_cns3xxx_pdata, 0);
 }
 
 static int sdhci_cns3xxx_remove(struct platform_device *pdev)
drivers/mmc/host/sdhci-dove.c +1 -1
index 15e7803..8424839 100644
@@ -130,7 +130,7 @@ static int sdhci_dove_probe(struct platform_device *pdev)
 		gpio_direction_input(priv->gpio_cd);
 	}
 
-	host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata);
+	host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0);
 	if (IS_ERR(host)) {
 		ret = PTR_ERR(host);
 		goto err_sdhci_pltfm_init;
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index 67d6dde..9a1e6fa 100644
@@ -470,7 +470,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 	int err;
 	struct pltfm_imx_data *imx_data;
 
-	host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata);
+	host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata, 0);
 	if (IS_ERR(host))
 		return PTR_ERR(host);
 
drivers/mmc/host/sdhci-of-esdhc.c +1 -1
index 5e68adc..37e668f 100644
@@ -262,7 +262,7 @@ static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {
 
 static int sdhci_esdhc_probe(struct platform_device *pdev)
 {
-	return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata);
+	return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata, 0);
 }
 
 static int sdhci_esdhc_remove(struct platform_device *pdev)
drivers/mmc/host/sdhci-of-hlwd.c +1 -1
index 200a6a9..57c514a 100644
@@ -68,7 +68,7 @@ static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {
 
 static int sdhci_hlwd_probe(struct platform_device *pdev)
 {
-	return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata);
+	return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata, 0);
 }
 
 static int sdhci_hlwd_remove(struct platform_device *pdev)
drivers/mmc/host/sdhci-pltfm.c +9 -8
index cd0f1f6..38e38a5 100644
@@ -115,10 +115,10 @@ void sdhci_get_of_property(struct platform_device *pdev) {}
 EXPORT_SYMBOL_GPL(sdhci_get_of_property);
 
 struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
-				    const struct sdhci_pltfm_data *pdata)
+				    const struct sdhci_pltfm_data *pdata,
+				    size_t priv_size)
 {
 	struct sdhci_host *host;
-	struct sdhci_pltfm_host *pltfm_host;
 	struct device_node *np = pdev->dev.of_node;
 	struct resource *iomem;
 	int ret;
@@ -134,17 +134,17 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
 
 	/* Some PCI-based MFD need the parent here */
 	if (pdev->dev.parent != &platform_bus && !np)
-		host = sdhci_alloc_host(pdev->dev.parent, sizeof(*pltfm_host));
+		host = sdhci_alloc_host(pdev->dev.parent,
+			sizeof(struct sdhci_pltfm_host) + priv_size);
 	else
-		host = sdhci_alloc_host(&pdev->dev, sizeof(*pltfm_host));
+		host = sdhci_alloc_host(&pdev->dev,
+			sizeof(struct sdhci_pltfm_host) + priv_size);
 
 	if (IS_ERR(host)) {
 		ret = PTR_ERR(host);
 		goto err;
 	}
 
-	pltfm_host = sdhci_priv(host);
-
 	host->hw_name = dev_name(&pdev->dev);
 	if (pdata && pdata->ops)
 		host->ops = pdata->ops;
@@ -202,12 +202,13 @@ void sdhci_pltfm_free(struct platform_device *pdev)
 EXPORT_SYMBOL_GPL(sdhci_pltfm_free);
 
 int sdhci_pltfm_register(struct platform_device *pdev,
-			 const struct sdhci_pltfm_data *pdata)
+			const struct sdhci_pltfm_data *pdata,
+			size_t priv_size)
 {
 	struct sdhci_host *host;
 	int ret = 0;
 
-	host = sdhci_pltfm_init(pdev, pdata);
+	host = sdhci_pltfm_init(pdev, pdata, priv_size);
 	if (IS_ERR(host))
 		return PTR_ERR(host);
 
drivers/mmc/host/sdhci-pltfm.h +11 -2
index 1210ed1..ed4a85d 100644
@@ -27,6 +27,8 @@ struct sdhci_pltfm_host {
 	/* migrate from sdhci_of_host */
 	unsigned int clock;
 	u16 xfer_mode_shadow;
+
+	unsigned long private[0] ____cacheline_aligned;
 };
 
 #ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
@@ -91,15 +93,22 @@ static inline void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg)
 extern void sdhci_get_of_property(struct platform_device *pdev);
 
 extern struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
-					  const struct sdhci_pltfm_data *pdata);
+					  const struct sdhci_pltfm_data *pdata,
+					  size_t priv_size);
 extern void sdhci_pltfm_free(struct platform_device *pdev);
 
 extern int sdhci_pltfm_register(struct platform_device *pdev,
-				const struct sdhci_pltfm_data *pdata);
+				const struct sdhci_pltfm_data *pdata,
+				size_t priv_size);
 extern int sdhci_pltfm_unregister(struct platform_device *pdev);
 
 extern unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host);
 
+static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host)
+{
+	return (void *)host->private;
+}
+
 #ifdef CONFIG_PM
 extern const struct dev_pm_ops sdhci_pltfm_pmops;
 #define SDHCI_PLTFM_PMOPS (&sdhci_pltfm_pmops)
drivers/mmc/host/sdhci-pxav2.c +1 -1
index 6a3f702..1cf093f 100644
@@ -175,7 +175,7 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
 	if (!pxa)
 		return -ENOMEM;
 
-	host = sdhci_pltfm_init(pdev, NULL);
+	host = sdhci_pltfm_init(pdev, NULL, 0);
 	if (IS_ERR(host)) {
 		kfree(pxa);
 		return PTR_ERR(host);
drivers/mmc/host/sdhci-pxav3.c +1 -1
index 1ae358e..9124104 100644
@@ -230,7 +230,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
 	if (!pxa)
 		return -ENOMEM;
 
-	host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata);
+	host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata, 0);
 	if (IS_ERR(host)) {
 		kfree(pxa);
 		return PTR_ERR(host);
drivers/mmc/host/sdhci-tegra.c +1 -1
index e0dba74..c8b0582 100644
@@ -231,7 +231,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 		return -EINVAL;
 	soc_data = match->data;
 
-	host = sdhci_pltfm_init(pdev, soc_data->pdata);
+	host = sdhci_pltfm_init(pdev, soc_data->pdata, 0);
 	if (IS_ERR(host))
 		return PTR_ERR(host);
 	pltfm_host = sdhci_priv(host);
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v3 2/3 ARM: mmc: bcm281xx SDHCI driver

Add SDHCI driver for the Broadcom 281xx SoCs. Also add bindings for it into bcm281xx dts files. Still missing:
- power managemement

Changes from V2:
- Structure cleanups
- init space from sdhci_pltfm_init
- replace spinlock_irqsave with mutex on sd_card_emulate
- Reduce init_74_clocks delay and document it

Changes from V1:
- split DT into separate patch
- use gpio_is_valid instead of direct test
- switch pr_debug calls to dev_dbg
- use of_property_read_bool

arch/arm/configs/bcm_defconfig +7 -0
index e3bf2d6..65edf6d 100644
@@ -78,6 +78,13 @@ CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 # CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+CONFIG_MMC_UNSAFE_RESUME=y
+CONFIG_MMC_BLOCK_MINORS=32
+CONFIG_MMC_TEST=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_PLTFM=y
+CONFIG_MMC_SDHCI_BCM_KONA=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_TRIGGERS=y
drivers/mmc/host/Kconfig +11 -0
index 9ab8f8d..2455a35 100644
@@ -249,6 +249,17 @@ config MMC_SDHCI_S3C_DMA
 
 	  YMMV.
 
+config MMC_SDHCI_BCM_KONA
+	tristate "SDHCI support on Broadcom KONA platform"
+	depends on ARCH_BCM
+	select MMC_SDHCI_PLTFM
+	help
+	  This selects the Broadcom Kona Secure Digital Host Controller
+	  Interface(SDHCI) support.
+	  This is used in Broadcom mobile SoCs.
+
+	  If you have a controller with this interface, say Y or M here.
+
 config MMC_SDHCI_BCM2835
 	tristate "SDHCI platform support for the BCM2835 SD/MMC Controller"
 	depends on ARCH_BCM2835
drivers/mmc/host/Makefile +1 -0
index cd32280..cd4c845 100644
@@ -60,6 +60,7 @@ obj-$(CONFIG_MMC_SDHCI_DOVE)		+= sdhci-dove.o
 obj-$(CONFIG_MMC_SDHCI_TEGRA)		+= sdhci-tegra.o
 obj-$(CONFIG_MMC_SDHCI_OF_ESDHC)	+= sdhci-of-esdhc.o
 obj-$(CONFIG_MMC_SDHCI_OF_HLWD)		+= sdhci-of-hlwd.o
+obj-$(CONFIG_MMC_SDHCI_BCM_KONA)	+= sdhci-bcm-kona.o
 obj-$(CONFIG_MMC_SDHCI_BCM2835)		+= sdhci-bcm2835.o
 
 ifeq ($(CONFIG_CB710_DEBUG),y)
drivers/mmc/host/sdhci-bcm-kona.c new file +443 -0

443 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v3 2/3 ARM: mmc: bcm281xx SDHCI driver

drivers/mmc/host/sdhci-bcm-kona.c line 100

Quoted 11 lines · Christian Daudt
drivers/mmc/host/sdhci-bcm-kona.c new file +10 -0
+static int sdhci_bcm_kona_sd_reset(struct sdhci_host *host)
+{
 
+	/*
+	 * Back-to-Back register write needs a delay of 1ms at bootup (min 10uS)
+	 * Back-to-Back writes to same register needs delay when SD bus clock
+	 * is very low w.r.t AHB clock, mainly during boot-time and during card
+	 * insert-removal.
+	 */
+	mdelay(1);
+	sdhci_writel(host, val, KONA_SDHOST_CORECTRL);

This is now called always without spinlocks held and interrupts enabled, so it should really be msleep() not mdelay().

Quoted 12 lines
drivers/mmc/host/sdhci-bcm-kona.c new file +12 -0
+static void sdhci_bcm_kona_sd_init(struct sdhci_host *host)
+{
+	unsigned int val;
+
+	/* enable the interrupt from the IP core */
+	val = sdhci_readl(host, KONA_SDHOST_COREIMR);
+	val |= KONA_SDHOST_IP;
+	sdhci_writel(host, val, KONA_SDHOST_COREIMR);
+
+	/* Enable the AHB clock gating module to the host */
+	val = sdhci_readl(host, KONA_SDHOST_CORECTRL);
+	val |= KONA_SDHOST_EN;

drivers/mmc/host/sdhci-bcm-kona.c line 126

Quoted 10 lines
drivers/mmc/host/sdhci-bcm-kona.c new file +10 -0
+
+	/*
+	 * Back-to-Back register write needs a delay of 1ms at bootup (min 10uS)
+	 * Back-to-Back writes to same register needs delay when SD bus clock
+	 * is very low w.r.t AHB clock, mainly during boot-time and during card
+	 * insert-removal.
+	 */
+	mdelay(1);
+	sdhci_writel(host, val, KONA_SDHOST_CORECTRL);
+}

Same here.

Looks good aside from that.

Arnd

#3 lore raw

PATCH v3 3/3 ARM: mmc: bcm281xx SDHCI driver (dt mods)

In reply to Christian Daudt

Add SDHCI bindings for the Broadcom 281xx SoCs.

Changes from V2:
- Documentation cleanups

Changes from V1:
- split original patch into 2, one for driver and this one for dt

Documentation/devicetree/bindings/mmc/bcm,kona-sdhci.txt new file +16 -0
new file mode 100644
index 0000000..094ae01
@@ -0,0 +1,16 @@
+Broadcom BCM281xx SDHCI
+
+This file documents differences between the core properties in mmc.txt
+and the properties present in the bcm281xx SDHCI
+
+Required properties:
+- compatible : Should be "bcm,kona-sdhci"
+
+Example:
+
+sdio2: sdio at 0x3f1a0000 {
+	compatible = "bcm,kona-sdhci";
+	reg = <0x3f1a0000 0x10000>;
+	interrupts = <0x0 74 0x4>;
+};
+
arch/arm/boot/dts/bcm11351-brt.dts +17 -0
index 248067c..9ae3404 100644
@@ -27,4 +27,21 @@
 		status = "okay";
 	};
 
+	sdio0: sdio at 0x3f180000 {
+		max-frequency = <48000000>;
+		status = "okay";
+	};
+
+	sdio1: sdio at 0x3f190000 {
+		non-removable;
+		max-frequency = <48000000>;
+		status = "okay";
+	};
+
+	sdio3: sdio at 0x3f1b0000 {
+		max-frequency = <48000000>;
+		status = "okay";
+	};
+
+
 };
arch/arm/boot/dts/bcm11351.dtsi +28 -0
index 41b2c6c..39de6e2 100644
@@ -60,4 +60,32 @@
 		clock-frequency = <32768>;
 	};
 
+	sdio0: sdio at 0x3f180000 {
+		compatible = "bcm,kona-sdhci";
+		reg = <0x3f180000 0x10000>;
+		interrupts = <0x0 77 0x4>;
+		status = "disabled";
+	};
+
+	sdio1: sdio at 0x3f190000 {
+		compatible = "bcm,kona-sdhci";
+		reg = <0x3f190000 0x10000>;
+		interrupts = <0x0 76 0x4>;
+		status = "disabled";
+	};
+
+	sdio2: sdio at 0x3f1a0000 {
+		compatible = "bcm,kona-sdhci";
+		reg = <0x3f1a0000 0x10000>;
+		interrupts = <0x0 74 0x4>;
+		status = "disabled";
+	};
+
+	sdio3: sdio at 0x3f1b0000 {
+		compatible = "bcm,kona-sdhci";
+		reg = <0x3f1b0000 0x10000>;
+		interrupts = <0x0 73 0x4>;
+		status = "disabled";
+	};
+
 };
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH v3 3/3 ARM: mmc: bcm281xx SDHCI driver (dt mods)

arch/arm/boot/dts/bcm11351-brt.dts line 34

Quoted 5 lines · Christian Daudt
arch/arm/boot/dts/bcm11351-brt.dts +5 -0
+       sdio0: sdio at 0x3f180000 {
+               max-frequency = <48000000>;
+               status = "okay";
+       };
+

On a general note, there is no need to duplicate both the label and the name here, one of the two is enough. The easiest way to write this in a board file is

&sdio {
	max-frequency = <48000000>;
	status = "okay";
};

Your version is not wrong though, so

#5 lore raw

PATCH v3 1/3 mmc: Add size for caller in init+register

In reply to Christian Daudt
Quoted 6 lines · Christian Daudt

Add a param to allow users of sdhci_pltfm to allocate private space in calls to sdhci_pltfm_init+sdhci_pltfm_register. This is implemented in the same way as sdhci does for its users.
None of the users have been migrated yet and are passing in zero to
retain their private allocation.

Quoted 6 lines

- todo: migrate clients to using allocation this way
- todo: remove priv variable once migration is complete

Also removed unused variable in sdhci_pltfm_init fn

Hi Christian,

Sorry if being a bit picky, do you mind using "mmc: sdhci" as the prefix for the heading of this patch?

Quoted 139 lines
drivers/mmc/host/sdhci-bcm2835.c +1 -1
index d49bc95..0584a1c 100644
@@ -148,7 +148,7 @@ static int bcm2835_sdhci_probe(struct platform_device *pdev)
        struct sdhci_pltfm_host *pltfm_host;
        int ret;
 
-       host = sdhci_pltfm_init(pdev, &bcm2835_sdhci_pdata);
+       host = sdhci_pltfm_init(pdev, &bcm2835_sdhci_pdata, 0);
        if (IS_ERR(host))
                return PTR_ERR(host);
 
drivers/mmc/host/sdhci-cns3xxx.c +1 -1
index 8ebb6b6..f2cc266 100644
@@ -96,7 +96,7 @@ static const struct sdhci_pltfm_data sdhci_cns3xxx_pdata = {
 
 static int sdhci_cns3xxx_probe(struct platform_device *pdev)
 {
-       return sdhci_pltfm_register(pdev, &sdhci_cns3xxx_pdata);
+       return sdhci_pltfm_register(pdev, &sdhci_cns3xxx_pdata, 0);
 }
 
 static int sdhci_cns3xxx_remove(struct platform_device *pdev)
drivers/mmc/host/sdhci-dove.c +1 -1
index 15e7803..8424839 100644
@@ -130,7 +130,7 @@ static int sdhci_dove_probe(struct platform_device *pdev)
                gpio_direction_input(priv->gpio_cd);
        }
 
-       host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata);
+       host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0);
        if (IS_ERR(host)) {
                ret = PTR_ERR(host);
                goto err_sdhci_pltfm_init;
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index 67d6dde..9a1e6fa 100644
@@ -470,7 +470,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
        int err;
        struct pltfm_imx_data *imx_data;
 
-       host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata);
+       host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata, 0);
        if (IS_ERR(host))
                return PTR_ERR(host);
 
drivers/mmc/host/sdhci-of-esdhc.c +1 -1
index 5e68adc..37e668f 100644
@@ -262,7 +262,7 @@ static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {
 
 static int sdhci_esdhc_probe(struct platform_device *pdev)
 {
-       return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata);
+       return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata, 0);
 }
 
 static int sdhci_esdhc_remove(struct platform_device *pdev)
drivers/mmc/host/sdhci-of-hlwd.c +1 -1
index 200a6a9..57c514a 100644
@@ -68,7 +68,7 @@ static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {
 
 static int sdhci_hlwd_probe(struct platform_device *pdev)
 {
-       return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata);
+       return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata, 0);
 }
 
 static int sdhci_hlwd_remove(struct platform_device *pdev)
drivers/mmc/host/sdhci-pltfm.c +9 -8
index cd0f1f6..38e38a5 100644
@@ -115,10 +115,10 @@ void sdhci_get_of_property(struct platform_device *pdev) {}
 EXPORT_SYMBOL_GPL(sdhci_get_of_property);
 
 struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
-                                   const struct sdhci_pltfm_data *pdata)
+                                   const struct sdhci_pltfm_data *pdata,
+                                   size_t priv_size)
 {
        struct sdhci_host *host;
-       struct sdhci_pltfm_host *pltfm_host;
        struct device_node *np = pdev->dev.of_node;
        struct resource *iomem;
        int ret;
@@ -134,17 +134,17 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
 
        /* Some PCI-based MFD need the parent here */
        if (pdev->dev.parent != &platform_bus && !np)
-               host = sdhci_alloc_host(pdev->dev.parent, sizeof(*pltfm_host));
+               host = sdhci_alloc_host(pdev->dev.parent,
+                       sizeof(struct sdhci_pltfm_host) + priv_size);
        else
-               host = sdhci_alloc_host(&pdev->dev, sizeof(*pltfm_host));
+               host = sdhci_alloc_host(&pdev->dev,
+                       sizeof(struct sdhci_pltfm_host) + priv_size);
 
        if (IS_ERR(host)) {
                ret = PTR_ERR(host);
                goto err;
        }
 
-       pltfm_host = sdhci_priv(host);
-
        host->hw_name = dev_name(&pdev->dev);
        if (pdata && pdata->ops)
                host->ops = pdata->ops;
@@ -202,12 +202,13 @@ void sdhci_pltfm_free(struct platform_device *pdev)
 EXPORT_SYMBOL_GPL(sdhci_pltfm_free);
 
 int sdhci_pltfm_register(struct platform_device *pdev,
-                        const struct sdhci_pltfm_data *pdata)
+                       const struct sdhci_pltfm_data *pdata,
+                       size_t priv_size)
 {
        struct sdhci_host *host;
        int ret = 0;
 
-       host = sdhci_pltfm_init(pdev, pdata);
+       host = sdhci_pltfm_init(pdev, pdata, priv_size);
        if (IS_ERR(host))
                return PTR_ERR(host);
 
drivers/mmc/host/sdhci-pltfm.h +0 -0
index 1210ed1..ed4a85d 100644

drivers/mmc/host/sdhci-pltfm.h struct sdhci_pltfm_host { · line 31

Quoted 5 lines
drivers/mmc/host/sdhci-pltfm.h +2 -0
@@ -27,6 +27,8 @@ struct sdhci_pltfm_host {
        /* migrate from sdhci_of_host */
        unsigned int clock;
        u16 xfer_mode_shadow;
+
+       unsigned long private[0] ____cacheline_aligned;

Why do you need this to be "____cacheline_aligned"?

Quoted 72 lines
drivers/mmc/host/sdhci-pltfm.h +9 -2
 };
 
 #ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
@@ -91,15 +93,22 @@ static inline void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg)
 extern void sdhci_get_of_property(struct platform_device *pdev);
 
 extern struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
-                                         const struct sdhci_pltfm_data *pdata);
+                                         const struct sdhci_pltfm_data *pdata,
+                                         size_t priv_size);
 extern void sdhci_pltfm_free(struct platform_device *pdev);
 
 extern int sdhci_pltfm_register(struct platform_device *pdev,
-                               const struct sdhci_pltfm_data *pdata);
+                               const struct sdhci_pltfm_data *pdata,
+                               size_t priv_size);
 extern int sdhci_pltfm_unregister(struct platform_device *pdev);
 
 extern unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host);
 
+static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host)
+{
+       return (void *)host->private;
+}
+
 #ifdef CONFIG_PM
 extern const struct dev_pm_ops sdhci_pltfm_pmops;
 #define SDHCI_PLTFM_PMOPS (&sdhci_pltfm_pmops)
drivers/mmc/host/sdhci-pxav2.c +1 -1
index 6a3f702..1cf093f 100644
@@ -175,7 +175,7 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
        if (!pxa)
                return -ENOMEM;
 
-       host = sdhci_pltfm_init(pdev, NULL);
+       host = sdhci_pltfm_init(pdev, NULL, 0);
        if (IS_ERR(host)) {
                kfree(pxa);
                return PTR_ERR(host);
drivers/mmc/host/sdhci-pxav3.c +1 -1
index 1ae358e..9124104 100644
@@ -230,7 +230,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
        if (!pxa)
                return -ENOMEM;
 
-       host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata);
+       host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata, 0);
        if (IS_ERR(host)) {
                kfree(pxa);
                return PTR_ERR(host);
drivers/mmc/host/sdhci-tegra.c +1 -2
index e0dba74..c8b0582 100644
@@ -231,7 +231,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
                return -EINVAL;
        soc_data = match->data;
 
-       host = sdhci_pltfm_init(pdev, soc_data->pdata);
+       host = sdhci_pltfm_init(pdev, soc_data->pdata, 0);
        if (IS_ERR(host))
                return PTR_ERR(host);
        pltfm_host = sdhci_priv(host);
--

1.7.10.4

Quoted 4 lines

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Kind regards
Ulf Hansson

#6 lore raw

PATCH v3 1/3 mmc: Add size for caller in init+register

Quoted 4 lines · Ulf Hansson
Quoted 4 lines
drivers/mmc/host/sdhci-pltfm.h +0 -0
index 1210ed1..ed4a85d 100644
Quoted 8 lines

drivers/mmc/host/sdhci-pltfm.h struct sdhci_pltfm_host { · line 31

Quoted 6 lines
drivers/mmc/host/sdhci-pltfm.h +2 -0
@@ -27,6 +27,8 @@ struct sdhci_pltfm_host {
        /* migrate from sdhci_of_host */
        unsigned int clock;
        u16 xfer_mode_shadow;
+
+       unsigned long private[0] ____cacheline_aligned;

Why do you need this to be "____cacheline_aligned"?

This is common practice for additional members in data structures like this. The reason is that we append a structure which may have larger alignment requirements than 'unsigned long'.

The kmalloc function generally returns a cache line aligned object, so this provides the same alignment that we get with a separate allocation.

Arnd

#7 lore raw

PATCH v3 1/3 mmc: Add size for caller in init+register

Quoted 18 lines · Arnd Bergmann
Quoted 4 lines · Ulf Hansson
Quoted 4 lines
drivers/mmc/host/sdhci-pltfm.h +0 -0
index 1210ed1..ed4a85d 100644
Quoted 8 lines

drivers/mmc/host/sdhci-pltfm.h struct sdhci_pltfm_host { · line 31

Quoted 6 lines
drivers/mmc/host/sdhci-pltfm.h +2 -0
@@ -27,6 +27,8 @@ struct sdhci_pltfm_host {
        /* migrate from sdhci_of_host */
        unsigned int clock;
        u16 xfer_mode_shadow;
+
+       unsigned long private[0] ____cacheline_aligned;

Why do you need this to be "____cacheline_aligned"?

This is common practice for additional members in data structures like this. The reason is that we append a structure which may have larger alignment requirements than 'unsigned long'.

Quoted 6 lines

The kmalloc function generally returns a cache line aligned object, so this provides the same alignment that we get with a separate allocation.

Arnd

Arnd, thanks for the explanation!

Quoted 4 lines

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#8 lore raw

PATCH v3 1/3 mmc: Add size for caller in init+register

In reply to Christian Daudt
Quoted 6 lines · Christian Daudt

Add a param to allow users of sdhci_pltfm to allocate private space in calls to sdhci_pltfm_init+sdhci_pltfm_register. This is implemented in the same way as sdhci does for its users.
None of the users have been migrated yet and are passing in zero to
retain their private allocation.

Quoted 6 lines

- todo: migrate clients to using allocation this way
- todo: remove priv variable once migration is complete

Also removed unused variable in sdhci_pltfm_init fn