[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 09/11] megasas: change msi/msix property type
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v6 09/11] megasas: change msi/msix property type |
Date: |
Wed, 01 Jun 2016 11:14:58 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Cao jin <address@hidden> writes:
>>From bit to enum OnOffAuto.
>
> cc: Hannes Reinecke <address@hidden>
> cc: Paolo Bonzini <address@hidden>
> cc: Michael S. Tsirkin <address@hidden>
> cc: Markus Armbruster <address@hidden>
> cc: Marcel Apfelbaum <address@hidden>
>
> Signed-off-by: Cao jin <address@hidden>
> ---
> hw/scsi/megasas.c | 28 +++++++++++-----------------
> 1 file changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> index 56fb645..e71a28b 100644
> --- a/hw/scsi/megasas.c
> +++ b/hw/scsi/megasas.c
> @@ -48,11 +48,7 @@
>
> #define MEGASAS_FLAG_USE_JBOD 0
> #define MEGASAS_MASK_USE_JBOD (1 << MEGASAS_FLAG_USE_JBOD)
> -#define MEGASAS_FLAG_USE_MSI 1
> -#define MEGASAS_MASK_USE_MSI (1 << MEGASAS_FLAG_USE_MSI)
> -#define MEGASAS_FLAG_USE_MSIX 2
> -#define MEGASAS_MASK_USE_MSIX (1 << MEGASAS_FLAG_USE_MSIX)
> -#define MEGASAS_FLAG_USE_QUEUE64 3
> +#define MEGASAS_FLAG_USE_QUEUE64 1
> #define MEGASAS_MASK_USE_QUEUE64 (1 << MEGASAS_FLAG_USE_QUEUE64)
>
> static const char *mfi_frame_desc[] = {
> @@ -96,6 +92,8 @@ typedef struct MegasasState {
> int busy;
> int diag;
> int adp_reset;
> + OnOffAuto msi;
> + OnOffAuto msix;
>
> MegasasCmd *event_cmd;
> int event_locale;
> @@ -159,12 +157,12 @@ static bool megasas_use_queue64(MegasasState *s)
>
> static bool megasas_use_msi(MegasasState *s)
> {
> - return s->flags & MEGASAS_MASK_USE_MSI;
> + return s->msi == ON_OFF_AUTO_AUTO || s->msi == ON_OFF_AUTO_ON;
s->msi != ON_OFF_AUTO_OFF, please.
> }
As we'll see below, s->msi changes on realize().
Before the first realize(), it's whatever the user put there.
Before this patch: megasas_mask_use_msi() returns false when the
user explicitly requested msi=off, and true when the user did
nothing or requested msi=on.
After this patch: it returns false when the user explicitly
requested msi=off, and true true when the user did nothing or
requested msi=on or msi=auto. Okay.
Afterwards, it reflects MSI capability.
Before this patch: megasas_mask_use_msi() returns false when the
device has no MSI capability, either because the user suppressed it
with msi=off, or because we couldn't add it.
After this patch: same. Okay.
>
> static bool megasas_use_msix(MegasasState *s)
> {
> - return s->flags & MEGASAS_MASK_USE_MSIX;
> + return s->msix == ON_OFF_AUTO_AUTO || s->msix == ON_OFF_AUTO_ON;
s->msi != ON_OFF_AUTO_OFF, please.
> }
Same correctness argument as for megasas_mask_use_msi().
>
> static bool megasas_is_jbod(MegasasState *s)
> @@ -2349,12 +2347,12 @@ static void megasas_scsi_realize(PCIDevice *dev,
> Error **errp)
>
> if (megasas_use_msi(s) &&
> msi_init(dev, 0x50, 1, true, false) < 0) {
> - s->flags &= ~MEGASAS_MASK_USE_MSI;
> + s->msi = ON_OFF_AUTO_OFF;
> }
> if (megasas_use_msix(s) &&
> msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000,
> &s->mmio_io, b->mmio_bar, 0x3800, 0x68)) {
> - s->flags &= ~MEGASAS_MASK_USE_MSIX;
> + s->msix = ON_OFF_AUTO_OFF;
> }
> if (pci_is_express(dev)) {
> pcie_endpoint_cap_init(dev, 0xa0);
Unlike the device models we've seen in earlier patches, this one
overwrites its configuration to reflect actual device state. Hmm. I'll
revisit this in my review of PATCH 11.
> @@ -2422,10 +2420,8 @@ static Property megasas_properties_gen1[] = {
> MEGASAS_DEFAULT_FRAMES),
> DEFINE_PROP_STRING("hba_serial", MegasasState, hba_serial),
> DEFINE_PROP_UINT64("sas_address", MegasasState, sas_addr, 0),
> - DEFINE_PROP_BIT("use_msi", MegasasState, flags,
> - MEGASAS_FLAG_USE_MSI, false),
> - DEFINE_PROP_BIT("use_msix", MegasasState, flags,
> - MEGASAS_FLAG_USE_MSIX, false),
> + DEFINE_PROP_ON_OFF_AUTO("msi", MegasasState, msi, ON_OFF_AUTO_AUTO),
> + DEFINE_PROP_ON_OFF_AUTO("msix", MegasasState, msix, ON_OFF_AUTO_AUTO),
> DEFINE_PROP_BIT("use_jbod", MegasasState, flags,
> MEGASAS_FLAG_USE_JBOD, false),
> DEFINE_PROP_END_OF_LIST(),
> @@ -2438,10 +2434,8 @@ static Property megasas_properties_gen2[] = {
> MEGASAS_GEN2_DEFAULT_FRAMES),
> DEFINE_PROP_STRING("hba_serial", MegasasState, hba_serial),
> DEFINE_PROP_UINT64("sas_address", MegasasState, sas_addr, 0),
> - DEFINE_PROP_BIT("use_msi", MegasasState, flags,
> - MEGASAS_FLAG_USE_MSI, true),
> - DEFINE_PROP_BIT("use_msix", MegasasState, flags,
> - MEGASAS_FLAG_USE_MSIX, true),
> + DEFINE_PROP_ON_OFF_AUTO("msi", MegasasState, msi, ON_OFF_AUTO_AUTO),
> + DEFINE_PROP_ON_OFF_AUTO("msix", MegasasState, msix, ON_OFF_AUTO_AUTO),
> DEFINE_PROP_BIT("use_jbod", MegasasState, flags,
> MEGASAS_FLAG_USE_JBOD, false),
> DEFINE_PROP_END_OF_LIST(),
- Re: [Qemu-devel] [PATCH v6 09/11] megasas: change msi/msix property type,
Markus Armbruster <=