From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] arm/gic: Add supports for GICv2m MSI(-X)
Date: Wed, 25 Jun 2014 09:57:04 +0100 [thread overview]
Message-ID: <20140625085703.GB29789@leverpostej> (raw)
In-Reply-To: <53AA3A3A.2050401@amd.com>
On Wed, Jun 25, 2014 at 03:55:54AM +0100, Suravee Suthikulanit wrote:
> Mark,
>
> Thank you for all your comments. Please see my reply below. I have
> omitted the minor ones.
Likewise.
> >> +static void free_msi_irq(struct gicv2m_msi_data *data, unsigned int irq)
> >> +{
> >> + int pos;
> >> +
> >> + spin_lock(&data->msi_cnt_lock);
> >> +
> >> + pos = irq - data->spi_start;
> >> + if (pos >= 0 && pos < data->max_spi_cnt)
> >
> > Should either of these cases ever happen?
>
> This is to check if the irq provided is within the MSI range.
Sure, but surely this should only be called for the correct set of MSI
IRQs? Allowing this to be called for arbitrary interrupts without
reporting an error sounds wrong.
[...]
> >> +static int gicv2m_setup_msi_irq(struct msi_chip *chip, struct pci_dev *pdev,
> >> + struct msi_desc *desc)
> >> +{
> >> + int avail, irq = 0;
> >> + struct msi_msg msg;
> >> + phys_addr_t addr;
> >> + struct gicv2m_msi_data *data = to_gicv2m_msi_data(chip);
> >> +
> >> + if (data == NULL) {
> >
> > If container_of returns NULL, you have bigger problems.
>
> It was just sanity check. But, if you think this is obvious, I'll remove
> this check then.
The issue is you check for NULL _after_ you've performed some pointer
arithmetic. Because the msi_chip is the first element of
gicv2m_msi_data, to_gicv2m_msi_data is currently an identity function
with some type casting, but we should rely on that here. What if the
msi_chip were moved to later in gicv2m_msi_data?
If you want to check for NULL, check chip before
to_gicv2m_msi_data(chip).
[...]
> >> + /*
> >> + * MSI_TYPER:
> >> + * [31:26] Reserved
> >> + * [25:16] lowest SPI assigned to MSI
> >> + * [15:10] Reserved
> >> + * [9:0] Numer of SPIs assigned to MSI
> >> + */
> >> + val = __raw_readl(msi->base + MSI_TYPER);
> >
> > Are you sure you want to use __raw_readl?
> >
> Probably not. I am replacing this with ioread32(msi->base + MSI_TYPER).
It's probably better to use readl() or a readl_relaxed() here for
consistency with the rest of the ARM code, but otherwise that sounds
sane.
Thanks,
Mark.
next prev parent reply other threads:[~2014-06-25 8:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-24 0:32 [PATCH 0/2] Introduce ARM GICv2m MSI(-X) support suravee.suthikulpanit at amd.com
2014-06-24 0:32 ` [PATCH 1/2] arm/gic: Add binding probe for GIC400 suravee.suthikulpanit at amd.com
2014-06-24 12:22 ` Jason Cooper
2014-06-24 0:33 ` [PATCH 2/2] arm/gic: Add supports for GICv2m MSI(-X) suravee.suthikulpanit at amd.com
2014-06-24 9:52 ` Marc Zyngier
2014-06-25 3:04 ` Suravee Suthikulanit
2014-06-27 15:43 ` Suravee Suthikulpanit
2014-06-27 17:35 ` Marc Zyngier
2014-06-24 10:11 ` Mark Rutland
2014-06-25 2:55 ` Suravee Suthikulanit
2014-06-25 8:57 ` Mark Rutland [this message]
2014-06-24 12:19 ` [PATCH 0/2] Introduce ARM GICv2m MSI(-X) support Jason Cooper
2014-06-24 12:26 ` Jason Cooper
2014-06-25 0:19 ` Suravee Suthikulanit
2014-06-30 18:27 ` Jason Cooper
2014-06-24 14:09 ` Joel Schopp
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=20140625085703.GB29789@leverpostej \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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