From: Lucas De Marchi <lucas.demarchi@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>,
intel-gfx@lists.freedesktop.org, dri-devel@freedesktop.org,
Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH libdrm v2 1/5] intel: add generic functions to check PCI ID
Date: Fri, 31 Aug 2018 09:06:01 -0700 [thread overview]
Message-ID: <20180831160601.GA7200@ldmartin-desk.jf.intel.com> (raw)
In-Reply-To: <153570338383.8603.13730509394835497287@skylake-alporthouse-com>
On Fri, Aug 31, 2018 at 09:16:23AM +0100, Chris Wilson wrote:
> Quoting Lucas De Marchi (2018-08-29 01:35:28)
> > +static const struct pci_device {
> > + uint16_t device;
> > + uint16_t gen;
> > +} pciids[] = {
>
> Add a comment here as well for the ordering requirement.
>
> /* Keep ids sorted by gen; latest gen first */
>
> We're unlikely to notice a comment in the function later trying to
> impose its restriction.
ok
>
> > +};
> > +
> > +bool intel_is_genx(unsigned int devid, int gen)
> > +{
> > + const struct pci_device *p,
> > + *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
> > +
> > + for (p = pciids; p < pend; p++) {
> > + /* PCI IDs are sorted */
> > + if (p->gen < gen)
> > + break;
>
> If we have lots of gen with lots of subids, a binary search for gen
> would be sensible. However, do we need this function? Do we not just
> convert everyone over to a lookup of pci-id on entry?
in some places we need the single IS_GEN9(). The advantage of using this
function rather than intel_get_genx() is that it can be faster due to
stopping here, or doing a binary search as you pointed out.
With intel_get_genx we don't have this. IS_GEN9() is may be called in
non-initialization code paths, so IMO its worth.
What we *can* do here instead is: guarantee all codepaths will occur
after the call to drm_intel_bufmgr_gem_init() then remove all macros and
just implement a single function that checks the "cached value".
>
> > +
> > + if (p->device != devid)
> > + continue;
> > +
> > + if (gen == p->gen)
> > + return true;
> > +
> > + break;
> > + }
> > +
> > + return false;
> > +}
> > +
> > +bool intel_get_genx(unsigned int devid, int *gen)
> > +{
> > + const struct pci_device *p,
> > + *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
> > +
> > + for (p = pciids; p < pend; p++) {
> > + if (p->device != devid)
> > + continue;
> > +
> > + if (gen)
> > + *gen = p->gen;
> > +
> > + return true;
> > + }
> > +
> > + return false;
> > +}
>
> Idle thought
> #ifdef SELFTEST
> int main(void)
> {
> /* check pci-ids are ordered by gen */
> }
> #endif
$ git grep SELFTEST
$
you do know this is a patch for libdrm, right?
>
> > diff --git a/intel/intel_chipset.h b/intel/intel_chipset.h
> > index 4a34b7be..0e14c58f 100644
> > --- a/intel/intel_chipset.h
> > +++ b/intel/intel_chipset.h
> > @@ -568,6 +568,13 @@
> >
> > #define IS_GEN11(devid) (IS_ICELAKE_11(devid))
> >
> > +/* New platforms use kernel pci ids */
> > +#include <stdbool.h>
> > +
> > +bool intel_is_genx(unsigned int devid, int gen);
> > +bool intel_get_genx(unsigned int devid, int *gen);
> > +
> > +/* all platforms */
>
> Quite clearly not all platforms :-p
by some definition of "all".... the " New platforms use kernel pci ids " + the ones that don't ;)
I'm ok with just removing the comment
Lucas De Marchi
>
> > #define IS_9XX(dev) (IS_GEN3(dev) || \
> > IS_GEN4(dev) || \
> > IS_GEN5(dev) || \
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2018-08-31 16:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-29 0:35 [PATCH libdrm v2 0/5] intel: rework how we add PCI IDs Lucas De Marchi
2018-08-29 0:35 ` [PATCH libdrm v2 1/5] intel: add generic functions to check PCI ID Lucas De Marchi
2018-08-31 8:16 ` Chris Wilson
2018-08-31 16:06 ` Lucas De Marchi [this message]
2018-08-31 16:13 ` Chris Wilson
2018-08-29 0:35 ` [PATCH libdrm v2 2/5] intel: make gen11 use generic gen macro Lucas De Marchi
2018-08-29 0:35 ` [PATCH libdrm v2 3/5] intel: make gen10 " Lucas De Marchi
2018-08-29 0:35 ` [PATCH libdrm v2 4/5] intel: make gen9 " Lucas De Marchi
2018-08-29 10:32 ` Chris Wilson
2018-08-29 16:01 ` Lucas De Marchi
2018-08-31 8:20 ` Chris Wilson
2018-08-31 8:21 ` Chris Wilson
2018-08-31 16:14 ` Lucas De Marchi
2018-08-29 0:35 ` [PATCH libdrm v2 5/5] intel: get gen once for gen >= 9 Lucas De Marchi
2018-08-29 14:31 ` Chris Wilson
2018-09-05 18:01 ` Lucas De Marchi
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=20180831160601.GA7200@ldmartin-desk.jf.intel.com \
--to=lucas.demarchi@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=dri-devel@freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=paulo.r.zanoni@intel.com \
--cc=rodrigo.vivi@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