Re: [PATCH v2 10/16] dmaengine: bcm-sba-raid: Alloc resources before registering DMA device

From: Anup Patel
Date: Fri Aug 18 2017 - 01:02:00 EST


On Thu, Aug 17, 2017 at 12:08 PM, Vinod Koul <vinod.koul@xxxxxxxxx> wrote:
> On Tue, Aug 01, 2017 at 04:07:54PM +0530, Anup Patel wrote:
>> We should allocate DMA channel resources before registering the
>> DMA device in sba_probe() because we can get DMA request soon
>> after registering the DMA device. If DMA channel resources are
>> not allocated before first DMA request then SBA-RAID driver will
>> crash.
>>
>> Signed-off-by: Anup Patel <anup.patel@xxxxxxxxxxxx>
>> ---
>> drivers/dma/bcm-sba-raid.c | 30 +++++++++++++++---------------
>> 1 file changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/dma/bcm-sba-raid.c b/drivers/dma/bcm-sba-raid.c
>> index f6616da..f14ed0a 100644
>> --- a/drivers/dma/bcm-sba-raid.c
>> +++ b/drivers/dma/bcm-sba-raid.c
>> @@ -1478,13 +1478,13 @@ static int sba_prealloc_channel_resources(struct sba_device *sba)
>> int i, j, ret = 0;
>> struct sba_request *req = NULL;
>>
>> - sba->resp_base = dma_alloc_coherent(sba->dma_dev.dev,
>> + sba->resp_base = dma_alloc_coherent(sba->mbox_dev,
>
> how does this qualify as move before registering, you seem to be using
> different device now

The sba->dma_dev.dev is assigned in sba_async_register().

Now, if we are calling sba_async_register() after
sba_prealloc_channel_resources() then we cannot
use sba->dma_dev.dev in sba_prealloc_channel_resources()

Regards,
Anup