public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Matthew Wilcox <willy@linux.intel.com>,
	Jesse Barnes <jbarnes@virtuousgeek.org>
Subject: Re: [PATCH] PCI/MSI: fix msi_mask()
Date: Sun, 8 Feb 2009 04:26:51 -0700	[thread overview]
Message-ID: <20090208112650.GD31509@parisc-linux.org> (raw)
In-Reply-To: <498A5348.3090508@jp.fujitsu.com>

On Thu, Feb 05, 2009 at 11:47:36AM +0900, Hidetoshi Seto wrote:
> The commit bffac3c593eba1f9da3efd0199e49ea6558a40ce does:
> 
>  -    temp = (1 << multi_msi_capable(control));
>  -    temp = ((temp - 1) & ~temp);
>  +    temp = msi_mask((control & PCI_MSI_FLAGS_QMASK) >> 1);
> 
> and provides msi_mask() to avoid undefined shift by 32.
[...]
> This patch fix the wrong array in the msi_mask().

Quite correct.  While disconnected for a couple of weeks, I also
considered this possible fix:

static inline __attribute_const__ u32 msi_mask(unsigned x)
{
        /* Don't shift by >= width of type */
        if (x >= 5)
                return 0xffffffff;
        return (1 << (1 << x)) - 1;
}

which has the added bonus of not running off the end of the array if
some device has a bogus value in its config space.

What do you think?

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

  reply	other threads:[~2009-02-08 11:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-05  2:47 [PATCH] PCI/MSI: fix msi_mask() Hidetoshi Seto
2009-02-08 11:26 ` Matthew Wilcox [this message]
2009-02-09  1:38   ` Hidetoshi Seto
2009-02-09  1:40   ` [PATCH] PCI/MSI: fix msi_mask() (rev. 2) Hidetoshi Seto
2009-02-09  3:27     ` Matthew Wilcox
2009-02-09  4:31       ` Hidetoshi Seto
2009-02-09 17:23       ` Jesse Barnes

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=20090208112650.GD31509@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=seto.hidetoshi@jp.fujitsu.com \
    --cc=willy@linux.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