[U-Boot] [PATCH 0/2] Invoke board specific board_usb_cleanup function

This patches invoke board-specific usb cleanup interface (board_usb_cleanup) After USB initalization.
Inha Song (2): usb: common: provide a _weak board_usb_cleanup() function usb: invoke board specific USB cleanup interface
common/cmd_dfu.c | 1 + common/cmd_thordown.c | 1 + common/cmd_usb_mass_storage.c | 1 + common/usb.c | 6 ++++++ 4 files changed, 9 insertions(+)

This patch implement _weak function for board_usb_cleanup. This function (usb_board_cleanup) implementation is board-specific feature.
board_usb_cleanup function can be used to clean up after failed board-specific USB initialization.
Signed-off-by: Inha Song ideal.song@samsung.com --- common/usb.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/common/usb.c b/common/usb.c index 736cd9f..fbb4495 100644 --- a/common/usb.c +++ b/common/usb.c @@ -1063,4 +1063,10 @@ int board_usb_init(int index, enum usb_init_type init) { return 0; } + +__weak +int board_usb_cleanup(int index, enum usb_init_type init) +{ + return 0; +} /* EOF */

Hi Marek
This patch implement _weak function for board_usb_cleanup. This function (usb_board_cleanup) implementation is board-specific feature.
board_usb_cleanup function can be used to clean up after failed board-specific USB initialization.
Signed-off-by: Inha Song ideal.song@samsung.com
common/usb.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/common/usb.c b/common/usb.c index 736cd9f..fbb4495 100644 --- a/common/usb.c +++ b/common/usb.c @@ -1063,4 +1063,10 @@ int board_usb_init(int index, enum usb_init_type init) { return 0; }
+__weak +int board_usb_cleanup(int index, enum usb_init_type init) +{
- return 0;
+} /* EOF */
Acked-by: Lukasz Majewski l.majewski@samsung.com
Marek could you take this patch (and the following one) to -usb tree?

Hi Lukasz,
Hi Marek
This patch implement _weak function for board_usb_cleanup. This function (usb_board_cleanup) implementation is board-specific feature.
board_usb_cleanup function can be used to clean up after failed board-specific USB initialization.
Signed-off-by: Inha Song ideal.song@samsung.com
common/usb.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/common/usb.c b/common/usb.c index 736cd9f..fbb4495 100644 --- a/common/usb.c +++ b/common/usb.c @@ -1063,4 +1063,10 @@ int board_usb_init(int index, enum usb_init_type init) { return 0; }
+__weak +int board_usb_cleanup(int index, enum usb_init_type init) +{
- return 0;
+} /* EOF */
Acked-by: Lukasz Majewski l.majewski@samsung.com
Marek could you take this patch (and the following one) to -usb tree?
I've looked a bit more deep into this and it seems like this code is also defined in patches provided by Kishon:
"common: cmd_dfu: invoke board_usb_cleanup() for cleaning up" b607ea5d62bb0c295f10af86a6de6b33dd1fea75
Marek, it is your call to decide how we should proceed.
My recommendation - we should use Kishon's patches, since it is the part of a larger patchset.

On Tuesday, February 24, 2015 at 05:05:29 PM, Lukasz Majewski wrote:
Hi Lukasz,
Hi Lukasz,
is your other self doing good too ? ;-)
Hi Marek
This patch implement _weak function for board_usb_cleanup. This function (usb_board_cleanup) implementation is board-specific feature.
board_usb_cleanup function can be used to clean up after failed board-specific USB initialization.
Signed-off-by: Inha Song ideal.song@samsung.com
common/usb.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/common/usb.c b/common/usb.c index 736cd9f..fbb4495 100644 --- a/common/usb.c +++ b/common/usb.c @@ -1063,4 +1063,10 @@ int board_usb_init(int index, enum usb_init_type init) {
return 0;
}
+__weak +int board_usb_cleanup(int index, enum usb_init_type init) +{
- return 0;
+}
/* EOF */
Acked-by: Lukasz Majewski l.majewski@samsung.com
Marek could you take this patch (and the following one) to -usb tree?
I've looked a bit more deep into this and it seems like this code is also defined in patches provided by Kishon:
"common: cmd_dfu: invoke board_usb_cleanup() for cleaning up" b607ea5d62bb0c295f10af86a6de6b33dd1fea75
Marek, it is your call to decide how we should proceed.
My recommendation - we should use Kishon's patches, since it is the part of a larger patchset.
I'll stick with your recommendation, though I'd like to -- somehow -- work in Inha's credit into those patches too. What do you think please ?
Best regards, Marek Vasut

