LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH 12/32] usb: gadget: fusb300_udc: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we can drop some
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/fusb300_udc.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c
index 8c2372f..798a25b 100644
--- a/drivers/usb/gadget/fusb300_udc.c
+++ b/drivers/usb/gadget/fusb300_udc.c
@@ -1422,15 +1422,12 @@ static int __init fusb300_probe(struct platform_device *pdev)
 
 	fusb300->gadget.ops = &fusb300_gadget_ops;
 
-	device_initialize(&fusb300->gadget.dev);
-
-	dev_set_name(&fusb300->gadget.dev, "gadget");
-
 	fusb300->gadget.max_speed = USB_SPEED_HIGH;
 	fusb300->gadget.dev.parent = &pdev->dev;
 	fusb300->gadget.dev.dma_mask = pdev->dev.dma_mask;
 	fusb300->gadget.dev.release = pdev->dev.release;
 	fusb300->gadget.name = udc_name;
+	fusb300->gadget.register_my_device = true;
 	fusb300->reg = reg;
 
 	ret = request_irq(ires->start, fusb300_irq, IRQF_SHARED,
@@ -1478,19 +1475,10 @@ static int __init fusb300_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_add_udc;
 
-	ret = device_add(&fusb300->gadget.dev);
-	if (ret) {
-		pr_err("device_add error (%d)\n", ret);
-		goto err_add_device;
-	}
-
 	dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);
 
 	return 0;
 
-err_add_device:
-	usb_del_gadget_udc(&fusb300->gadget);
-
 err_add_udc:
 	fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);
 
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 10/32] usb: gadget: fsl_qe_udc: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we can drop some
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/fsl_qe_udc.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index ec50f18..08c8432 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -2523,13 +2523,9 @@ static int qe_udc_probe(struct platform_device *ofdev)
 
 	/* name: Identifies the controller hardware type. */
 	udc->gadget.name = driver_name;
-
-	device_initialize(&udc->gadget.dev);
-
-	dev_set_name(&udc->gadget.dev, "gadget");
-
 	udc->gadget.dev.release = qe_udc_release;
 	udc->gadget.dev.parent = &ofdev->dev;
+	udc->gadget.register_my_device = true;
 
 	/* initialize qe_ep struct */
 	for (i = 0; i < USB_MAX_ENDPOINTS ; i++) {
@@ -2592,13 +2588,9 @@ static int qe_udc_probe(struct platform_device *ofdev)
 		goto err5;
 	}
 
-	ret = device_add(&udc->gadget.dev);
-	if (ret)
-		goto err6;
-
 	ret = usb_add_gadget_udc(&ofdev->dev, &udc->gadget);
 	if (ret)
-		goto err7;
+		goto err6;
 
 	dev_set_drvdata(&ofdev->dev, udc);
 	dev_info(udc->dev,
@@ -2606,8 +2598,6 @@ static int qe_udc_probe(struct platform_device *ofdev)
 			(udc->soc_type == PORT_QE) ? "QE" : "CPM");
 	return 0;
 
-err7:
-	device_unregister(&udc->gadget.dev);
 err6:
 	free_irq(udc->usb_irq, udc);
 err5:
@@ -2702,7 +2692,6 @@ static int qe_udc_remove(struct platform_device *ofdev)
 
 	iounmap(udc->usb_regs);
 
-	device_unregister(&udc->gadget.dev);
 	/* wait for release() of gadget.dev to free udc */
 	wait_for_completion(&done);
 
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 07/32] usb: gadget: atmel_usba_udc: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we can drop some
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/atmel_usba_udc.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index a7aed84..f0f9423 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1900,9 +1900,9 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 	dev_info(&pdev->dev, "FIFO at 0x%08lx mapped at %p\n",
 		 (unsigned long)fifo->start, udc->fifo);
 
-	device_initialize(&udc->gadget.dev);
 	udc->gadget.dev.parent = &pdev->dev;
 	udc->gadget.dev.dma_mask = pdev->dev.dma_mask;
+	udc->gadget.register_my_device = true;
 
 	platform_set_drvdata(pdev, udc);
 
@@ -1962,12 +1962,6 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 	}
 	udc->irq = irq;
 
-	ret = device_add(&udc->gadget.dev);
-	if (ret) {
-		dev_dbg(&pdev->dev, "Could not add gadget: %d\n", ret);
-		goto err_device_add;
-	}
-
 	if (gpio_is_valid(pdata->vbus_pin)) {
 		if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) {
 			udc->vbus_pin = pdata->vbus_pin;
@@ -2007,9 +2001,6 @@ err_add_udc:
 		gpio_free(udc->vbus_pin);
 	}
 
-	device_unregister(&udc->gadget.dev);
-
-err_device_add:
 	free_irq(irq, udc);
 err_request_irq:
 	kfree(usba_ep);
@@ -2053,8 +2044,6 @@ static int __exit usba_udc_remove(struct platform_device *pdev)
 	clk_put(udc->hclk);
 	clk_put(udc->pclk);
 
-	device_unregister(&udc->gadget.dev);
-
 	return 0;
 }
 
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 11/32] usb: gadget: fsl_udc_core: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we can drop some
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/fsl_udc_core.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 49642d4..b78b734 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -2526,9 +2526,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
 	udc_controller->gadget.dev.release = fsl_udc_release;
 	udc_controller->gadget.dev.parent = &pdev->dev;
 	udc_controller->gadget.dev.of_node = pdev->dev.of_node;
-	ret = device_register(&udc_controller->gadget.dev);
-	if (ret < 0)
-		goto err_free_irq;
+	udc_controller->gadget.register_my_device = true;
 
 	if (!IS_ERR_OR_NULL(udc_controller->transceiver))
 		udc_controller->gadget.is_otg = 1;
@@ -2561,7 +2559,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
 			DTD_ALIGNMENT, UDC_DMA_BOUNDARY);
 	if (udc_controller->td_pool == NULL) {
 		ret = -ENOMEM;
-		goto err_unregister;
+		goto err_free_irq;
 	}
 
 	ret = usb_add_gadget_udc(&pdev->dev, &udc_controller->gadget);
@@ -2573,8 +2571,6 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
 
 err_del_udc:
 	dma_pool_destroy(udc_controller->td_pool);
-err_unregister:
-	device_unregister(&udc_controller->gadget.dev);
 err_free_irq:
 	free_irq(udc_controller->irq, udc_controller);
 err_iounmap:
