mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>,
	markgross@kernel.org
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: ISST: PUNIT device mapping with Sub-NUMA clustering
Date: Wed, 29 Jun 2022 17:36:10 +0200	[thread overview]
Message-ID: <d0e8a984-52f4-75e7-93a7-b498af4c859e@redhat.com> (raw)
In-Reply-To: <4fa1d4befe5de6d402aeb72ec1ae9953789da3ec.camel@linux.intel.com>

Hi,

On 6/29/22 16:14, srinivas pandruvada wrote:
> Hi Hans,
> 
> Thanks for the review.
> 
> On Wed, 2022-06-29 at 12:00 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 6/27/22 23:50, Srinivas Pandruvada wrote:
>>>
> [...]
> 
>>>  
>>> +struct isst_if_pkg_info {
>>> +       struct pci_dev *pci_dev[2];
>>
>> This and (continued below) ...
>>
> Didn't understand the comment.

What I was trying to say here is that this is all
one long comment (continued further down/below
in the email) about checking the bounds
of this array.

> 
>>> +};
>>> +
>>>  static struct isst_if_cpu_info *isst_cpu_info;
>>> +static struct isst_if_pkg_info *isst_pkg_info;
>>> +
>>>  #define ISST_MAX_PCI_DOMAINS   8
>>>  
>>>  static struct pci_dev *_isst_if_get_pci_dev(int cpu, int bus_no,
>>> int dev, int fn)
>>>  {
>>> +       int pkg_id = topology_physical_package_id(cpu);
>>>         struct pci_dev *matched_pci_dev = NULL;
>>>         struct pci_dev *pci_dev = NULL;
>>>         int no_matches = 0;
>>> @@ -324,6 +331,8 @@ static struct pci_dev *_isst_if_get_pci_dev(int
>>> cpu, int bus_no, int dev, int fn
>>>                 }
>>>  
>>>                 if (node == isst_cpu_info[cpu].numa_node) {
>>> +                       isst_pkg_info[pkg_id].pci_dev[bus_no] =
>>> _pci_dev;
>>> +
>>
>> This and ...
>>
> Please explain the comment.

Idem.


> 
>>>                         pci_dev = _pci_dev;
>>>                         break;
>>>                 }
>>> @@ -342,6 +351,9 @@ static struct pci_dev *_isst_if_get_pci_dev(int
>>> cpu, int bus_no, int dev, int fn
>>>         if (!pci_dev && no_matches == 1)
>>>                 pci_dev = matched_pci_dev;
>>>  
>>> +       if (!pci_dev)
>>> +               pci_dev = isst_pkg_info[pkg_id].pci_dev[bus_no];
>>> +
>>
>> This assumes that bus_no is never > 1, is this assumption enforced
>> somewhere?
>>
> Yes. That is checked at the beginning of function
>    if (bus_no < 0 || bus_no > 1 || cpu < 0 || cpu >= nr_cpu_ids ||
>             cpu >= num_possible_cpus())
> 	 return NULL;

Ah, good.

>> Also maybe make the 2 in:
>>
>>> +struct isst_if_pkg_info {
>>> +       struct pci_dev *pci_dev[2];
>>
>> a #define ?
> I will.

Great; then also please update the "bus_no > 1" in the bounds check
to use this define.

Regards,

Hans



> 
> Thanks,
> Srinivas
> 
>>
>> Regards,
>>
>> Hans
>>
>>
>>>         return pci_dev;
>>>  }
>>>  
>>> @@ -417,10 +429,19 @@ static int isst_if_cpu_info_init(void)
>>>         if (!isst_cpu_info)
>>>                 return -ENOMEM;
>>>  
>>> +       isst_pkg_info = kcalloc(topology_max_packages(),
>>> +                               sizeof(*isst_pkg_info),
>>> +                               GFP_KERNEL);
>>> +       if (!isst_pkg_info) {
>>> +               kfree(isst_cpu_info);
>>> +               return -ENOMEM;
>>> +       }
>>> +
>>>         ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
>>>                                 "platform/x86/isst-if:online",
>>>                                 isst_if_cpu_online, NULL);
>>>         if (ret < 0) {
>>> +               kfree(isst_pkg_info);
>>>                 kfree(isst_cpu_info);
>>>                 return ret;
>>>         }
>>> @@ -433,6 +454,7 @@ static int isst_if_cpu_info_init(void)
>>>  static void isst_if_cpu_info_exit(void)
>>>  {
>>>         cpuhp_remove_state(isst_if_online_id);
>>> +       kfree(isst_pkg_info);
>>>         kfree(isst_cpu_info);
>>>  };
>>>  
>>
> 


      reply	other threads:[~2022-06-29 15:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 21:50 Srinivas Pandruvada
2022-06-28 20:16 ` Hans de Goede
2022-06-29 10:00 ` Hans de Goede
2022-06-29 14:14   ` srinivas pandruvada
2022-06-29 15:36     ` Hans de Goede [this message]

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=d0e8a984-52f4-75e7-93a7-b498af4c859e@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=srinivas.pandruvada@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

all inboxes | Powered by JetHome®