Hi Marek,
On Tuesday, February 24, 2015 at 05:05:29 PM, Lukasz Majewski wrote:
Hi Lukasz,
Hi Lukasz,
is your other self doing good too ? ;-)
Hi Marek
This patch implement _weak function for board_usb_cleanup. This function (usb_board_cleanup) implementation is board-specific feature.
board_usb_cleanup function can be used to clean up after failed board-specific USB initialization.
Signed-off-by: Inha Song ideal.song@samsung.com
common/usb.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/common/usb.c b/common/usb.c index 736cd9f..fbb4495 100644 --- a/common/usb.c +++ b/common/usb.c @@ -1063,4 +1063,10 @@ int board_usb_init(int index, enum usb_init_type init) {
return 0;
}
+__weak +int board_usb_cleanup(int index, enum usb_init_type init) +{
- return 0;
+}
/* EOF */
Acked-by: Lukasz Majewski l.majewski@samsung.com
Marek could you take this patch (and the following one) to -usb tree?
I've looked a bit more deep into this and it seems like this code is also defined in patches provided by Kishon:
"common: cmd_dfu: invoke board_usb_cleanup() for cleaning up" b607ea5d62bb0c295f10af86a6de6b33dd1fea75
Marek, it is your call to decide how we should proceed.
My recommendation - we should use Kishon's patches, since it is the part of a larger patchset.
I'll stick with your recommendation, though I'd like to -- somehow -- work in Inha's credit into those patches too. What do you think please ?
Rob Herring had some comments to Inha original patches, so now I'm confused.
Lets see if Inha fixes issues with original patch. It is also possible to drop only one patch from Kishon, namely "common: cmd_dfu: invoke board_usb_cleanup() for cleaning up"
Best regards, Marek Vasut

On Wednesday, February 25, 2015 at 10:15:24 AM, Lukasz Majewski wrote:
Hi Marek,
Hi!
On Tuesday, February 24, 2015 at 05:05:29 PM, Lukasz Majewski wrote:
Hi Lukasz,
[...]
I'll stick with your recommendation, though I'd like to -- somehow -- work in Inha's credit into those patches too. What do you think please ?
Rob Herring had some comments to Inha original patches, so now I'm confused.
Lets see if Inha fixes issues with original patch. It is also possible to drop only one patch from Kishon, namely "common: cmd_dfu: invoke board_usb_cleanup() for cleaning up"
Gah, we're loosing traction here. Maybe we need to sync up and we surely need to apply something, otherwise this will become a chaotic mess.
I placed all of the patches into u-boot-usb branch topic/dwc3 . Can you please check if it's working and what is possibly missing ? Let's work on top of that please, OK ?
Best regards, Marek Vasut

Hi Marek,
On Wednesday, February 25, 2015 at 10:15:24 AM, Lukasz Majewski wrote:
Hi Marek,
Hi!
On Tuesday, February 24, 2015 at 05:05:29 PM, Lukasz Majewski wrote:
Hi Lukasz,
[...]
I'll stick with your recommendation, though I'd like to -- somehow -- work in Inha's credit into those patches too. What do you think please ?
Rob Herring had some comments to Inha original patches, so now I'm confused.
Lets see if Inha fixes issues with original patch. It is also possible to drop only one patch from Kishon, namely "common: cmd_dfu: invoke board_usb_cleanup() for cleaning up"
Gah, we're loosing traction here. Maybe we need to sync up and we surely need to apply something, otherwise this will become a chaotic mess.
I placed all of the patches into u-boot-usb branch topic/dwc3 . Can you please check if it's working and what is possibly missing ? Let's work on top of that please, OK ?
Thanks for preparing the branch.
However, some fixes - those collected by me need some extra rework, since there were some comments regarding them (mostly from Kishon).
Moreover, we could also add to this branch (on top of Kishon's dwc3 patch set) the linux compatibility rework. On top of that I would like to add next version of dwc3 fixes.
Best regards, Marek Vasut

This patch invoke board-specific USB cleanup (board_usb_cleanup) interface.
Signed-off-by: Inha Song ideal.song@samsung.com --- common/cmd_dfu.c | 1 + common/cmd_thordown.c | 1 + common/cmd_usb_mass_storage.c | 1 + 3 files changed, 3 insertions(+)
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c index e975abe..161d38b 100644 --- a/common/cmd_dfu.c +++ b/common/cmd_dfu.c @@ -68,6 +68,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } exit: g_dnl_unregister(); + board_usb_cleanup(controller_index, USB_INIT_DEVICE); done: dfu_free_entities();
diff --git a/common/cmd_thordown.c b/common/cmd_thordown.c index 8ed1dc6..436b7f5 100644 --- a/common/cmd_thordown.c +++ b/common/cmd_thordown.c @@ -56,6 +56,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
exit: g_dnl_unregister(); + board_usb_cleanup(controller_index, USB_INIT_DEVICE); done: dfu_free_entities();
diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c index 2c879ea..53a765e 100644 --- a/common/cmd_usb_mass_storage.c +++ b/common/cmd_usb_mass_storage.c @@ -154,6 +154,7 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, } exit: g_dnl_unregister(); + board_usb_cleanup(controller_index, USB_INIT_DEVICE); return CMD_RET_SUCCESS; }

