diff mbox

esp-pci: fixup deadlock with linux

Message ID 1415362952-16047-1-git-send-email-hare@suse.de
State New
Headers show

Commit Message

Hannes Reinecke Nov. 7, 2014, 12:22 p.m. UTC
A linux guest will be issuing messages:

[   32.124042] DC390: Deadlock in DataIn_0: DMA aborted unfinished: 000000 bytes remain!!
[   32.126348] DC390: DataIn_0: DMA State: 0

and the HBA will fail to work properly.
Reason is the emulation is not setting the 'DMA transfer done'
status correctly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 hw/scsi/esp-pci.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Paolo Bonzini Nov. 7, 2014, 12:32 p.m. UTC | #1
On 07/11/2014 13:22, Hannes Reinecke wrote:
> A linux guest will be issuing messages:
> 
> [   32.124042] DC390: Deadlock in DataIn_0: DMA aborted unfinished: 000000 bytes remain!!
> [   32.126348] DC390: DataIn_0: DMA State: 0
> 
> and the HBA will fail to work properly.
> Reason is the emulation is not setting the 'DMA transfer done'
> status correctly.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>

Cc: qemu-stable@nongnu.org

Applied, thanks.

Paolo

> ---

>  hw/scsi/esp-pci.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
> index 82795e6..77b8647 100644
> --- a/hw/scsi/esp-pci.c
> +++ b/hw/scsi/esp-pci.c
> @@ -268,6 +268,8 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
>      /* update status registers */
>      pci->dma_regs[DMA_WBC] -= len;
>      pci->dma_regs[DMA_WAC] += len;
> +    if (pci->dma_regs[DMA_WBC] == 0)
> +        pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE;
>  }
>  
>  static void esp_pci_dma_memory_read(void *opaque, uint8_t *buf, int len)
>
Mark Cave-Ayland Nov. 9, 2014, 9:44 a.m. UTC | #2
On 07/11/14 12:22, Hannes Reinecke wrote:

> A linux guest will be issuing messages:
> 
> [   32.124042] DC390: Deadlock in DataIn_0: DMA aborted unfinished: 000000 bytes remain!!
> [   32.126348] DC390: DataIn_0: DMA State: 0
> 
> and the HBA will fail to work properly.
> Reason is the emulation is not setting the 'DMA transfer done'
> status correctly.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  hw/scsi/esp-pci.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
> index 82795e6..77b8647 100644
> --- a/hw/scsi/esp-pci.c
> +++ b/hw/scsi/esp-pci.c
> @@ -268,6 +268,8 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
>      /* update status registers */
>      pci->dma_regs[DMA_WBC] -= len;
>      pci->dma_regs[DMA_WAC] += len;
> +    if (pci->dma_regs[DMA_WBC] == 0)
> +        pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE;
>  }

Missing braces on the if statement here?

>  static void esp_pci_dma_memory_read(void *opaque, uint8_t *buf, int len)



ATB,

Mark.
Hannes Reinecke Nov. 10, 2014, 7:02 a.m. UTC | #3
On 11/09/2014 10:44 AM, Mark Cave-Ayland wrote:
> On 07/11/14 12:22, Hannes Reinecke wrote:
> 
>> A linux guest will be issuing messages:
>>
>> [   32.124042] DC390: Deadlock in DataIn_0: DMA aborted unfinished: 000000 bytes remain!!
>> [   32.126348] DC390: DataIn_0: DMA State: 0
>>
>> and the HBA will fail to work properly.
>> Reason is the emulation is not setting the 'DMA transfer done'
>> status correctly.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> ---
>>  hw/scsi/esp-pci.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
>> index 82795e6..77b8647 100644
>> --- a/hw/scsi/esp-pci.c
>> +++ b/hw/scsi/esp-pci.c
>> @@ -268,6 +268,8 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
>>      /* update status registers */
>>      pci->dma_regs[DMA_WBC] -= len;
>>      pci->dma_regs[DMA_WAC] += len;
>> +    if (pci->dma_regs[DMA_WBC] == 0)
>> +        pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE;
>>  }
> 
> Missing braces on the if statement here?
> 
Sigh.

If you insist ...

Cheers,

Hannes
Gonglei (Arei) Nov. 10, 2014, 7:39 a.m. UTC | #4
On 2014/11/10 15:02, Hannes Reinecke wrote:

> On 11/09/2014 10:44 AM, Mark Cave-Ayland wrote:
>> On 07/11/14 12:22, Hannes Reinecke wrote:
>>
>>> A linux guest will be issuing messages:
>>>
>>> [   32.124042] DC390: Deadlock in DataIn_0: DMA aborted unfinished: 000000 bytes remain!!
>>> [   32.126348] DC390: DataIn_0: DMA State: 0
>>>
>>> and the HBA will fail to work properly.
>>> Reason is the emulation is not setting the 'DMA transfer done'
>>> status correctly.
>>>
>>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>>> ---
>>>  hw/scsi/esp-pci.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
>>> index 82795e6..77b8647 100644
>>> --- a/hw/scsi/esp-pci.c
>>> +++ b/hw/scsi/esp-pci.c
>>> @@ -268,6 +268,8 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
>>>      /* update status registers */
>>>      pci->dma_regs[DMA_WBC] -= len;
>>>      pci->dma_regs[DMA_WAC] += len;
>>> +    if (pci->dma_regs[DMA_WBC] == 0)
>>> +        pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE;
>>>  }
>>
>> Missing braces on the if statement here?
>>
> Sigh.
> 
> If you insist ...
> 
> Cheers,
> 
> Hannes

That's the Qemu coding style.
And you will fail ./script/checkpatch.pl.