@@ -2624,7 +2620,6 @@ static int __exit fsl_udc_remove(struct platform_device *pdev)
 	if (pdata->operating_mode == FSL_USB2_DR_DEVICE)
 		release_mem_region(res->start, resource_size(res));
 
-	device_unregister(&udc_controller->gadget.dev);
 	/* free udc --wait for the release() finished */
 	wait_for_completion(&done);
 
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 09/32] usb: gadget: dummy_hcd: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we can drop some
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/dummy_hcd.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 95d584d..8155d4a 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -982,16 +982,10 @@ static int dummy_udc_probe(struct platform_device *pdev)
 	dum->gadget.name = gadget_name;
 	dum->gadget.ops = &dummy_ops;
 	dum->gadget.max_speed = USB_SPEED_SUPER;
+	dum->gadget.register_my_device = true;
 
-	dev_set_name(&dum->gadget.dev, "gadget");
 	dum->gadget.dev.parent = &pdev->dev;
 	dum->gadget.dev.release = dummy_gadget_release;
-	rc = device_register(&dum->gadget.dev);
-	if (rc < 0) {
-		put_device(&dum->gadget.dev);
-		return rc;
-	}
-
 	init_dummy_udc_hw(dum);
 
 	rc = usb_add_gadget_udc(&pdev->dev, &dum->gadget);
@@ -1007,7 +1001,6 @@ static int dummy_udc_probe(struct platform_device *pdev)
 err_dev:
 	usb_del_gadget_udc(&dum->gadget);
 err_udc:
-	device_unregister(&dum->gadget.dev);
 	return rc;
 }
 
@@ -1018,7 +1011,6 @@ static int dummy_udc_remove(struct platform_device *pdev)
 	usb_del_gadget_udc(&dum->gadget);
 	platform_set_drvdata(pdev, NULL);
 	device_remove_file(&dum->gadget.dev, &dev_attr_function);
-	device_unregister(&dum->gadget.dev);
 	return 0;
 }
 
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 00/32] usb: refactor gadget->dev registration
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel

Hi folks,

Please comment on this series as I need help testing it
on all UDC controllers so we can send it for v3.10 merge
window.

NOTE: I will queue this series for v3.10 merge window, so
make sure to test and comment.

cheers

Felipe Balbi (32):
  usb: gadget: udc-core: allow udc class register gadget device
  usb: dwc3: gadget: let udc-core manage gadget->dev
  usb: musb: gadget: let udc-core manage gadget-dev
  usb: gadget: omap_udc: let udc-core manage gadget->dev
  usb: gadget: amd5536udc: let udc-core manage gadget->dev
  usb: gadget: at91_udc: let udc-core manage gadget->dev
  usb: gadget: atmel_usba_udc: let udc-core manage gadget->dev
  usb: gadget: bcm63xx_udc: let udc-core manage gadget->dev
  usb: gadget: dummy_hcd: let udc-core manage gadget->dev
  usb: gadget: fsl_qe_udc: let udc-core manage gadget->dev
  usb: gadget: fsl_udc_core: let udc-core manage gadget->dev
  usb: gadget: fusb300_udc: let udc-core manage gadget->dev
  usb: gadget: goku_udc: let udc-core manage gadget->dev
  usb: gadget: imx_udc: let udc-core manage gadget->dev
  usb: gadget: lpc32xx_udc: let udc-core manage gadget->dev
  usb: gadget: m66592-udc: let udc-core manage gadget->dev
  usb: gadget: mv_u3d_core: let udc-core manage gadget->dev
  usb: gadget: mv_u3d_core: fix a compile warning
  usb: gadget: mv_udc_core: let udc-core manage gadget->dev
  usb: gadget: net2272: let udc-core manage gadget->dev
  usb: gadget: net2280: let udc-core manage gadget->dev
  usb: gadget: pch_udc: let udc-core manage gadget->dev
  usb: gadget: r8a66597-udc: let udc-core manage gadget->dev
  usb: gadget: s3c-hsotg: let udc-core manage gadget->dev
  usb: gadget: s3c-hsudc: let udc-core manage gadget->dev
  usb: gadget: s3c2410_udc: let udc-core manage gadget->dev
  usb: renesas_usbhs: gadget: let udc-core manage gadget->dev
  usb: gadget: pxa25x_udc: let udc-core manage gadget->dev
  usb: gadget: pxa27x_udc: let udc-core manage gadget->dev
  usb: chipidea: register debugging syfs on our device
  usb: chipidea: let udc-core manage gadget->dev
  usb: gadget: drop now unnecessary flag

 drivers/usb/chipidea/udc.c             | 18 ++++--------------
 drivers/usb/dwc3/gadget.c              | 16 +---------------
 drivers/usb/gadget/amd5536udc.c        |  8 --------
 drivers/usb/gadget/at91_udc.c          | 12 +-----------
 drivers/usb/gadget/atmel_usba_udc.c    | 12 ------------
 drivers/usb/gadget/bcm63xx_udc.c       |  6 ------
 drivers/usb/gadget/dummy_hcd.c         |  9 ---------
 drivers/usb/gadget/fsl_qe_udc.c        | 14 +-------------
 drivers/usb/gadget/fsl_udc_core.c      |  8 +-------
 drivers/usb/gadget/fusb300_udc.c       | 13 -------------
 drivers/usb/gadget/goku_udc.c          |  9 ---------
 drivers/usb/gadget/goku_udc.h          |  3 +--
 drivers/usb/gadget/imx_udc.c           | 12 ------------
 drivers/usb/gadget/lpc32xx_udc.c       | 10 ----------
 drivers/usb/gadget/m66592-udc.c        | 12 ------------
 drivers/usb/gadget/mv_u3d_core.c       | 11 +----------
 drivers/usb/gadget/mv_udc_core.c       | 11 +----------
 drivers/usb/gadget/net2272.c           |  9 +--------
 drivers/usb/gadget/net2280.c           |  4 ----
 drivers/usb/gadget/omap_udc.c          | 11 +++--------
 drivers/usb/gadget/pch_udc.c           |  9 ---------
 drivers/usb/gadget/pxa25x_udc.c        |  9 ---------
 drivers/usb/gadget/pxa27x_udc.c        |  8 --------
 drivers/usb/gadget/r8a66597-udc.c      | 11 +----------
 drivers/usb/gadget/s3c-hsotg.c         | 13 -------------
 drivers/usb/gadget/s3c-hsudc.c         | 10 ----------
 drivers/usb/gadget/s3c2410_udc.c       |  9 ---------
 drivers/usb/gadget/udc-core.c          | 20 ++++++++++++++++----
 drivers/usb/musb/musb_gadget.c         |  9 ---------
 drivers/usb/renesas_usbhs/mod_gadget.c | 10 +---------
 30 files changed, 33 insertions(+), 283 deletions(-)

