Skip to content

Commit 364783c

Browse files
committed
formatting and few improv
1 parent 6e8231a commit 364783c

File tree

3 files changed

+114
-94
lines changed

3 files changed

+114
-94
lines changed

bmc-sbefifo-rainier.dts.m4

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
dnl
2-
dnl SBEFIFO([index], [path-index])
2+
dnl SCOM_TARGET([index], [path-index])
33
dnl
4-
define(`SBEFIFO',
4+
define(`SCOM_TARGET',
55
`
6-
sbefifo@2400 { /* Bogus address */
7-
reg = <0x0 0x2400 0x7>;
8-
compatible = "ibm,kernel-sbefifo";
6+
kernelpib@$1 {
7+
#address-cells = <0x2>;
8+
#size-cells = <0x1>;
9+
reg = <0x0 0x$1 0x7>;
10+
compatible = "ibm,kernel-pib";
911
index = <0x$1>;
10-
device-path = "/dev/sbefifo$2";
11-
12-
sbefifo-pib {
13-
#address-cells = <0x2>;
14-
#size-cells = <0x1>;
15-
compatible = "ibm,sbefifo-pib";
12+
device-path = "/dev/scom$2";
13+
backend = "kernel";
14+
};
15+
16+
sbefifo@2400 { /* Bogus address */
17+
reg = <0x0 0x2400 0x7>;
18+
compatible = "ibm,kernel-sbefifo";
1619
index = <0x$1>;
17-
system-path = "/proc$1/pib";
18-
backend = "sbefifo";
19-
20-
pib@$1 {
20+
device-path = "/dev/sbefifo$2";
21+
22+
sbefifo-pib {
2123
#address-cells = <0x2>;
2224
#size-cells = <0x1>;
23-
reg = <0x0 0x$1 0x7>;
24-
compatible = "ibm,kernel-pib";
25+
compatible = "ibm,sbefifo-pib";
2526
index = <0x$1>;
26-
device-path = "/dev/scom$2";
27-
backend = "kernel";
27+
system-path = "/proc$1/pib";
28+
backend = "sbefifo";
2829
};
29-
};
3030

31-
sbefifo-mem {
32-
compatible = "ibm,sbefifo-mem";
33-
index = <0x$1>;
34-
system-path = "/mem$1";
35-
};
31+
sbefifo-mem {
32+
compatible = "ibm,sbefifo-mem";
33+
index = <0x$1>;
34+
system-path = "/mem$1";
35+
};
3636

37-
sbefifo-pba {
38-
compatible = "ibm,sbefifo-mem-pba";
39-
index = <0x$1>;
40-
system-path = "/mempba$1";
41-
};
37+
sbefifo-pba {
38+
compatible = "ibm,sbefifo-mem-pba";
39+
index = <0x$1>;
40+
system-path = "/mempba$1";
41+
};
4242

43-
sbefifo-chipop {
44-
compatible = "ibm,sbefifo-chipop";
45-
index = <0x$1>;
43+
sbefifo-chipop {
44+
compatible = "ibm,sbefifo-chipop";
45+
index = <0x$1>;
46+
};
4647
};
47-
};
4848
')dnl
4949

5050
dnl
@@ -62,7 +62,7 @@ define(`FSI_PRE',
6262
status = "mustexist";
6363
system-path = "/proc$2/fsi";
6464

65-
SBEFIFO($2, $3)
65+
SCOM_TARGET($2, $3)
6666
')dnl
6767

6868
dnl
@@ -88,7 +88,7 @@ define(`HMFSI',
8888
index = <0x$3>;
8989
system-path = "/proc$3/fsi";
9090

91-
SBEFIFO($3, $4)
91+
SCOM_TARGET($3, $4)
9292
};
9393
')dnl
9494

@@ -197,7 +197,6 @@ define(`BMC_I2CBUS',
197197
HMFSI(400000, 7, 7, 8)
198198

199199

200-
201200
HMFSI_ODY(0, 0, 1, 11)
202201
HMFSI_ODY(1, 0, 1, 10)
203202
HMFSI_ODY(2, 0, 1, 12)

libpdbg/libpdbg.c

Lines changed: 77 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct pdbg_target *__pdbg_next_target(const char *class, struct pdbg_target *pa
4949
retry:
5050
/* No more targets left to check in this class */
5151
if ((last && last->class_link.next == &target_class->targets.n) ||
52-
list_empty(&target_class->targets))
52+
list_empty(&target_class->targets))
5353
return NULL;
5454

5555
if (last)
@@ -82,16 +82,16 @@ static struct pdbg_target *target_map_child(struct pdbg_target *next, bool syste
8282
* (the target itself can be virtual or real)
8383
*
8484
* - If there is virtual node associated,
85-
* - If the target is virtual, return the associated node
86-
* - If the target is real, return NULL
87-
* (this target is already covered by previous condition)
85+
* - If the target is virtual, return the associated node
86+
* - If the target is real, return NULL
87+
* (this target is already covered by previous condition)
8888
*
8989
* Map a target in backend tree:
9090
*
9191
* - If the target is real, return the target
9292
*
9393
* - If the target is virtual, return NULL
94-
* (no virtual nodes in backend tree)
94+
* (no virtual nodes in backend tree)
9595
*/
9696
if (system) {
9797
if (!next->vnode)
@@ -118,11 +118,11 @@ struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct
118118
* Parent node can be virtual or real.
119119
*
120120
* If the parent node doesn't have any children,
121-
* - If there is associated virtual node,
122-
* Use that node as parent
121+
* - If there is associated virtual node,
122+
* Use that node as parent
123123
*
124-
* - If there is no associated virtual node,
125-
* No children
124+
* - If there is no associated virtual node,
125+
* No children
126126
*/
127127
if (list_empty(&parent->children)) {
128128
if (parent->vnode)
@@ -133,8 +133,8 @@ struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct
133133

134134
/*
135135
* If the parent node has children,
136-
* - Traverse the children
137-
* (map the children in system or backend tree)
136+
* - Traverse the children
137+
* (map the children in system or backend tree)
138138
*/
139139
if (!last) {
140140
list_for_each(&parent->children, child, list)
@@ -150,10 +150,10 @@ struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct
150150
*
151151
* When the last child is specified:
152152
* - If in a system tree traverse, and
153-
* the last child has associated node, and
154-
* the last child is real
155-
* Then the last child is not the actual child of the parent
156-
* (the associated virtual node is the actual child)
153+
* the last child has associated node, and
154+
* the last child is real
155+
* Then the last child is not the actual child of the parent
156+
* (the associated virtual node is the actual child)
157157
*/
158158
if (system)
159159
last = target_to_virtual(last, false);
@@ -317,20 +317,20 @@ int pdbg_target_u32_property(struct pdbg_target *target, const char *name, uint3
317317
int pdbg_target_u32_index(struct pdbg_target *target, const char *name, int index, uint32_t *val)
318318
{
319319
const void *p;
320-
size_t len;
320+
size_t len;
321321

322-
p = pdbg_get_target_property(target, name, &len);
323-
if (!p)
324-
return -1;
322+
p = pdbg_get_target_property(target, name, &len);
323+
if (!p)
324+
return -1;
325325

326-
assert(len >= (index+1)*sizeof(uint32_t));
326+
assert(len >= (index+1)*sizeof(uint32_t));
327327

328328
/* FDT pointers should be aligned, but best to check */
329329
assert(!((uintptr_t) p & 0x3));
330330

331-
/* Always aligned, so this works. */
332-
*val = be32toh(((uint32_t *)p)[index]);
333-
return 0;
331+
/* Always aligned, so this works. */
332+
*val = be32toh(((uint32_t *)p)[index]);
333+
return 0;
334334
}
335335

336336
void pdbg_progress_tick(uint64_t cur, uint64_t end)
@@ -362,68 +362,89 @@ bool pdbg_context_is_short(void)
362362

363363
struct pdbg_target *pdbg_get_unattached_backend_target(struct pdbg_target* target, const char* class_name)
364364
{
365-
struct pdbg_target* backend_target = NULL;
365+
if (!target || !class_name)
366+
{
367+
pdbg_log(PDBG_ERROR, "Invalid input: target or class_name is NULL\n");
368+
return NULL;
369+
}
370+
371+
struct pdbg_target* backend_target = NULL;
366372

367-
/* We assume each processor chip contains one and only one pib */
368-
pdbg_for_each_target(class_name, target, backend_target)
369-
{
373+
/* We assume each processor chip contains one and only one pib */
374+
pdbg_for_each_target(class_name, target, backend_target)
375+
{
370376
/* There is a vnode attached, so this should be the backend target*/
371377
if(!backend_target->vnode)
372378
{
373379
break;
374380
}
375-
}
381+
}
376382
return backend_target;
377383
}
378384

379385
struct pdbg_target *pdbg_get_backend_target(struct pdbg_target* target, const char* class_name)
380386
{
381-
struct pdbg_target* backend_target = NULL;
387+
if (!target || !class_name)
388+
{
389+
pdbg_log(PDBG_ERROR, "Invalid input: target or class_name is NULL\n");
390+
return NULL;
391+
}
382392

383-
/* We assume each processor chip contains one and only one pib */
384-
pdbg_for_each_target(class_name, target, backend_target)
385-
{
393+
struct pdbg_target* backend_target = NULL;
394+
/* We assume each processor chip contains one and only one pib */
395+
pdbg_for_each_target(class_name, target, backend_target)
396+
{
386397
/* There is a vnode attached, so this should be the current backend target*/
387398
if(backend_target->vnode)
388399
{
389400
break;
390401
}
391-
}
402+
}
392403

393-
if (!backend_target)
394-
{
395-
/* If the pib target is not a child target, look for the parent pib target
396-
But the translation does not happen here. So better to */
397-
while(1)
404+
/* If the pib target is not a child target, look for the parent pib target
405+
But the translation does not happen here. So better to */
406+
if (!backend_target)
407+
{
408+
backend_target = target_parent(class_name, target, false);
409+
if (!backend_target)
398410
{
399-
backend_target = target_parent(class_name, target, false);
400-
401-
//TODO, check
402-
403-
if (!backend_target)
404-
{
405-
pdbg_log(PDBG_ERROR, "unable to get %s target for %s\n",
406-
class_name, pdbg_target_path(target));
407-
return NULL;
408-
}
411+
pdbg_log(PDBG_ERROR, "unable to get %s target for %s\n",
412+
class_name, pdbg_target_path(target));
413+
return NULL;
409414
}
410-
}
411-
return backend_target;
415+
}
416+
return backend_target;
412417
}
413418

414-
void pdbg_switch_node_backend(struct pdbg_target* target)
419+
struct pdbg_target* pdbg_switch_node_backend(struct pdbg_target* target, char* backend)
415420
{
416421
struct pdbg_target* attached_pib_target = pdbg_get_backend_target(target,"pib");
417-
418-
struct pdbg_target* unattached_pib_target = pdbg_get_unattached_backend_target(target,"pib");
422+
if (!attached_pib_target)
423+
{
424+
pdbg_log(PDBG_ERROR, "Failed to get attached PIB target\n");
425+
return NULL;
426+
}
419427

420-
struct pdbg_target* virtual_target = target_to_virtual(attached_pib_target, true);
428+
if (backend != NULL && backend[0] != '\0')
429+
{
430+
const char *cur_backend = pdbg_target_property(attached_pib_target, "backend", NULL);
431+
if(strcmp(cur_backend, backend) == 0)
432+
{
433+
//The current backend is same as expected backend. return
434+
return attached_pib_target;
435+
}
436+
}
421437

422-
if(virtual_target && unattached_pib_target)
438+
struct pdbg_target* virtual_target = target_to_virtual(attached_pib_target, true);
439+
struct pdbg_target* new_pib_target = pdbg_get_unattached_backend_target(target,"pib");
440+
441+
if(virtual_target && new_pib_target)
423442
{
424-
dt_link_virtual(virtual_target, unattached_pib_target);
443+
dt_link_virtual(virtual_target, new_pib_target);
425444
/*remove the virtual link as we have switched the backend*/
426445
attached_pib_target->vnode = NULL;
446+
return new_pib_target;
427447
}
448+
return NULL;
428449
}
429450

libpdbg/libpdbg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ struct pdbg_target *pdbg_get_backend_target(struct pdbg_target* target, const ch
15391539
/**
15401540
* The proc target whose backend we need to switch
15411541
*/
1542-
void pdbg_switch_node_backend(struct pdbg_target* target);
1542+
struct pdbg_target* pdbg_switch_node_backend(struct pdbg_target* target, char* backend);
15431543

15441544
void dt_link_virtual(struct pdbg_target *node, struct pdbg_target *vnode);
15451545

0 commit comments

Comments
 (0)