Thread (32 messages) 32 messages, 8 authors, 2013-08-29

Re: [RFC PATCH 3/4] powerpc: refactor of_get_cpu_node to support other architectures

From: Sudeep KarkadaNagesha <hidden>
Date: 2013-08-16 08:48:21
Also in: linux-arm-kernel, linux-pm, lkml

On 16/08/13 05:49, Benjamin Herrenschmidt wrote:
On Thu, 2013-08-15 at 18:09 +0100, Sudeep KarkadaNagesha wrote:
quoted
From: Sudeep KarkadaNagesha <redacted>

Currently different drivers requiring to access cpu device node are
parsing the device tree themselves. Since the ordering in the DT need
not match the logical cpu ordering, the parsing logic needs to consider
that. However, this has resulted in lots of code duplication and in some
cases even incorrect logic.
=20
 .../...
=20
quoted
=20
+bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+=09return (int)phys_id =3D=3D get_hard_smp_processor_id(cpu);
+}
=20
Naming is a bit gross. You might want to make it clearer that
we are talking about CPU IDs in the device-tree here.
=20
Any particular preference to the name or just a note is sufficient.
Also unlike PPC, in ARM we don't set hard processor id value based
values read from device tree. DT must contain the values matching to the
hardware ID registers.
quoted
+static bool __of_find_n_match_cpu_property(struct device_node *cpun,
+=09=09=09const char *prop_name, int cpu, unsigned int *thread)
+{
+=09const __be32 *cell;
+=09int ac, prop_len, tid;
+=09u64 hwid;
+
+=09ac =3D of_n_addr_cells(cpun);
+=09cell =3D of_get_property(cpun, prop_name, &prop_len);
+=09if (!cell)
+=09=09return false;
+=09prop_len /=3D sizeof(*cell);
+=09for (tid =3D 0; tid < prop_len; tid++) {
+=09=09hwid =3D of_read_number(cell, ac);
+=09=09if (arch_match_cpu_phys_id(cpu, hwid)) {
+=09=09=09if (thread)
+=09=09=09=09*thread =3D tid;
+=09=09=09return true;
+=09=09}
=20
Missing:          cell +=3D ac;
Ah, missed it while refactoring, will fix it. Thanks

Regards,
Sudeep
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help