All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, Intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 5/5] drm/i915/pmu: Support multiple GPUs
Date: Thu, 1 Aug 2019 16:10:14 +0100	[thread overview]
Message-ID: <6e776f39-efba-08bc-e96d-188cc88ebcb4@linux.intel.com> (raw)
In-Reply-To: <156467129926.6045.16909307069650415218@skylake-alporthouse-com>


On 01/08/2019 15:54, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2019-08-01 15:17:32)
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> With discrete graphics system can have both integrated and discrete GPU
>> handled by i915.
>>
>> Currently we use a fixed name ("i915") when registering as the uncore PMU
>> provider which stops working in this case.
>>
>> To fix this we add the PCI device name string to non-integrated devices
>> handled by us. Integrated devices keep the legacy name preserving
>> backward compatibility.
>>
>> v2:
>>   * Detect IGP and keep legacy name. (Michal)
>>   * Use PCI device name as suffix. (Michal, Chris)
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> ---
>> Is our GPU always "0000:00:02.0"? CI will tell me.
> 
> It always has been. (With a few additional 2.1 for Windows95 multihead
> where each head had to be a unique device!)
> 
> One hopes that by now it is firmly ingrained that it will always be
> kept to 00:02.0.

Re-assuring, thanks! However still some tests to do before I am happy 
this is upstream worthy, not least CI.

> 
>> ---
>>   drivers/gpu/drm/i915/i915_pmu.c | 27 +++++++++++++++++++++++++--
>>   drivers/gpu/drm/i915/i915_pmu.h |  4 ++++
>>   2 files changed, 29 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
>> index e0e0180bca7c..9a404d85c4e9 100644
>> --- a/drivers/gpu/drm/i915/i915_pmu.c
>> +++ b/drivers/gpu/drm/i915/i915_pmu.c
>> @@ -1053,6 +1053,15 @@ static void i915_pmu_unregister_cpuhp_state(struct i915_pmu *pmu)
>>          cpuhp_remove_multi_state(cpuhp_slot);
>>   }
>>   
>> +static bool is_igp(struct pci_dev *pdev)
>> +{
>> +       /* IGP is 0000:00:02.0 */
>> +       return pdev->bus->parent == NULL &&
> 
> pci_domain_nr(pdev->bus) == 0 ?

Aha, thanks!

> 
>> +              pdev->bus->number == 0 &&
>> +              PCI_SLOT(pdev->devfn) == 2 &&
>> +              PCI_FUNC(pdev->devfn) == 0;
> 
> I am surprised there isn't already a convenience function. None that I
> could find.
> 
>> +}
>> +
>>   void i915_pmu_register(struct drm_i915_private *i915)
>>   {
>>          struct i915_pmu *pmu = &i915->pmu;
>> @@ -1083,10 +1092,19 @@ void i915_pmu_register(struct drm_i915_private *i915)
>>          hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
>>          pmu->timer.function = i915_sample;
>>   
>> -       ret = perf_pmu_register(&pmu->base, "i915", -1);
>> -       if (ret)
>> +       if (!is_igp(i915->drm.pdev))
>> +               pmu->name = kasprintf(GFP_KERNEL,
>> +                                     "i915-%s",
>> +                                     dev_name(i915->drm.dev));
>> +       else
>> +               pmu->name = "i915";
> 
> Makes sense, and quite a neat solution.
> 
>> +       if (!pmu->name)
>>                  goto err;
>>   
>> +       ret = perf_pmu_register(&pmu->base, pmu->name, -1);
>> +       if (ret)
>> +               goto err_name;
>> +
>>          ret = i915_pmu_register_cpuhp_state(pmu);
>>          if (ret)
>>                  goto err_unreg;
>> @@ -1095,6 +1113,9 @@ void i915_pmu_register(struct drm_i915_private *i915)
>>   
>>   err_unreg:
>>          perf_pmu_unregister(&pmu->base);
>> +err_name:
>> +       if (!is_igp(i915->drm.pdev))
>> +               kfree(pmu->name);
> kfree_const(pmu->name);
> 
>>   err:
>>          pmu->base.event_init = NULL;
>>          free_event_attributes(pmu);
>> @@ -1116,5 +1137,7 @@ void i915_pmu_unregister(struct drm_i915_private *i915)
>>   
>>          perf_pmu_unregister(&pmu->base);
>>          pmu->base.event_init = NULL;
>> +       if (!is_igp(i915->drm.pdev))
>> +               kfree(pmu->name);
> 
> kfree_const(pmu->name);
> 
> Works for me, I wonder what PeterZ will say...

In what sense?

> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Thanks,

Tvrtko

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-08-01 15:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 14:17 [PATCH 1/5] drm/i915/pmu: Make more struct i915_pmu centric Tvrtko Ursulin
2019-08-01 14:17 ` [PATCH 2/5] drm/i915/pmu: Convert engine sampling to uncore mmio Tvrtko Ursulin
2019-08-01 14:17 ` [PATCH 3/5] drm/i915/pmu: Convert sampling to gt Tvrtko Ursulin
2019-08-01 14:17 ` [PATCH 4/5] drm/i915/pmu: Make get_rc6 take intel_gt Tvrtko Ursulin
2019-08-01 14:45   ` Chris Wilson
2019-08-01 14:17 ` [PATCH 5/5] drm/i915/pmu: Support multiple GPUs Tvrtko Ursulin
2019-08-01 14:54   ` Chris Wilson
2019-08-01 15:10     ` Tvrtko Ursulin [this message]
2019-08-01 15:20       ` Chris Wilson
2019-08-01 15:31         ` Tvrtko Ursulin
2019-08-01 15:08   ` [PATCH v3 " Tvrtko Ursulin
2019-08-01 15:43     ` Chris Wilson
2019-08-01 15:54   ` [PATCH v4 " Tvrtko Ursulin
2019-09-06 15:47     ` [Intel-gfx] " Tvrtko Ursulin
2019-10-10 12:37       ` Tvrtko Ursulin
2019-08-01 21:22 ` ✗ Fi.CI.BAT: failure for series starting with [1/5] drm/i915/pmu: Make more struct i915_pmu centric (rev3) Patchwork
2019-08-01 21:37   ` Chris Wilson

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=6e776f39-efba-08bc-e96d-188cc88ebcb4@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=chris@chris-wilson.co.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.