-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply

* [RFC/PATCH 05/32] usb: gadget: amd5536udc: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we drop some boilerplate
code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/amd5536udc.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 3dac001..1827d4c 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3080,7 +3080,6 @@ static void udc_pci_remove(struct pci_dev *pdev)
 	if (dev->active)
 		pci_disable_device(pdev);
 
-	device_unregister(&dev->gadget.dev);
 	pci_set_drvdata(pdev, NULL);
 
 	udc_remove(dev);
@@ -3276,6 +3275,7 @@ static int udc_probe(struct udc *dev)
 	dev->gadget.dev.release = gadget_release;
 	dev->gadget.name = name;
 	dev->gadget.max_speed = USB_SPEED_HIGH;
+	dev->gadget.register_my_device = true;
 
 	/* init registers, interrupts, ... */
 	startup_registers(dev);
@@ -3301,13 +3301,6 @@ static int udc_probe(struct udc *dev)
 	if (retval)
 		goto finished;
 
-	retval = device_register(&dev->gadget.dev);
-	if (retval) {
-		usb_del_gadget_udc(&dev->gadget);
-		put_device(&dev->gadget.dev);
-		goto finished;
-	}
-
 	/* timer init */
 	init_timer(&udc_timer);
 	udc_timer.function = udc_timer_function;
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 02/32] usb: dwc3: gadget: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

We don't need to register that device ourselves
if we simply set gadget->register_my_device.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/dwc3/gadget.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 2e43b33..7002cf6 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2412,8 +2412,6 @@ int dwc3_gadget_init(struct dwc3 *dwc)
 		goto err3;
 	}
 
-	dev_set_name(&dwc->gadget.dev, "gadget");
-
 	dwc->gadget.ops			= &dwc3_gadget_ops;
 	dwc->gadget.max_speed		= USB_SPEED_SUPER;
 	dwc->gadget.speed		= USB_SPEED_UNKNOWN;
@@ -2425,6 +2423,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)
 	dwc->gadget.dev.dma_parms	= dwc->dev->dma_parms;
 	dwc->gadget.dev.dma_mask	= dwc->dev->dma_mask;
 	dwc->gadget.dev.release		= dwc3_gadget_release;
+	dwc->gadget.register_my_device	= true;
 	dwc->gadget.name		= "dwc3-gadget";
 
 	/*
@@ -2480,24 +2479,14 @@ int dwc3_gadget_init(struct dwc3 *dwc)
 		dwc3_gadget_usb3_phy_suspend(dwc, false);
 	}
 
-	ret = device_register(&dwc->gadget.dev);
-	if (ret) {
-		dev_err(dwc->dev, "failed to register gadget device\n");
-		put_device(&dwc->gadget.dev);
-		goto err6;
-	}
-
 	ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget);
 	if (ret) {
 		dev_err(dwc->dev, "failed to register udc\n");
-		goto err7;
+		goto err6;
 	}
 
 	return 0;
 
-err7:
-	device_unregister(&dwc->gadget.dev);
-
 err6:
 	dwc3_writel(dwc->regs, DWC3_DEVTEN, 0x00);
 	free_irq(irq, dwc);
@@ -2546,6 +2535,4 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
 
 	dma_free_coherent(dwc->dev, sizeof(*dwc->ctrl_req),
 			dwc->ctrl_req, dwc->ctrl_req_addr);
-
-	device_unregister(&dwc->gadget.dev);
 }
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 06/32] usb: gadget: at91_udc: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we can remove some
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/at91_udc.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 10f45fa..177b56d 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1726,6 +1726,7 @@ static int at91udc_probe(struct platform_device *pdev)
 
 	/* init software state */
 	udc = &controller;
+	udc->gadget.register_my_device = true;
 	udc->gadget.dev.parent = dev;
 	if (pdev->dev.of_node)
 		at91udc_of_init(udc, pdev->dev.of_node);
@@ -1780,13 +1781,7 @@ static int at91udc_probe(struct platform_device *pdev)
 		DBG("clocks missing\n");
 		retval = -ENODEV;
 		/* NOTE: we "know" here that refcounts on these are NOPs */
-		goto fail0b;
-	}
-
-	retval = device_register(&udc->gadget.dev);
-	if (retval < 0) {
-		put_device(&udc->gadget.dev);
-		goto fail0b;
+		goto fail1;
 	}
 
 	/* don't do anything until we have both gadget driver and VBUS */
@@ -1857,8 +1852,6 @@ fail3:
 fail2:
 	free_irq(udc->udp_irq, udc);
 fail1:
-	device_unregister(&udc->gadget.dev);
-fail0b:
 	iounmap(udc->udp_baseaddr);
 fail0a:
 	if (cpu_is_at91rm9200())
@@ -1892,8 +1885,6 @@ static int __exit at91udc_remove(struct platform_device *pdev)
 		gpio_free(udc->board.vbus_pin);
 	}
 	free_irq(udc->udp_irq, udc);
-	device_unregister(&udc->gadget.dev);
-
 	iounmap(udc->udp_baseaddr);
 
 	if (cpu_is_at91rm9200())
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 08/32] usb: gadget: bcm63xx_udc: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we can drop some
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/bcm63xx_udc.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/bcm63xx_udc.c b/drivers/usb/gadget/bcm63xx_udc.c
index 47a4993..10b0475 100644
--- a/drivers/usb/gadget/bcm63xx_udc.c
+++ b/drivers/usb/gadget/bcm63xx_udc.c
@@ -2367,13 +2367,13 @@ static int bcm63xx_udc_probe(struct platform_device *pdev)
 
 	spin_lock_init(&udc->lock);
 	INIT_WORK(&udc->ep0_wq, bcm63xx_ep0_process);
