From: Marek Vasut <marex@denx.de>
To: "Bjørn Erik Nilsen" <ben@datarespons.no>
Cc: Jingoo Han <jg1.han@samsung.com>,
"'Pratyush Anand'" <pratyush.anand@gmail.com>,
"'Bjorn Helgaas'" <bhelgaas@google.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"'Kishon Vijay Abraham I'" <kishon@ti.com>,
"'Mohit KUMAR DCG'" <Mohit.KUMAR@st.com>,
"'Ajay KHANDELWAL'" <ajay.khandelwal@st.com>,
"'Tim Harvey'" <tharvey@gateworks.com>,
"'Eric Nelson'" <Eric.Nelson@boundarydevices.com>,
"'Troy Kisky'" <troy.kisky@boundarydevices.com>
Subject: Re: [PATCH] Kernel oops from pci_disable_msi
Date: Tue, 26 Nov 2013 22:19:49 +0100 [thread overview]
Message-ID: <201311262219.49115.marex@denx.de> (raw)
In-Reply-To: <cmu-lmtpd-32538-1385137032-0@frontend1.mail.m-online.net>
Dear Bjørn Erik Nilsen,
[...]
> > > Thank you for your effort!
> > > I reproduced this kernel panic on Exynos platform with LAN card.
> > > And then, I tested your patch and checked this kernel panic is
> > > resolved.
> > >
> > > Marek Vasut,
> > > Will you test Bjørn Erik Nilsen's patch with your i.MX platform?
> > >
> > > Pratyush Anand,
> > > Would you confirm Bjørn Erik Nilsen's patch?
> > >
> > > I will do more extensive testing.
> > > Thank you.
> >
> > The patch does indeed fix the crash, but there are more subtle issues
> > lurking around. I noticed how irq numbers were constantly increasing and
> > I found at least one stupid mistake that I made.
> >
> > > - irq_set_msi_desc(irq + i, desc);
> > > + irq_set_msi_desc_off(irq + i, i, desc);
> >
> > That should be 'irq_set_msi_desc_off(irq, i, desc)'
> >
> > (I'm really puzzled why this didn't cause other oops ...)
> >
> > I also realized that teardown() is only called for the irq returned from
> > setup(), which kind of makes sense since the others are destroyed() in
> > the first call to teardown. This means we need to iterate all irqs in
> > the same fashion as we allocate in setup/assign_irq. Basically unrolling
> > what was done there.
> >
> > I'm hacking on this solution now but it doesn't quite take me to where I
> > want at the moment, so it would be nice if someone with a better
> > understanding of the code could pitch in.
>
> I gave it another shot and now it starts to look like something. At
> least I get consistent irq numbers and my system is very stable in
> general.
>
> My new patch does exactly the opposite in teardown() of what is done in
> setup(), which in itself is a good sign.
>
> --- pcie-designware.c.orig 2013-11-21 14:02:03.656007695 +0100
> +++ pcie-designware.c 2013-11-22 16:32:30.360954591 +0100
> @@ -242,11 +242,15 @@ static int assign_irq(int no_irqs, struc
> if (!irq)
> goto no_valid_irq;
>
> + /*
> + * irq_domain_add_linear (called from dw_pcie_host_init)
> pre-allocates + * descs so there is no need to call irq_alloc_descs
> here. + */
> +
> i = 0;
> while (i < no_irqs) {
> set_bit(pos0 + i, pp->msi_irq_in_use);
> - irq_alloc_descs((irq + i), (irq + i), 1, 0);
> - irq_set_msi_desc(irq + i, desc);
> + irq_set_msi_desc_off(irq, i, desc);
Why do you not allocate the descs anymore ?
> /*Enable corresponding interrupt in MSI interrupt
> controller */ res = ((pos0 + i) / 32) * 12;
> bit = (pos0 + i) % 32;
> @@ -266,7 +270,7 @@ no_valid_irq:
>
> static void clear_irq(unsigned int irq)
> {
> - int res, bit, val, pos;
> struct irq_desc *desc;
> struct msi_desc *msi;
> struct pcie_port *pp;
> @@ -281,18 +285,28 @@ static void clear_irq(unsigned int irq)
> return;
> }
>
> + /* undo what was done in assign_irq */
> pos = data->hwirq;
> + nvec = 1 << msi->msi_attrib.multiple;
>
> - irq_free_desc(irq);
> -
> - clear_bit(pos, pp->msi_irq_in_use);
> + i = 0;
> + while (i < nvec) {
> + clear_bit(pos + i, pp->msi_irq_in_use);
> + irq_set_msi_desc_off(irq, i, NULL);
> + /* Disable corresponding interrupt on MSI interrupt
> controller */ + res = ((pos + i) / 32) * 12;
> + bit = (pos + i) % 32;
> + dw_pcie_rd_own_conf(pp, PCIE_MSI_INTR0_ENABLE + res, 4,
> &val); + val &= ~(1 << bit);
> + dw_pcie_wr_own_conf(pp, PCIE_MSI_INTR0_ENABLE + res, 4,
> val); + ++i;
> + }
>
> - /* Disable corresponding interrupt on MSI interrupt controller */
> - res = (pos / 32) * 12;
> - bit = pos % 32;
> - dw_pcie_rd_own_conf(pp, PCIE_MSI_INTR0_ENABLE + res, 4, &val);
> - val &= ~(1 << bit);
> - dw_pcie_wr_own_conf(pp, PCIE_MSI_INTR0_ENABLE + res, 4, val);
> + msi->msg.address_lo = 0;
> + msi->msg.address_hi = 0;
> + msi->msg.data = 0;
> + msi->irq = 0;
> + msi->msi_attrib.multiple = 0;
> }
>
> static int dw_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev,
> @@ -320,15 +334,14 @@ static int dw_msi_setup_irq(struct msi_c
> if (irq < 0)
> return irq;
>
> - msg_ctr &= ~PCI_MSI_FLAGS_QSIZE;
> - msg_ctr |= msgvec << 4;
> - pci_write_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS,
> - msg_ctr);
> desc->msi_attrib.multiple = msgvec;
> -
> msg.address_lo = virt_to_phys((void *)pp->msi_data);
> msg.address_hi = 0x0;
> msg.data = pos;
> + /*
> + * write_msi_msg() will update PCI_MSI_FLAGS so there
> + * is no need to explicitly call pci_write_config here
> + */
> write_msi_msg(irq, &msg);
>
> return 0;
>
>
> Best regards,
>
> Bjørn Erik Nilsen
Can you try using 'git send-email' for submitting subsequent patches please?
The patch works back and forth, I can 'remove' the card with:
echo 1 > /sys/bus/pci/devices/0000:01:00.0/remove
and then 'rescan' the card with:
echo 1 > /sys/bus/pci/devices/0000:00:00.0/rescan
Tested-by: Marek Vasut <marex@denx.de>
next prev parent reply other threads:[~2013-11-26 21:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <528a1bb6.6a88700a.28c9.ffff824aSMTPIN_ADDED_MISSING@mx.google.com>
[not found] ` <CAErSpo4TbUuq0wb06JV9Xchmcjsk9q3cm7+XO-dOSiJAAhXPMA@mail.gmail.com>
2013-11-18 21:02 ` Kernel oops from pci_disable_msi Bjorn Helgaas
2013-11-18 23:11 ` Jingoo Han
2013-11-19 11:24 ` Marek Vasut
[not found] ` <1384861142.3682.1.camel@bnilsen-HP-EliteBook-8760w>
[not found] ` <cmu-lmtpd-19155-1384861370-13@frontend1.mail.m-online.net>
2013-11-19 22:01 ` Marek Vasut
[not found] ` <cmu-lmtpd-1612-1384936883-21@frontend1.mail.m-online.net>
2013-11-20 10:30 ` Marek Vasut
[not found] ` <cmu-lmtpd-21237-1384948548-21@frontend1.mail.m-online.net>
2013-11-20 12:02 ` Marek Vasut
[not found] ` <cmu-lmtpd-23243-1384949805-3@frontend1.mail.m-online.net>
2013-11-20 13:57 ` Marek Vasut
[not found] ` <1385036087.3945.28.camel@bnilsen-HP>
[not found] ` <1385039987.6020.5.camel@bnilsen-HP>
[not found] ` <16.79.22145.6305E825@epmailin9.samsung.com>
2013-11-22 8:48 ` Jingoo Han
[not found] ` <1385118399.3944.32.camel@bnilsen-HP>
[not found] ` <7D.78.31634.B838F825@epmailin2.samsung.com>
2013-11-26 11:21 ` [PATCH] " Jingoo Han
[not found] ` <cmu-lmtpd-32538-1385137032-0@frontend1.mail.m-online.net>
2013-11-26 21:19 ` Marek Vasut [this message]
[not found] ` <cmu-lmtpd-17794-1385506605-2@frontend1.mail.m-online.net>
2013-11-26 23:05 ` Marek Vasut
2013-11-27 9:46 ` Marek Vasut
[not found] ` <cmu-lmtpd-20073-1385566822-1@frontend1.mail.m-online.net>
2013-11-27 19:05 ` [PATCH v4] " Marek Vasut
[not found] ` <C7.DF.00504.D1216925@epmailin4.samsung.com>
2013-11-29 7:37 ` Jingoo Han
2013-11-29 13:35 ` [PATCH v5 0/2] " Bjørn Erik Nilsen
2013-11-29 13:35 ` [PATCH v5 1/2] PCI: designware: Fix crash in dw_msi_teardown_irq Bjørn Erik Nilsen
2013-11-29 14:32 ` Marek Vasut
[not found] ` <cmu-lmtpd-25244-1385737839-23@frontend1.mail.m-online.net>
2013-11-29 15:36 ` Marek Vasut
[not found] ` <cmu-lmtpd-32360-1385742114-0@frontend1.mail.m-online.net>
2013-11-29 17:02 ` Marek Vasut
[not found] ` <cmu-lmtpd-8418-1385750273-5@frontend1.mail.m-online.net>
2013-12-02 8:10 ` Marek Vasut
2013-11-29 13:35 ` [PATCH v5 2/2] PCI: designware: Remove redundant call to pci_write_config Bjørn Erik Nilsen
2013-12-05 1:52 ` [PATCH v5 0/2] Kernel oops from pci_disable_msi Jingoo Han
2013-12-05 2:18 ` Marek Vasut
2013-12-05 2:24 ` Jingoo Han
2013-12-05 4:07 ` Mohit KUMAR DCG
2013-12-09 20:43 ` Bjorn Helgaas
[not found] ` <52a632f0.e42c980a.3d86.ffff8faeSMTPIN_ADDED_MISSING@mx.google.com>
2013-12-09 21:21 ` Bjorn Helgaas
[not found] ` <52a63678.4902980a.6fd7.ffffa2b9SMTPIN_ADDED_MISSING@mx.google.com>
2013-12-09 22:27 ` Bjorn Helgaas
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=201311262219.49115.marex@denx.de \
--to=marex@denx.de \
--cc=Eric.Nelson@boundarydevices.com \
--cc=Mohit.KUMAR@st.com \
--cc=ajay.khandelwal@st.com \
--cc=ben@datarespons.no \
--cc=bhelgaas@google.com \
--cc=jg1.han@samsung.com \
--cc=kishon@ti.com \
--cc=linux-pci@vger.kernel.org \
--cc=pratyush.anand@gmail.com \
--cc=tharvey@gateworks.com \
--cc=troy.kisky@boundarydevices.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).