From: Matthew Wilcox <willy@infradead.org>
To: Ira Weiny <ira.weiny@intel.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org,
linux-pci@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC PATCH 2/3] pci/doe: Use devm_xa_init()
Date: Fri, 8 Jul 2022 16:04:05 +0100 [thread overview]
Message-ID: <YshHZXK/dq3apNDu@casper.infradead.org> (raw)
In-Reply-To: <YshFxnBZGUPN5LoC@iweiny-desk3>
On Fri, Jul 08, 2022 at 07:57:10AM -0700, Ira Weiny wrote:
> > > I'll update this to be more clear in a V1 if it goes that far. But to clarify
> > > here; the protocol information is a u16 vendor id and u8 protocol number. So
> > > we are able to store that in the unsigned long value that would normally be a
> > > pointer to something in the XArray.
> >
> > Er. Signed long.
>
> Sorry I misspoke, xa_mk_value() takes an unsigned long.
It does, *but* ...
static inline void *xa_mk_value(unsigned long v)
{
WARN_ON((long)v < 0);
return (void *)((v << 1) | 1);
}
... you can't pass an integer that has the top bit set to it.
> Can't I use xa_mk_value() to store data directly in the entry "pointer"?
Yes, that's the purpose of xa_mk_value(). From what you said, it sounded
like you were just storing the integer directly, which won't work.
> +static void *pci_doe_xa_prot_entry(u16 vid, u8 prot)
> +{
> + return xa_mk_value(((unsigned long)vid << 16) | prot);
> +}
>
> Both Dan and I thought this was acceptable in XArray?
You haven't tested that on 32-bit, have you? Shift vid by 8 instead of
16, and it'll be fine.
(Oh, and you don't need to cast vid; the standard C integer promotions
will promote vid to int before shifting, and you won't lose any bits)
next prev parent reply other threads:[~2022-07-08 15:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-05 23:21 [RFC PATCH 0/3] Introduce devm_xa_init ira.weiny
2022-07-05 23:21 ` [RFC PATCH 1/3] xarray: Introduce devm_xa_init() ira.weiny
2022-07-07 16:10 ` Bjorn Helgaas
2022-07-08 14:51 ` Ira Weiny
2022-07-08 14:53 ` Matthew Wilcox
2022-07-08 14:59 ` Ira Weiny
2022-07-08 15:21 ` Matthew Wilcox
2022-07-14 15:44 ` Dan Williams
2022-07-14 16:02 ` Ira Weiny
2022-07-05 23:21 ` [RFC PATCH 2/3] pci/doe: Use devm_xa_init() ira.weiny
2022-07-07 16:06 ` Bjorn Helgaas
2022-07-08 14:45 ` Ira Weiny
2022-07-08 14:49 ` Matthew Wilcox
2022-07-08 14:57 ` Ira Weiny
2022-07-08 15:04 ` Matthew Wilcox [this message]
2022-07-08 15:49 ` Ira Weiny
2022-07-05 23:21 ` [RFC PATCH 3/3] CXL/doe: " ira.weiny
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=YshHZXK/dq3apNDu@casper.infradead.org \
--to=willy@infradead.org \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=helgaas@kernel.org \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=vishal.l.verma@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).