-	dev_set_name(&udc->gadget.dev, "gadget");
 
 	udc->gadget.ops = &bcm63xx_udc_ops;
 	udc->gadget.name = dev_name(dev);
 	udc->gadget.dev.parent = dev;
 	udc->gadget.dev.release = bcm63xx_udc_gadget_release;
 	udc->gadget.dev.dma_mask = dev->dma_mask;
+	udc->gadget.register_my_device = true;
 
 	if (!pd->use_fullspeed && !use_fullspeed)
 		udc->gadget.max_speed = USB_SPEED_HIGH;
@@ -2413,10 +2413,6 @@ static int bcm63xx_udc_probe(struct platform_device *pdev)
 		}
 	}
 
-	rc = device_register(&udc->gadget.dev);
-	if (rc)
-		goto out_uninit;
-
 	bcm63xx_udc_init_debugfs(udc);
 	rc = usb_add_gadget_udc(dev, &udc->gadget);
 	if (!rc)
@@ -2439,7 +2435,6 @@ static int bcm63xx_udc_remove(struct platform_device *pdev)
 
 	bcm63xx_udc_cleanup_debugfs(udc);
 	usb_del_gadget_udc(&udc->gadget);
-	device_unregister(&udc->gadget.dev);
 	BUG_ON(udc->driver);
 
 	platform_set_drvdata(pdev, NULL);
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 04/32] usb: gadget: omap_udc: let udc-core manage gadget->dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we drop some boilerplate
code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/omap_udc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index d0c87b1..234e82b 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2631,10 +2631,9 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv)
 	udc->gadget.max_speed = USB_SPEED_FULL;
 	udc->gadget.name = driver_name;
 
-	device_initialize(&udc->gadget.dev);
-	dev_set_name(&udc->gadget.dev, "gadget");
 	udc->gadget.dev.release = omap_udc_release;
 	udc->gadget.dev.parent = &odev->dev;
+	udc->gadget.register_my_device = true;
 	if (use_dma)
 		udc->gadget.dev.dma_mask = odev->dev.dma_mask;
 
@@ -2911,14 +2910,12 @@ bad_on_1710:
 	}
 
 	create_proc_file();
-	status = device_add(&udc->gadget.dev);
+	status = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
 	if (status)
 		goto cleanup4;
 
-	status = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
-	if (!status)
-		return status;
-	/* If fail, fall through */
+	return 0;
+
 cleanup4:
 	remove_proc_file();
 
@@ -2989,7 +2986,6 @@ static int omap_udc_remove(struct platform_device *pdev)
 	release_mem_region(pdev->resource[0].start,
 			pdev->resource[0].end - pdev->resource[0].start + 1);
 
-	device_unregister(&udc->gadget.dev);
 	wait_for_completion(&done);
 
 	return 0;
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 03/32] usb: musb: gadget: let udc-core manage gadget-dev
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

By simply setting a flag, we can delete a little
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/musb/musb_gadget.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 8767874..1c4a8e8 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1871,12 +1871,11 @@ int musb_gadget_setup(struct musb *musb)
 	musb->g.speed = USB_SPEED_UNKNOWN;
 
 	/* this "gadget" abstracts/virtualizes the controller */
-	dev_set_name(&musb->g.dev, "gadget");
 	musb->g.dev.parent = musb->controller;
 	musb->g.dev.dma_mask = musb->controller->dma_mask;
 	musb->g.dev.release = musb_gadget_release;
 	musb->g.name = musb_driver_name;
-
+	musb->g.register_my_device = true;
 	musb->g.is_otg = 1;
 
 	musb_g_init_endpoints(musb);
@@ -1884,11 +1883,6 @@ int musb_gadget_setup(struct musb *musb)
 	musb->is_active = 0;
 	musb_platform_try_idle(musb, 0);
 
-	status = device_register(&musb->g.dev);
-	if (status != 0) {
-		put_device(&musb->g.dev);
-		return status;
-	}
 	status = usb_add_gadget_udc(musb->controller, &musb->g);
 	if (status)
 		goto err;
