From: "Jiawen Wu" <jiawenwu@trustnetic.com>
To: "'Michal Kubiak'" <michal.kubiak@intel.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <horms@kernel.org>, <andrew@lunn.ch>,
<netdev@vger.kernel.org>, <przemyslaw.kitszel@intel.com>,
<mengyuanlou@net-swift.com>, <duanqiangwen@net-swift.com>
Subject: RE: [PATCH net v3 1/4] net: txgbe: initialize num_q_vectors for MSI/INTx interrupts
Date: Wed, 3 Jul 2024 09:45:09 +0800 [thread overview]
Message-ID: <075201daccea$a33739d0$e9a5ad70$@trustnetic.com> (raw)
In-Reply-To: <ZoQbChC5gTNxBNtI@localhost.localdomain>
On Tue, Jul 2, 2024 11:22 PM, Michal Kubiak wrote:
> On Mon, Jul 01, 2024 at 03:14:13PM +0800, Jiawen Wu wrote:
> > When using MSI/INTx interrupts, wx->num_q_vectors is uninitialized.
> > Thus there will be kernel panic in wx_alloc_q_vectors() to allocate
> > queue vectors.
> >
> > Fixes: 3f703186113f ("net: libwx: Add irq flow functions")
> > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> > ---
> > drivers/net/ethernet/wangxun/libwx/wx_lib.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> > index 68bde91b67a0..f53776877f71 100644
> > --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> > +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> > @@ -1686,6 +1686,7 @@ static int wx_set_interrupt_capability(struct wx *wx)
> > }
> >
> > pdev->irq = pci_irq_vector(pdev, 0);
> > + wx->num_q_vectors = 1;
>
> I would suggest improving readability of that logic. TBH, initially it wasn't
> obvious to me why you assign 1 to num_q_vectors (instead of nvecs variable).
> Maybe you just want to exit with an error when nvecs != 1 and avoid some nesting.
> I think that should make that logic easier to read. For example:
>
> /* minmum one for queue, one for misc*/
> nvecs = 1;
> nvecs = pci_alloc_irq_vectors(pdev, nvecs,
> nvecs, PCI_IRQ_MSI | PCI_IRQ_INTX);
> if (nvecs != 1) {
> wx_err(wx, "Failed to allocate MSI/INTx interrupts. Error: %d\n", nvecs);
> return nvecs;
> }
>
> if (pdev->msi_enabled)
> wx_err(wx, "Fallback to MSI.\n");
> else
> wx_err(wx, "Fallback to INTx.\n");
>
> pdev->irq = pci_irq_vector(pdev, 0);
> wx->num_q_vectors = 1;
>
> (Please consider it as a suggestion only).
Thanks for the suggestion, it can be considered as a commit for code optimization.
next prev parent reply other threads:[~2024-07-03 1:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 7:14 [PATCH net v3 0/4] net: txgbe: fix MSI and INTx interrupts Jiawen Wu
2024-07-01 7:14 ` [PATCH net v3 1/4] net: txgbe: initialize num_q_vectors for MSI/INTx interrupts Jiawen Wu
2024-07-02 15:21 ` Michal Kubiak
2024-07-03 1:45 ` Jiawen Wu [this message]
2024-07-01 7:14 ` [PATCH net v3 2/4] net: txgbe: remove separate irq request for MSI and INTx Jiawen Wu
2024-07-03 13:33 ` Michal Kubiak
2024-07-03 14:53 ` Michal Kubiak
2024-07-01 7:14 ` [PATCH net v3 3/4] net: txgbe: add extra handle for MSI/INTx into thread irq handle Jiawen Wu
2024-07-01 7:14 ` [PATCH net v3 4/4] net: txgbe: free isb resources at the right time Jiawen Wu
2024-07-02 14:10 ` [PATCH net v3 0/4] net: txgbe: fix MSI and INTx interrupts patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='075201daccea$a33739d0$e9a5ad70$@trustnetic.com' \
--to=jiawenwu@trustnetic.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=duanqiangwen@net-swift.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=mengyuanlou@net-swift.com \
--cc=michal.kubiak@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).