Hi Inha,
This patch invoke board-specific USB cleanup (board_usb_cleanup) interface.
Signed-off-by: Inha Song ideal.song@samsung.com
common/cmd_dfu.c | 1 + common/cmd_thordown.c | 1 + common/cmd_usb_mass_storage.c | 1 + 3 files changed, 3 insertions(+)
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c index e975abe..161d38b 100644 --- a/common/cmd_dfu.c +++ b/common/cmd_dfu.c @@ -68,6 +68,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } exit: g_dnl_unregister();
- board_usb_cleanup(controller_index, USB_INIT_DEVICE);
done: dfu_free_entities();
diff --git a/common/cmd_thordown.c b/common/cmd_thordown.c index 8ed1dc6..436b7f5 100644 --- a/common/cmd_thordown.c +++ b/common/cmd_thordown.c @@ -56,6 +56,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) exit: g_dnl_unregister();
- board_usb_cleanup(controller_index, USB_INIT_DEVICE);
done: dfu_free_entities();
diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c index 2c879ea..53a765e 100644 --- a/common/cmd_usb_mass_storage.c +++ b/common/cmd_usb_mass_storage.c @@ -154,6 +154,7 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, } exit: g_dnl_unregister();
- board_usb_cleanup(controller_index, USB_INIT_DEVICE); return CMD_RET_SUCCESS;
}Lukasz Majewski l.majewski@samsung.com
Acked-by: Lukasz Majewski l.majewski@samsung.com

On Mon, Jan 19, 2015 at 1:07 AM, Inha Song ideal.song@samsung.com wrote:
This patch invoke board-specific USB cleanup (board_usb_cleanup) interface.
Signed-off-by: Inha Song ideal.song@samsung.com
common/cmd_dfu.c | 1 + common/cmd_thordown.c | 1 + common/cmd_usb_mass_storage.c | 1 +
You missed fastboot at a minimum.
What about other gadget functions such as rndis/cdc_etherent?
3 files changed, 3 insertions(+)
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c index e975abe..161d38b 100644 --- a/common/cmd_dfu.c +++ b/common/cmd_dfu.c @@ -68,6 +68,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } exit: g_dnl_unregister();
board_usb_cleanup(controller_index, USB_INIT_DEVICE);
Perhaps this should be part of g_dnl_unregister since it is always called immediately after.
done: dfu_free_entities();
diff --git a/common/cmd_thordown.c b/common/cmd_thordown.c index 8ed1dc6..436b7f5 100644 --- a/common/cmd_thordown.c +++ b/common/cmd_thordown.c @@ -56,6 +56,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
exit: g_dnl_unregister();
board_usb_cleanup(controller_index, USB_INIT_DEVICE);
done: dfu_free_entities();
diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c index 2c879ea..53a765e 100644 --- a/common/cmd_usb_mass_storage.c +++ b/common/cmd_usb_mass_storage.c @@ -154,6 +154,7 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, } exit: g_dnl_unregister();
board_usb_cleanup(controller_index, USB_INIT_DEVICE); return CMD_RET_SUCCESS;
}
-- 2.0.0.390.gcb682f8