@@ -1903,8 +1897,6 @@ err:
 void musb_gadget_cleanup(struct musb *musb)
 {
 	usb_del_gadget_udc(&musb->g);
-	if (musb->g.dev.parent)
-		device_unregister(&musb->g.dev);
 }
 
 /*
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* [RFC/PATCH 01/32] usb: gadget: udc-core: allow udc class register gadget device
From: Felipe Balbi @ 2013-01-24 15:45 UTC (permalink / raw)
  To: Linux USB Mailing List
  Cc: kgene.kim, eric.y.miao, kuninori.morimoto.gx, alexander.shishkin,
	gregkh, yoshihiro.shimoda.uh, nicolas.ferre, linux-geode,
	haojian.zhuang, Linux OMAP Mailing List, linux-samsung-soc,
	Felipe Balbi, ben-linux, dahlmann.thomas, linux, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>

Currently all UDC drivers are calling
device_register() before calling
usb_add_gadget_udc(). In order to avoid
code duplication, we can allow udc-core.c
register that device.

However that would become a really large patch,
so to cope with the meanwhile and allow us
to write bite-sized patches, we're adding
a flag which will be set by UDC driver once
it removes the code for registering the
gadget device.

Once all are converted, the new flag will
be removed.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/gadget/udc-core.c | 23 +++++++++++++++++++----
 include/linux/usb/gadget.h    |  4 ++++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 2a9cd36..9195054 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -173,6 +173,14 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
 	if (!udc)
 		goto err1;
 
+	if (gadget->register_my_device) {
+		dev_set_name(&gadget->dev, "gadget");
+
+		ret = device_register(&gadget->dev);
+		if (ret)
+			goto err2;
+	}
+
 	device_initialize(&udc->dev);
 	udc->dev.release = usb_udc_release;
 	udc->dev.class = udc_class;
@@ -180,7 +188,7 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
 	udc->dev.parent = parent;
 	ret = dev_set_name(&udc->dev, "%s", kobject_name(&parent->kobj));
 	if (ret)
-		goto err2;
+		goto err3;
 
 	udc->gadget = gadget;
 
@@ -189,18 +197,22 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
 
 	ret = device_add(&udc->dev);
 	if (ret)
-		goto err3;
+		goto err4;
 
 	mutex_unlock(&udc_lock);
 
 	return 0;
-err3:
+
+err4:
 	list_del(&udc->list);
 	mutex_unlock(&udc_lock);
 
-err2:
+err3:
 	put_device(&udc->dev);
 
+err2:
+	if (gadget->register_my_device)
+		put_device(&gadget->dev);
 err1:
 	return ret;
 }
@@ -254,6 +266,9 @@ found:
 
 	kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
 	device_unregister(&udc->dev);
+
+	if (gadget->register_my_device)
+		device_unregister(&gadget->dev);
 }
 EXPORT_SYMBOL_GPL(usb_del_gadget_udc);
 
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 2e297e8..fcd9ef8 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -494,6 +494,9 @@ struct usb_gadget_ops {
  *	only supports HNP on a different root port.
  * @b_hnp_enable: OTG device feature flag, indicating that the A-Host
  *	enabled HNP support.
+ * @register_my_device: Flag telling udc-core that UDC driver didn't
+ *	register the gadget device to the driver model. Temporary until
+ *	all UDC drivers are fixed up properly.
  * @name: Identifies the controller hardware type.  Used in diagnostics
  *	and sometimes configuration.
  * @dev: Driver model state for this abstract device.
@@ -531,6 +534,7 @@ struct usb_gadget {
 	unsigned			b_hnp_enable:1;
 	unsigned			a_hnp_support:1;
 	unsigned			a_alt_hnp_support:1;
+	unsigned			register_my_device:1;
 	const char			*name;
 	struct device			dev;
 	unsigned			out_epnum;
-- 
1.8.1.rc1.5.g7e0651a

^ permalink raw reply related

* Re: [PATCH 3/8] mm: use vm_unmapped_area() on frv architecture
From: David Howells @ 2013-01-24 14:13 UTC (permalink / raw)
  To: Michel Lespinasse
  Cc: Fenghua Yu, Tony Luck, linux-ia64, linux-parisc, Helge Deller,
	James E.J. Bottomley, linux-kernel, dhowells, linux-mm,
	Paul Mackerras, linux-alpha, Ivan Kokshaysky, Matt Turner,
	linuxppc-dev, Andrew Morton, Richard Henderson
In-Reply-To: <1358990991-21316-4-git-send-email-walken@google.com>

Michel Lespinasse <walken@google.com> wrote:

> Update the frv arch_get_unmapped_area function to make use of
> vm_unmapped_area() instead of implementing a brute force search.
> 
> Signed-off-by: Michel Lespinasse <walken@google.com>
> Acked-by: Rik van Riel <riel@redhat.com>

Acked-by: David Howells <dhowells@redhat.com>

^ permalink raw reply

* Re: Freescale P2020 CPU Freeze over PCIe abort signal
From: siva kumar @ 2013-01-24 11:53 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev
In-Reply-To: <1358977222.9710.7@snotra>

[-- Attachment #1: Type: text/plain, Size: 684 bytes --]

Thank you Scott for the reply.
May I know did u got out of this issue and   can i get some brief on what
changes they had suggested.

Thanks,
Siva

On Thu, Jan 24, 2013 at 3:10 AM, Scott Wood <scottwood@freescale.com> wrote:

> On 01/23/2013 11:41:26 AM, siva kumar wrote:
>
>> Hi ,
>>
>> Is there any update on this , am getting in to the same state .
>> https://lists.ozlabs.org/**pipermail/linuxppc-dev/2010-**
>> October/086680.html<https://lists.ozlabs.org/pipermail/linuxppc-dev/2010-October/086680.html>
>>
>
> Eran's initial comment of "This should probably go to the Freescale
> support" seems right.  You can reach Freescale support at
> support@freescale.com.
>
> -Scott
>

[-- Attachment #2: Type: text/html, Size: 1303 bytes --]

^ permalink raw reply

* Re: [PATCH 1/8] mm: use vm_unmapped_area() on parisc architecture
From: James Bottomley @ 2013-01-24 10:33 UTC (permalink / raw)
  To: Michel Lespinasse
  Cc: Fenghua Yu, Tony Luck, linux-ia64, linux-parisc, Helge Deller,
	James E.J. Bottomley, linux-kernel, David Howells, linux-mm,
	Ivan Kokshaysky, linux-alpha, Paul Mackerras, Matt Turner,
	linuxppc-dev, Andrew Morton, Richard Henderson
In-Reply-To: <1358990991-21316-2-git-send-email-walken@google.com>

On Wed, 2013-01-23 at 17:29 -0800, Michel Lespinasse wrote:
> Update the parisc arch_get_unmapped_area function to make use of
> vm_unmapped_area() instead of implementing a brute force search.
> 
> Signed-off-by: Michel Lespinasse <walken@google.com>
> Acked-by: Rik van Riel <riel@redhat.com>
> 
> ---
>  arch/parisc/kernel/sys_parisc.c |   46 ++++++++++++++------------------------
>  1 files changed, 17 insertions(+), 29 deletions(-)
> 
> diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
> index f76c10863c62..6ab138088076 100644
> --- a/arch/parisc/kernel/sys_parisc.c
> +++ b/arch/parisc/kernel/sys_parisc.c
> @@ -35,18 +35,15 @@
>  
>  static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
>  {
> -	struct vm_area_struct *vma;
> +	struct vm_unmapped_area_info info;
>  
> -	addr = PAGE_ALIGN(addr);
> -
> -	for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
> -		/* At this point:  (!vma || addr < vma->vm_end). */
> -		if (TASK_SIZE - len < addr)
> -			return -ENOMEM;
> -		if (!vma || addr + len <= vma->vm_start)
> -			return addr;
> -		addr = vma->vm_end;
> -	}
> +	info.flags = 0;
> +	info.length = len;
> +	info.low_limit = PAGE_ALIGN(addr);
> +	info.high_limit = TASK_SIZE;
> +	info.align_mask = 0;
> +	info.align_offset = 0;
> +	return vm_unmapped_area(&info);
>  }
>  
>  #define DCACHE_ALIGN(addr) (((addr) + (SHMLBA - 1)) &~ (SHMLBA - 1))

This macro is now redundant and can be removed.

> @@ -63,30 +60,21 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
>   */
>  static int get_offset(struct address_space *mapping)
>  {
> -	int offset = (unsigned long) mapping << (PAGE_SHIFT - 8);
> -	return offset & 0x3FF000;
> +	return (unsigned long) mapping >> 8;

I'm not sure I agree with this shift (but I think the original was wrong
as well so the comment probably needs updating.)  Trying to derive
entropy from the mapping address is always nasty.  Mostly they're
embedded in the inode, so the right shift should be something like
log2(sizeof(inode)) + 1 and since the inode size is usually somewhere
between 512 and 1024 bytes, that comes out to 10 I think.

