qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH 1/7] libqos/ahci: track sector size


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/7] libqos/ahci: track sector size
Date: Wed, 6 Jun 2018 16:40:51 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 06/06/2018 04:09 PM, John Snow wrote:
> It's not always 512, and it does wind up mattering for PIO tranfers,
> because this means DRQ blocks are four times as big for ATAPI.
> Replace an instance of 2048 with the correct define, too.
> 
> This patch by itself winds changing no behavior. fis->count is ignored
> for CMD_PACKET, and sect_count only gets used in non-ATAPI cases.
> 
> Signed-off-by: John Snow <address@hidden>

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

> ---
>  tests/libqos/ahci.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
> index bc201d762b..63e1f9b92d 100644
> --- a/tests/libqos/ahci.c
> +++ b/tests/libqos/ahci.c
> @@ -90,6 +90,7 @@ struct AHCICommand {
>      uint32_t interrupts;
>      uint64_t xbytes;
>      uint32_t prd_size;
> +    uint32_t sector_size;
>      uint64_t buffer;
>      AHCICommandProp *props;
>      /* Data to be transferred to the guest */
> @@ -796,7 +797,7 @@ static void command_header_init(AHCICommand *cmd)
>  static void command_table_init(AHCICommand *cmd)
>  {
>      RegH2DFIS *fis = &(cmd->fis);
> -    uint16_t sect_count = (cmd->xbytes / AHCI_SECTOR_SIZE);
> +    uint16_t sect_count = (cmd->xbytes / cmd->sector_size);
>  
>      fis->fis_type = REG_H2D_FIS;
>      fis->flags = REG_H2D_FIS_CMD; /* "Command" bit */
> @@ -819,7 +820,7 @@ static void command_table_init(AHCICommand *cmd)
>          if (cmd->props->lba28 || cmd->props->lba48) {
>              fis->device = ATA_DEVICE_LBA;
>          }
> -        fis->count = (cmd->xbytes / AHCI_SECTOR_SIZE);
> +        fis->count = (cmd->xbytes / cmd->sector_size);
>      }
>      fis->icc = 0x00;
>      fis->control = 0x00;
> @@ -857,6 +858,7 @@ AHCICommand *ahci_command_create(uint8_t command_name)
>      cmd->xbytes = props->size;
>      cmd->prd_size = 4096;
>      cmd->buffer = 0xabad1dea;
> +    cmd->sector_size = props->atapi ? ATAPI_SECTOR_SIZE : AHCI_SECTOR_SIZE;
>  
>      if (!cmd->props->ncq) {
>          cmd->interrupts = AHCI_PX_IS_DHRS;
> @@ -1033,7 +1035,7 @@ void ahci_command_set_buffer(AHCICommand *cmd, uint64_t 
> buffer)
>  static void ahci_atapi_set_size(AHCICommand *cmd, uint64_t xbytes)
>  {
>      unsigned char *cbd = cmd->atapi_cmd;
> -    uint64_t nsectors = xbytes / 2048;
> +    uint64_t nsectors = xbytes / ATAPI_SECTOR_SIZE;
>      uint32_t tmp;
>      g_assert(cbd);
>  
> @@ -1080,7 +1082,7 @@ void ahci_command_set_sizes(AHCICommand *cmd, uint64_t 
> xbytes,
>          cmd->prd_size = prd_size;
>      }
>      cmd->xbytes = xbytes;
> -    sect_count = (cmd->xbytes / AHCI_SECTOR_SIZE);
> +    sect_count = (cmd->xbytes / cmd->sector_size);
>  
>      if (cmd->props->ncq) {
>          NCQFIS *nfis = (NCQFIS *)&(cmd->fis);
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]