*Re: [PATCH] usb: dwc3: Add shutdown to platform_driver
2019-08-27 11:53 ` Felipe Balbi@ 2019-08-27 12:16 ` Vicente Bergas
2019-09-09 15:07 ` Vicente Bergas0 siblings, 1 reply; 13+ messages in thread
From: Vicente Bergas @ 2019-08-27 12:16 UTC (permalink / raw)
To: Felipe Balbi
Cc: Robin Murphy, Heiko Stuebner, Will Deacon, MarcZyngier,
Catalin Marinas, Matthias Brugger, Greg Kroah-Hartman, linux-usb,
linux-arm-kernel, linux-rockchip
On Tuesday, August 27, 2019 1:53:04 PM CEST, Felipe Balbi wrote:
> Hi,
>
> Vicente Bergas <vicencb@gmail.com> writes:
>> On Saturday, August 17, 2019 7:41:40 PM CEST, Vicente Bergas wrote:
>>> Otherwise the device keeps writing to memory after kexec and disturbs
>>> the next kernel.
...
>
> why don't you just have shutdown use the same exact function as remove?
> Frankly, though, I still don't fully understand what's going wrong
> here. Why is the device still alive during kexec?
>
> cheers
Hi Felipe,
the remove and shutdown functions have different prototypes, so
shutdown is wrapping remove.
Would it be preferable to cast remove as shutdown?
The issue with kexec is that the device is being used during the livetime
of the first kernel. When the first kernel executes kexec it calls the
shutdown function of drivers (instead of remove). Because of this the dwc3
device keeps doing things like DMA.
While the second kernel is taking over, it gets its memory corrupted with
such DMA accesses from the device. When the second kernel reaches the point
of taking over the dwc3 device, re-initializes it, but it is already too
late. Still worse, if the second kernel did not have the dwc3 driver, it
would get endless memory corruptions.
All in all, devices that can do DMA need to stop doing it on shutdown.
Regards,
Vicenç.
^permalinkrawreply [flat|nested] 13+ messages in thread

*Re: [PATCH] usb: dwc3: Add shutdown to platform_driver
2019-08-27 12:16 ` Vicente Bergas@ 2019-09-09 15:07 ` Vicente Bergas0 siblings, 0 replies; 13+ messages in thread
From: Vicente Bergas @ 2019-09-09 15:07 UTC (permalink / raw)
To: Felipe Balbi, Robin Murphy
Cc: Heiko Stuebner, Will Deacon, MarcZyngier, Catalin Marinas,
Matthias Brugger, Greg Kroah-Hartman, linux-usb,
linux-arm-kernel, linux-rockchip
On Tuesday, August 27, 2019 2:16:20 PM CEST, Vicente Bergas wrote:
> On Tuesday, August 27, 2019 1:53:04 PM CEST, Felipe Balbi wrote:
>> Hi,
>>
>> Vicente Bergas <vicencb@gmail.com> writes:
>>> On Saturday, August 17, 2019 7:41:40 PM CEST, Vicente Bergas wrote:
>>>> Otherwise the device keeps writing to memory after kexec and disturbs
>>>> the next kernel.
> ...
>>
>> why don't you just have shutdown use the same exact function as remove?
>> Frankly, though, I still don't fully understand what's going wrong
>> here. Why is the device still alive during kexec?
>>
>> cheers
>
> Hi Felipe,
> the remove and shutdown functions have different prototypes, so
> shutdown is wrapping remove.
> Would it be preferable to cast remove as shutdown?
>
> The issue with kexec is that the device is being used during the livetime
> of the first kernel. When the first kernel executes kexec it calls the
> shutdown function of drivers (instead of remove). Because of this the dwc3
> device keeps doing things like DMA.
> While the second kernel is taking over, it gets its memory corrupted with
> such DMA accesses from the device. When the second kernel reaches the point
> of taking over the dwc3 device, re-initializes it, but it is already too
> late. Still worse, if the second kernel did not have the dwc3 driver, it
> would get endless memory corruptions.
> All in all, devices that can do DMA need to stop doing it on shutdown.
>
> Regards,
> Vicenç.
Hi,
please, can you provide some feedback on this?
Regards,
Vicenç.
^permalinkrawreply [flat|nested] 13+ messages in thread