>  }
>  
>  static unsigned long get_shared_area(struct address_space *mapping,
>  		unsigned long addr, unsigned long len, unsigned long pgoff)
>  {
> -	struct vm_area_struct *vma;
> -	int offset = mapping ? get_offset(mapping) : 0;
> -
> -	offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
> +	struct vm_unmapped_area_info info;
>  
> -	addr = DCACHE_ALIGN(addr - offset) + offset;
> -
> -	for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
> -		/* At this point:  (!vma || addr < vma->vm_end). */
> -		if (TASK_SIZE - len < addr)
> -			return -ENOMEM;
> -		if (!vma || addr + len <= vma->vm_start)
> -			return addr;
> -		addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
> -		if (addr < vma->vm_end) /* handle wraparound */
> -			return -ENOMEM;
> -	}
> +	info.flags = 0;
> +	info.length = len;
> +	info.low_limit = PAGE_ALIGN(addr);
> +	info.high_limit = TASK_SIZE;
> +	info.align_mask = PAGE_MASK & (SHMLBA - 1);
> +	info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
> +	return vm_unmapped_area(&info);
>  }
>  
>  unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,

Other than that, I think this will work, but I'd like to test it.

James

^ permalink raw reply

* Re: [PATCH powerpc ] Avoid debug_smp_processor_id() check in arch_spin_unlock_wait()
From: Li Zhong @ 2013-01-24 10:13 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Paul Mackerras, Paul E. McKenney, PowerPC email list
In-Reply-To: <1358999231.29726.9.camel@pasglop>

On Thu, 2013-01-24 at 14:47 +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2013-01-10 at 17:00 +0800, Li Zhong wrote:
> > Use local_paca directly in arch_spin_unlock_wait(), as all processors have the
> > same value for the field shared_proc, so we don't need care racy here.
> 
> Of course that won't build if CONFIG_PPC_SPLPAR isn't defined...

...ah, I didn't notice that lppaca_ptr is only defined under
CONFIG_PPC_BOOK3S, and the whole paca is only defined under
CONFIG_PPC64; while the function changed seems could be used by any
configuration. Sorry about the carelessness. 

> 
> Maybe you could change the definition of the SHARED_PROCESSOR
> macro itself. The only possible "risk" would be a stale lppaca
> if we preempt & hot unplug the CPU at the wrong time (provided
> we no longer stop_machine either), I suppose if that's a real
> concern we could delay freeing of lppaca's via RCU or such.

I'm not very clear about the "risk" you mentioned above. It seems to me
that the freeing of lppaca only appeared in free_unused_pacas(), called
by early setup code, at which time hotplug seems impossible. 

I must missed something ...

I'll update the SHARED_PROCESSOR directly, it seems better to me now.
(wonder why I gave it up immediately when it first came into my mind
while I was doing the last update...)

Thanks, Zhong

> Ben.
> 
> > Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
> > ---
> >  arch/powerpc/lib/locks.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
> > index bb7cfec..850bea6 100644
> > --- a/arch/powerpc/lib/locks.c
> > +++ b/arch/powerpc/lib/locks.c
> > @@ -72,7 +72,7 @@ void arch_spin_unlock_wait(arch_spinlock_t *lock)
> >  {
> >  	while (lock->slock) {
> >  		HMT_low();
> > -		if (SHARED_PROCESSOR)
> > +		if (local_paca->lppaca_ptr->shared_proc)
> >  			__spin_yield(lock);
> >  	}
> >  	HMT_medium();
> 
> 

^ permalink raw reply

* [PATCH 2/2] cpu-hotplug, memory-hotplug: Remove __cpuinit declaration of numa_clear_node().
From: Tang Chen @ 2013-01-24  9:38 UTC (permalink / raw)
  To: akpm, rjw, len.brown, mingo, tglx, minchan.kim, rientjes, benh,
	paulus, cl, kosaki.motohiro, isimatu.yasuaki, wujianguo, wency,
	hpa, linfeng, laijs, mgorman, yinghai, glommer, jiang.liu,
	julian.calaby, sfr, guz.fnst
  Cc: linux-mm, x86, linuxppc-dev, linux-kernel, linux-acpi
In-Reply-To: <1359020287-11661-1-git-send-email-tangchen@cn.fujitsu.com>

numa_clear_node() will be used by check_and_unmap_cpu_on_node()
when we do node hotplug. So it is no longer a __cpuinit function.
Do not declare it as a __cpuinit function, otherwise it will cause
section mismatch warning when compiling.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 arch/x86/mm/numa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 0624c85..6864b08 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -100,7 +100,7 @@ void __cpuinit numa_set_node(int cpu, int node)
 	set_cpu_numa_node(cpu, node);
 }
 
-void __cpuinit numa_clear_node(int cpu)
+void numa_clear_node(int cpu)
 {
 	numa_set_node(cpu, NUMA_NO_NODE);
 }
-- 
1.7.1

^ permalink raw reply related

* [PATCH 0/2] Fix section mismatch caused by node offline code.
From: Tang Chen @ 2013-01-24  9:38 UTC (permalink / raw)
  To: akpm, rjw, len.brown, mingo, tglx, minchan.kim, rientjes, benh,
	paulus, cl, kosaki.motohiro, isimatu.yasuaki, wujianguo, wency,
	hpa, linfeng, laijs, mgorman, yinghai, glommer, jiang.liu,
	julian.calaby, sfr, guz.fnst
  Cc: linux-mm, x86, linuxppc-dev, linux-kernel, linux-acpi

Since node offline code uses __apicid_to_node[] and numa_clear_node(),
they are no longer init data or function. So do not declare them as
__cpuinitdata or __cpuinit.

Tang Chen (2):
  cpu_hotplug: Remove __cpuinitdata declaration of __apicid_to_node[].
  cpu-hotplug,memory-hotplug: Remove __cpuinit declaration of
    numa_clear_node().

 arch/x86/mm/numa.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

^ permalink raw reply