Best regards,
-Gonglei
Hannes Reinecke Nov. 10, 2014, 7:50 a.m. UTC | #5
On 11/10/2014 08:39 AM, Gonglei wrote:
> On 2014/11/10 15:02, Hannes Reinecke wrote:
> 
>> On 11/09/2014 10:44 AM, Mark Cave-Ayland wrote:
>>> On 07/11/14 12:22, Hannes Reinecke wrote:
>>>
>>>> A linux guest will be issuing messages:
>>>>
>>>> [   32.124042] DC390: Deadlock in DataIn_0: DMA aborted unfinished: 000000 bytes remain!!
>>>> [   32.126348] DC390: DataIn_0: DMA State: 0
>>>>
>>>> and the HBA will fail to work properly.
>>>> Reason is the emulation is not setting the 'DMA transfer done'
>>>> status correctly.
>>>>
>>>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>>>> ---
>>>>  hw/scsi/esp-pci.c | 2 ++
>>>>  1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
>>>> index 82795e6..77b8647 100644
>>>> --- a/hw/scsi/esp-pci.c
>>>> +++ b/hw/scsi/esp-pci.c
>>>> @@ -268,6 +268,8 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
>>>>      /* update status registers */
>>>>      pci->dma_regs[DMA_WBC] -= len;
>>>>      pci->dma_regs[DMA_WAC] += len;
>>>> +    if (pci->dma_regs[DMA_WBC] == 0)
>>>> +        pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE;
>>>>  }
>>>
>>> Missing braces on the if statement here?
>>>
>> Sigh.
>>
>> If you insist ...
>>
>> Cheers,
>>
>> Hannes
> 
> That's the Qemu coding style.
> And you will fail ./script/checkpatch.pl.
> 
I know. After all, it's not the first patch I've sent.

But I always get the various codingstyle thingies
mixed up.

Cheers,

Hannes
Gonglei (Arei) Nov. 10, 2014, 7:55 a.m. UTC | #6
On 2014/11/10 15:50, Hannes Reinecke wrote:

> On 11/10/2014 08:39 AM, Gonglei wrote:
>> On 2014/11/10 15:02, Hannes Reinecke wrote:
>>
>>> On 11/09/2014 10:44 AM, Mark Cave-Ayland wrote:
>>>> On 07/11/14 12:22, Hannes Reinecke wrote:
>>>>
>>>>> A linux guest will be issuing messages:
>>>>>
>>>>> [   32.124042] DC390: Deadlock in DataIn_0: DMA aborted unfinished: 000000 bytes remain!!
>>>>> [   32.126348] DC390: DataIn_0: DMA State: 0
>>>>>
>>>>> and the HBA will fail to work properly.
>>>>> Reason is the emulation is not setting the 'DMA transfer done'
>>>>> status correctly.
>>>>>
>>>>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>>>>> ---
>>>>>  hw/scsi/esp-pci.c | 2 ++
>>>>>  1 file changed, 2 insertions(+)
>>>>>
>>>>> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
>>>>> index 82795e6..77b8647 100644
>>>>> --- a/hw/scsi/esp-pci.c
>>>>> +++ b/hw/scsi/esp-pci.c
>>>>> @@ -268,6 +268,8 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
>>>>>      /* update status registers */
>>>>>      pci->dma_regs[DMA_WBC] -= len;
>>>>>      pci->dma_regs[DMA_WAC] += len;
>>>>> +    if (pci->dma_regs[DMA_WBC] == 0)
>>>>> +        pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE;
>>>>>  }
>>>>
>>>> Missing braces on the if statement here?
>>>>
>>> Sigh.
>>>
>>> If you insist ...
>>>
>>> Cheers,
>>>
>>> Hannes
>>
>> That's the Qemu coding style.
>> And you will fail ./script/checkpatch.pl.
>>
> I know. After all, it's not the first patch I've sent.
> 
> But I always get the various codingstyle thingies
> mixed up.
> 
Hum. Each community has its own rules :)


Best regards,
-Gonglei
Paolo Bonzini Nov. 10, 2014, 10:31 a.m. UTC | #7
On 10/11/2014 08:02, Hannes Reinecke wrote:
> On 11/09/2014 10:44 AM, Mark Cave-Ayland wrote:
>> On 07/11/14 12:22, Hannes Reinecke wrote:
>>
>>> A linux guest will be issuing messages:
>>>
>>> [   32.124042] DC390: Deadlock in DataIn_0: DMA aborted unfinished: 000000 bytes remain!!
>>> [   32.126348] DC390: DataIn_0: DMA State: 0
>>>
>>> and the HBA will fail to work properly.
>>> Reason is the emulation is not setting the 'DMA transfer done'
>>> status correctly.
>>>
>>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>>> ---
>>>  hw/scsi/esp-pci.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
>>> index 82795e6..77b8647 100644
>>> --- a/hw/scsi/esp-pci.c
>>> +++ b/hw/scsi/esp-pci.c
>>> @@ -268,6 +268,8 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
>>>      /* update status registers */
>>>      pci->dma_regs[DMA_WBC] -= len;
>>>      pci->dma_regs[DMA_WAC] += len;
>>> +    if (pci->dma_regs[DMA_WBC] == 0)
>>> +        pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE;
>>>  }
>>
>> Missing braces on the if statement here?
>>
> Sigh.

I'll fix this, no need to resend.

Paolo
diff mbox

Patch

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 82795e6..77b8647 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -268,6 +268,8 @@  static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
     /* update status registers */
     pci->dma_regs[DMA_WBC] -= len;
     pci->dma_regs[DMA_WAC] += len;
+    if (pci->dma_regs[DMA_WBC] == 0)
+        pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE;
 }
 
 static void esp_pci_dma_memory_read(void *opaque, uint8_t *buf, int len)