Message ID | 1465200062-13824-10-git-send-email-caoj.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 06/06/2016 10:00 AM, Cao jin wrote: > From bit to enum OnOffAuto. > > cc: Hannes Reinecke <hare@suse.de> > cc: Paolo Bonzini <pbonzini@redhat.com> > cc: Michael S. Tsirkin <mst@redhat.com> > cc: Markus Armbruster <armbru@redhat.com> > cc: Marcel Apfelbaum <marcel@redhat.com> > > Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> > --- > 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..635be13 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_OFF; > } > > static bool megasas_use_msix(MegasasState *s) > { > - return s->flags & MEGASAS_MASK_USE_MSIX; > + return s->msix != ON_OFF_AUTO_OFF; > } > > 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); > @@ -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(), > What is the default value of 'ON_OFF_AUTO_AUTO'? Originally we've disabled MSI-X for gen1, and enabled it for gen2. Is this behaviour carried over? Cheers, Hannes
On 06/06/2016 04:27 PM, Hannes Reinecke wrote: > On 06/06/2016 10:00 AM, Cao jin wrote: >> @@ -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(), >> > What is the default value of 'ON_OFF_AUTO_AUTO'? > Originally we've disabled MSI-X for gen1, and enabled it for gen2. > Is this behaviour carried over? > default value of auto is on. Seems the behaviour is not carried over. If it must be carried over, gen1 will be the only one exception in all devices, which seems little weird. is any special reason for gen1 to be msi/msix-incapable by default? > Cheers, > > Hannes >
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 56fb645..635be13 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_OFF; } static bool megasas_use_msix(MegasasState *s) { - return s->flags & MEGASAS_MASK_USE_MSIX; + return s->msix != ON_OFF_AUTO_OFF; } 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); @@ -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(),
From bit to enum OnOffAuto. cc: Hannes Reinecke <hare@suse.de> cc: Paolo Bonzini <pbonzini@redhat.com> cc: Michael S. Tsirkin <mst@redhat.com> cc: Markus Armbruster <armbru@redhat.com> cc: Marcel Apfelbaum <marcel@redhat.com> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> --- hw/scsi/megasas.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)