* [PATCH 1/2] cpu_hotplug: Remove __cpuinitdata declaration of __apicid_to_node[].
From: Tang Chen @ 2013-01-24  9:38 UTC (permalink / raw)
  To: akpm, rjw, len.brown, mingo, tglx, minchan.kim, rientjes, benh,
	paulus, cl, kosaki.motohiro, isimatu.yasuaki, wujianguo, wency,
	hpa, linfeng, laijs, mgorman, yinghai, glommer, jiang.liu,
	julian.calaby, sfr, guz.fnst
  Cc: linux-mm, x86, linuxppc-dev, linux-kernel, linux-acpi
In-Reply-To: <1359020287-11661-1-git-send-email-tangchen@cn.fujitsu.com>

__apicid_to_node[] will be used by acpi_unmap_lsapic() when we do
node hotplug. So it is no longer an init data. Do not declare
__apicid_to_node[] as a __cpuinitdata, otherwise it will cause
section mismatch warning when compiling.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 arch/x86/mm/numa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 9b31ed5..0624c85 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -56,7 +56,7 @@ early_param("numa", numa_setup);
 /*
  * apicid, cpu, node mappings
  */
-s16 __apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = {
+s16 __apicid_to_node[MAX_LOCAL_APIC] = {
 	[0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
 };
 
-- 
1.7.1

^ permalink raw reply related

* [PATCH][v2] perf tools, powerpc: Fix compile warnings in tests/attr.c
From: Sukadev Bhattiprolu @ 2013-01-24  5:44 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linuxppc-dev, ellerman, Anton Blanchard, Jiri Olsa, linux-kernel


[PATCH][v2] perf tools, powerpc: Fix compile warnings in tests/attr.c

We print several '__u64' quantities using '%llu'. On powerpc, we by
default include '<asm-generic/int-l64.h> which results in __u64 being
an unsigned long. This causes compile warnings which are treated as
errors due to '-Werror'.

By defining __SANE_USERSPACE_TYPES__ we include <asm-generic/int-ll64.h>
and define __u64 as unsigned long long.

Changelog[v2]:
	[Michael Ellerman] Use __SANE_USERSPACE_TYPES__ and avoid PRIu64
	format specifier - which as Jiri Olsa pointed out, breaks on x86-64.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 tools/perf/tests/attr.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index f61dd3f..bdcceb8 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -19,6 +19,11 @@
  * permissions. All the event text files are stored there.
  */
 
+/*
+ * Powerpc needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
+ * 'int-ll64.h' and avoid compile warnings when printing __u64 with %llu.
+ */
+#define __SANE_USERSPACE_TYPES__
 #include <stdlib.h>
 #include <stdio.h>
 #include <inttypes.h>
-- 
1.7.1

^ permalink raw reply related

* Re: [PATCH] perf/Power: PERF_EVENT_IOC_ENABLE does not reenable event
From: Paul Mackerras @ 2013-01-24  5:05 UTC (permalink / raw)
  To: Sukadev Bhattiprolu; +Cc: Anton Blanchard, Maynard Johnson, linuxppc-dev
In-Reply-To: <20130111191117.GA9407@us.ibm.com>

On Fri, Jan 11, 2013 at 11:11:17AM -0800, Sukadev Bhattiprolu wrote:
> If we disable a perf event because we exceeded the specified ->event_limit,
> power_pmu_stop() sets the PERF_HES_STOPPED flag on the event.
> 
> If the application then re-enables the event using PERF_EVENT_IOC_ENABLE
> ioctl, we don't seem to ever clear this STOPPED flag. Consequently, the
> user space is never notified of the event.
> 
> Following message has more background and test case.
> 
>     http://lists.eecs.utk.edu/pipermail/ptools-perfapi/2012-October/002528.html
> 
> The problem reported there does not seem to occur on x86. My unverified theory:
> 
> Both x86 and Power clear the event->hw.state flag to 0 in their ->pmu_start()
> operations. On X86 x86_pmu_start() is called from x86_pmu_enable(). But on
> Power, power_pmu_start() is not called from power_pmu_enable().

This code has changed a lot since I worked on it, but it seems like
x86 has the STOPPED flag set whenever the event isn't currently active
on a hardware counter, whereas we have it set only when the event has
been throttled.

> Used the following test cases to verify that this patch works on latest PAPI.
> 
> 	$ papi.git/src/ctests/nonthread PAPI_TOT_CYC@5000000
> 
> 	$ papi.git/src/ctests/overflow_single_event
> 
> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> ---
>  arch/powerpc/perf/core-book3s.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> index aa2465e..a6faada 100644
> --- a/arch/powerpc/perf/core-book3s.c
> +++ b/arch/powerpc/perf/core-book3s.c
> @@ -880,8 +880,16 @@ static int power_pmu_add(struct perf_event *event, int ef_flags)
>  	cpuhw->events[n0] = event->hw.config;
>  	cpuhw->flags[n0] = event->hw.event_base;
>  
> +	/*
> +	 * If this event was disabled in record_and_restart() because we
> +	 * exceeded the ->event_limit, this is probably a good time to
> +	 * re-enable the event ? If we don't reenable the event, we will
> +	 * never notify the user again about this event.
> +	 */

The comment seems a bit tentative. :)  If the PERF_EF_START bit is set
then we are being told to restart the event.

>  	if (!(ef_flags & PERF_EF_START))
>  		event->hw.state = PERF_HES_STOPPED | PERF_HES_UPTODATE;
> +	else
> +		event->hw.state &= ~PERF_HES_STOPPED;

This looks fine, though I think you could equally well just set
event->hw.state to 0 in the else clause.  That would clear the
UPTODATE flag too, which is appropriate since we are about to put the
event on a hardware counter.

Paul.

^ permalink raw reply

* [PATCH] arch/powerpc/kernel: using %12.12s instead of %12s for avoiding memory overflow.
From: Chen Gang @ 2013-01-24  4:14 UTC (permalink / raw)
  To: benh, paulus; +Cc: linuxppc-dev


  for tmp_part->header.name:
    it is "Terminating null required only for names < 12 chars".
    so need to limit the %.12s for it in printk

  additional info:

    %12s  limit the width, not for the original string output length
          if name length is more than 12, it still can be fully displayed.
          if name length is less than 12, the ' ' will be filled before name.

    %.12s truly limit the original string output length (precision)


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 arch/powerpc/kernel/nvram_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index bec1e93..57bf6d2 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -202,7 +202,7 @@ static void __init nvram_print_partitions(char * label)
 	printk(KERN_WARNING "--------%s---------\n", label);
 	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
 	list_for_each_entry(tmp_part, &nvram_partitions, partition) {
-		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12s\n",
+		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12.12s\n",
 		       tmp_part->index, tmp_part->header.signature,
 		       tmp_part->header.checksum, tmp_part->header.length,
 		       tmp_part->header.name);
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH v5 04/45] percpu_rwlock: Implement the core design of Per-CPU Reader-Writer Locks
From: Srivatsa S. Bhat @ 2013-01-24  4:30 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-doc, peterz, fweisbec, linux-kernel, walken, mingo,
	linux-arch, linux, xiaoguangrong, wangyun, paulmck, nikunj,
	linux-pm, rusty, rostedt, rjw, namhyung, tglx, linux-arm-kernel,
	netdev, oleg, sbw, akpm, linuxppc-dev