Hi, Rob,
On Tue, 24 Feb 2015 10:20:13 -0600 Rob Herring robh@kernel.org wrote:
On Mon, Jan 19, 2015 at 1:07 AM, Inha Song ideal.song@samsung.com wrote:
This patch invoke board-specific USB cleanup (board_usb_cleanup) interface.
Signed-off-by: Inha Song ideal.song@samsung.com
common/cmd_dfu.c | 1 + common/cmd_thordown.c | 1 + common/cmd_usb_mass_storage.c | 1 +
You missed fastboot at a minimum.
Ok, I will add board_usb_cleanup fuction also in fastboot.
What about other gadget functions such as rndis/cdc_etherent?
I doesn't have any knowledge about rndis/cdc_etherent So, Afraid that to fix these code.
3 files changed, 3 insertions(+)
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c index e975abe..161d38b 100644 --- a/common/cmd_dfu.c +++ b/common/cmd_dfu.c @@ -68,6 +68,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } exit: g_dnl_unregister();
board_usb_cleanup(controller_index, USB_INIT_DEVICE);
Perhaps this should be part of g_dnl_unregister since it is always called immediately after.
Hm, I am not sure we need to add board_usb_cleanup funtion to the gadget.
Best Regards, Inha Song.
done: dfu_free_entities();
diff --git a/common/cmd_thordown.c b/common/cmd_thordown.c index 8ed1dc6..436b7f5 100644 --- a/common/cmd_thordown.c +++ b/common/cmd_thordown.c @@ -56,6 +56,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
exit: g_dnl_unregister();
board_usb_cleanup(controller_index, USB_INIT_DEVICE);
done: dfu_free_entities();
diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c index 2c879ea..53a765e 100644 --- a/common/cmd_usb_mass_storage.c +++ b/common/cmd_usb_mass_storage.c @@ -154,6 +154,7 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, } exit: g_dnl_unregister();
board_usb_cleanup(controller_index, USB_INIT_DEVICE); return CMD_RET_SUCCESS;
}
-- 2.0.0.390.gcb682f8

On Wed, Feb 25, 2015 at 06:58:03PM +0900, Inha Song wrote:
Hi, Rob,
On Tue, 24 Feb 2015 10:20:13 -0600 Rob Herring robh@kernel.org wrote:
On Mon, Jan 19, 2015 at 1:07 AM, Inha Song ideal.song@samsung.com wrote:
This patch invoke board-specific USB cleanup (board_usb_cleanup) interface.
Signed-off-by: Inha Song ideal.song@samsung.com
common/cmd_dfu.c | 1 + common/cmd_thordown.c | 1 + common/cmd_usb_mass_storage.c | 1 +
You missed fastboot at a minimum.
Ok, I will add board_usb_cleanup fuction also in fastboot.
What about other gadget functions such as rndis/cdc_etherent?
I doesn't have any knowledge about rndis/cdc_etherent So, Afraid that to fix these code.
So that's the problem with this approach. Kishon reminded me that on TI parts we see some PM problems because we don't always do a cleanup on the USB side for gadgets. I think the right answer here is to mirror the usb_stop() function in bootm_disable_interrupts() in common/bootm.c for the gadget code as well.

On Monday, January 19, 2015 at 08:07:14 AM, Inha Song wrote:
This patches invoke board-specific usb cleanup interface (board_usb_cleanup) After USB initalization.
Inha Song (2): usb: common: provide a _weak board_usb_cleanup() function usb: invoke board specific USB cleanup interface
Hi,
where do you plan to use this _weak function please ?
Best regards, Marek Vasut

Hi Marek,
I want to use this function for support Thor/DFU download in Odroid-XU3. For Odroid-XU3 usb support, we need to DWC3 code. (As I know, DWC3 patchsets (Kishon Vijay Abraham I) are RFC state) So, I used DWC3 patchset temporarily and I knew that I should be call dwc3_uboot_exit() function.
As a result, I have implemented board_usb_cleanup() function in smdk5420.c board file for called dwc3_uboot_exit() function.
If "board_usb_cleanup" is dead code, I will fix it.
Best Regards, Inha Song.
On Mon, 19 Jan 2015 09:50:34 +0100 Marek Vasut marex@denx.de wrote:
On Monday, January 19, 2015 at 08:07:14 AM, Inha Song wrote:
This patches invoke board-specific usb cleanup interface (board_usb_cleanup) After USB initalization.
Inha Song (2): usb: common: provide a _weak board_usb_cleanup() function usb: invoke board specific USB cleanup interface
Hi,
where do you plan to use this _weak function please ?
Best regards, Marek Vasut

On Monday, January 19, 2015 at 10:18:53 AM, Inha Song wrote:
Hi Marek,
I want to use this function for support Thor/DFU download in Odroid-XU3. For Odroid-XU3 usb support, we need to DWC3 code. (As I know, DWC3 patchsets (Kishon Vijay Abraham I) are RFC state) So, I used DWC3 patchset temporarily and I knew that I should be call dwc3_uboot_exit() function.
As a result, I have implemented board_usb_cleanup() function in smdk5420.c board file for called dwc3_uboot_exit() function.
If "board_usb_cleanup" is dead code, I will fix it.
Hi!
(please do not top-post)
Thanks for the clarification. Do you plan to send the dwc3 stuff as well please ?
Best regards, Marek Vasut
participants (5)
-
Inha Song
-
Lukasz Majewski
-
Marek Vasut
-
Rob Herring
-
Tom Rini