[PATCH v3 4/9] msix: simplify the conditional in msix_set/unset_vector_notifiers

Longpeng(Mike) posted 9 patches 4 years, 4 months ago
Maintainers: Alex Williamson <alex.williamson@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
[PATCH v3 4/9] msix: simplify the conditional in msix_set/unset_vector_notifiers
Posted by Longpeng(Mike) 4 years, 4 months ago
'msix_function_masked' is synchronized with the device's config,
we can use it to replace the complex conditional statementis in
msix_set/unset_vector_notifiers.

Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
---
 hw/pci/msix.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index ae9331cd0b..67682289af 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -592,8 +592,7 @@ int msix_set_vector_notifiers(PCIDevice *dev,
     dev->msix_vector_release_notifier = release_notifier;
     dev->msix_vector_poll_notifier = poll_notifier;
 
-    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
-        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
+    if (!dev->msix_function_masked) {
         for (vector = 0; vector < dev->msix_entries_nr; vector++) {
             ret = msix_set_notifier_for_vector(dev, vector);
             if (ret < 0) {
@@ -622,8 +621,7 @@ void msix_unset_vector_notifiers(PCIDevice *dev)
     assert(dev->msix_vector_use_notifier &&
            dev->msix_vector_release_notifier);
 
-    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
-        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
+    if (!dev->msix_function_masked) {
         for (vector = 0; vector < dev->msix_entries_nr; vector++) {
             msix_unset_notifier_for_vector(dev, vector);
         }
-- 
2.23.0


Re: [PATCH v3 4/9] msix: simplify the conditional in msix_set/unset_vector_notifiers
Posted by Alex Williamson 4 years, 4 months ago
On Tue, 21 Sep 2021 07:01:57 +0800
"Longpeng(Mike)" <longpeng2@huawei.com> wrote:

> 'msix_function_masked' is synchronized with the device's config,
> we can use it to replace the complex conditional statementis in
> msix_set/unset_vector_notifiers.
> 
> Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
> ---
>  hw/pci/msix.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/pci/msix.c b/hw/pci/msix.c
> index ae9331cd0b..67682289af 100644
> --- a/hw/pci/msix.c
> +++ b/hw/pci/msix.c
> @@ -592,8 +592,7 @@ int msix_set_vector_notifiers(PCIDevice *dev,
>      dev->msix_vector_release_notifier = release_notifier;
>      dev->msix_vector_poll_notifier = poll_notifier;
>  
> -    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
> -        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
> +    if (!dev->msix_function_masked) {
>          for (vector = 0; vector < dev->msix_entries_nr; vector++) {
>              ret = msix_set_notifier_for_vector(dev, vector);
>              if (ret < 0) {
> @@ -622,8 +621,7 @@ void msix_unset_vector_notifiers(PCIDevice *dev)
>      assert(dev->msix_vector_use_notifier &&
>             dev->msix_vector_release_notifier);
>  
> -    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
> -        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
> +    if (!dev->msix_function_masked) {
>          for (vector = 0; vector < dev->msix_entries_nr; vector++) {
>              msix_unset_notifier_for_vector(dev, vector);
>          }

This appears to be a cleanup that's not required for the functionality
of this series.  I'd suggest proposing it separately.  Same for the
patch 5/9 in this series.  If it makes a functional difference it
should be described in the commit log.  Thanks,

Alex


RE: [PATCH v3 4/9] msix: simplify the conditional in msix_set/unset_vector_notifiers
Posted by Longpeng (Mike, Cloud Infrastructure Service Product Dept.) 4 years, 4 months ago

> -----Original Message-----
> From: Alex Williamson [mailto:alex.williamson@redhat.com]
> Sent: Saturday, October 2, 2021 7:04 AM
> To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
> <longpeng2@huawei.com>
> Cc: philmd@redhat.com; pbonzini@redhat.com; marcel.apfelbaum@gmail.com;
> mst@redhat.com; qemu-devel@nongnu.org; Gonglei (Arei)
> <arei.gonglei@huawei.com>; chenjiashang <chenjiashang@huawei.com>
> Subject: Re: [PATCH v3 4/9] msix: simplify the conditional in
> msix_set/unset_vector_notifiers
> 
> On Tue, 21 Sep 2021 07:01:57 +0800
> "Longpeng(Mike)" <longpeng2@huawei.com> wrote:
> 
> > 'msix_function_masked' is synchronized with the device's config,
> > we can use it to replace the complex conditional statementis in
> > msix_set/unset_vector_notifiers.
> >
> > Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
> > ---
> >  hw/pci/msix.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/pci/msix.c b/hw/pci/msix.c
> > index ae9331cd0b..67682289af 100644
> > --- a/hw/pci/msix.c
> > +++ b/hw/pci/msix.c
> > @@ -592,8 +592,7 @@ int msix_set_vector_notifiers(PCIDevice *dev,
> >      dev->msix_vector_release_notifier = release_notifier;
> >      dev->msix_vector_poll_notifier = poll_notifier;
> >
> > -    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
> > -        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
> > +    if (!dev->msix_function_masked) {
> >          for (vector = 0; vector < dev->msix_entries_nr; vector++) {
> >              ret = msix_set_notifier_for_vector(dev, vector);
> >              if (ret < 0) {
> > @@ -622,8 +621,7 @@ void msix_unset_vector_notifiers(PCIDevice *dev)
> >      assert(dev->msix_vector_use_notifier &&
> >             dev->msix_vector_release_notifier);
> >
> > -    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
> > -        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
> > +    if (!dev->msix_function_masked) {
> >          for (vector = 0; vector < dev->msix_entries_nr; vector++) {
> >              msix_unset_notifier_for_vector(dev, vector);
> >          }
> 
> This appears to be a cleanup that's not required for the functionality
> of this series.  I'd suggest proposing it separately.  Same for the
> patch 5/9 in this series.  If it makes a functional difference it
> should be described in the commit log.  Thanks,
> 

OK, will remove these two patches in the v4, thanks.

> Alex