In-Reply-To: <20130123195740.GI2373@mtj.dyndns.org>

On 01/24/2013 01:27 AM, Tejun Heo wrote:
> Hello, Srivatsa.
> 
> On Thu, Jan 24, 2013 at 01:03:52AM +0530, Srivatsa S. Bhat wrote:
>> Hmm.. I split it up into steps to help explain the reasoning behind
>> the code sufficiently, rather than spring all of the intricacies at
>> one go (which would make it very hard to write the changelog/comments
>> also). The split made it easier for me to document it well in the
>> changelog, because I could deal with reasonable chunks of code/complexity
>> at a time. IMHO that helps people reading it for the first time to
>> understand the logic easily.
> 
> I don't know.  It's a judgement call I guess.  I personally would much
> prefer having ample documentation as comments in the source itself or
> as a separate Documentation/ file as that's what most people are gonna
> be looking at to figure out what's going on.  Maybe just compact it a
> bit and add more in-line documentation instead?
> 

OK, I'll think about this.

>>> The only two options are either punishing writers or identifying and
>>> updating all such possible deadlocks.  percpu_rwsem does the former,
>>> right?  I don't know how feasible the latter would be.
>>
>> I don't think we can avoid looking into all the possible deadlocks,
>> as long as we use rwlocks inside get/put_online_cpus_atomic() (assuming
>> rwlocks are fair). Even with Oleg's idea of using synchronize_sched()
>> at the writer, we still need to take care of locking rules, because the
>> synchronize_sched() only helps avoid the memory barriers at the reader,
>> and doesn't help get rid of the rwlocks themselves.
> 
> Well, percpu_rwlock don't have to use rwlock for the slow path.  It
> can implement its own writer starving locking scheme.  It's not like
> implementing slow path global rwlock logic is difficult.
>

Great idea! So probably I could use atomic ops or something similar in the
slow path to implement the scheme we need...

>> CPU 0                          CPU 1
>>
>> read_lock(&rwlock)
>>
>>                               write_lock(&rwlock) //spins, because CPU 0
>>                               //has acquired the lock for read
>>
>> read_lock(&rwlock)
>>    ^^^^^
>> What happens here? Does CPU 0 start spinning (and hence deadlock) or will
>> it continue realizing that it already holds the rwlock for read?
> 
> I don't think rwlock allows nesting write lock inside read lock.
> read_lock(); write_lock() will always deadlock.
> 

Sure, I understand that :-) My question was, what happens when *two* CPUs
are involved, as in, the read_lock() is invoked only on CPU 0 whereas the
write_lock() is invoked on CPU 1.

For example, the same scenario shown above, but with slightly different
timing, will NOT result in a deadlock:

Scenario 2:
  CPU 0                                CPU 1

read_lock(&rwlock)


read_lock(&rwlock) //doesn't spin

                                    write_lock(&rwlock) //spins, because CPU 0
                                    //has acquired the lock for read


So I was wondering whether the "fairness" logic of rwlocks would cause
the second read_lock() to spin (in the first scenario shown above) because
a writer is already waiting (and hence new readers should spin) and thus
cause a deadlock.

Regards,
Srivatsa S. Bhat

^ permalink raw reply

* Re: [PATCH v5 01/45] percpu_rwlock: Introduce the global reader-writer lock backend
From: Michel Lespinasse @ 2013-01-24  4:14 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-doc, peterz, fweisbec, linux-kernel, mingo, linux-arch,
	linux, xiaoguangrong, wangyun, paulmck, nikunj, linux-pm, rusty,
	rjw, namhyung, tglx, linux-arm-kernel, netdev, oleg, sbw,
	Srivatsa S. Bhat, tj, akpm, linuxppc-dev
In-Reply-To: <1358883152.21576.55.camel@gandalf.local.home>

On Tue, Jan 22, 2013 at 11:32 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 2013-01-22 at 13:03 +0530, Srivatsa S. Bhat wrote:
>> A straight-forward (and obvious) algorithm to implement Per-CPU Reader-Writer
>> locks can also lead to too many deadlock possibilities which can make it very
>> hard/impossible to use. This is explained in the example below, which helps
>> justify the need for a different algorithm to implement flexible Per-CPU
>> Reader-Writer locks.
>>
>> We can use global rwlocks as shown below safely, without fear of deadlocks:
>>
>> Readers:
>>
>>          CPU 0                                CPU 1
>>          ------                               ------
>>
>> 1.    spin_lock(&random_lock);             read_lock(&my_rwlock);
>>
>>
>> 2.    read_lock(&my_rwlock);               spin_lock(&random_lock);
>>
>>
>> Writer:
>>
>>          CPU 2:
>>          ------
>>
>>        write_lock(&my_rwlock);
>>
>
> I thought global locks are now fair. That is, a reader will block if a
> writer is waiting. Hence, the above should deadlock on the current
> rwlock_t types.

I believe you are mistaken here. struct rw_semaphore is fair (and
blocking), but rwlock_t is unfair. The reason we can't easily make
rwlock_t fair is because tasklist_lock currently depends on the
rwlock_t unfairness - tasklist_lock readers typically don't disable
local interrupts, and tasklist_lock may be acquired again from within
an interrupt, which would deadlock if rwlock_t was fair and a writer
was queued by the time the interrupt is processed.

> We need to fix those locations (or better yet, remove all rwlocks ;-)

tasklist_lock is the main remaining user. I'm not sure about removing
rwlock_t, but I would like to at least make it fair somehow :)

-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox