Skip to content

Commit faa6d21

Browse files
kvaneeshmpe
authored andcommitted
powerpc/nvdimm: use H_SCM_QUERY hcall on H_OVERLAP error
Right now we force an unbind of SCM memory at drcindex on H_OVERLAP error. This really slows down operations like kexec where we get the H_OVERLAP error because we don't go through a full hypervisor re init. H_OVERLAP error for a H_SCM_BIND_MEM hcall indicates that SCM memory at drc index is already bound. Since we don't specify a logical memory address for bind hcall, we can use the H_SCM_QUERY hcall to query the already bound logical address. Boot time difference with and without patch is: [ 5.583617] IOMMU table initialized, virtual merging enabled [ 5.603041] papr_scm ibm,persistent-memory:ibm,pmemory@44104001: Retrying bind after unbinding [ 301.514221] papr_scm ibm,persistent-memory:ibm,pmemory@44108001: Retrying bind after unbinding [ 340.057238] hv-24x7: read 1530 catalog entries, created 537 event attrs (0 failures), 275 descs after fix [ 5.101572] IOMMU table initialized, virtual merging enabled [ 5.116984] papr_scm ibm,persistent-memory:ibm,pmemory@44104001: Querying SCM details [ 5.117223] papr_scm ibm,persistent-memory:ibm,pmemory@44108001: Querying SCM details [ 5.120530] hv-24x7: read 1530 catalog entries, created 537 event attrs (0 failures), 275 descs Signed-off-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4111cde commit faa6d21

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

arch/powerpc/platforms/pseries/papr_scm.c

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ static int drc_pmem_bind(struct papr_scm_priv *p)
6565
cond_resched();
6666
} while (rc == H_BUSY);
6767

68-
if (rc) {
69-
dev_err(&p->pdev->dev, "bind err: %lld\n", rc);
68+
if (rc)
7069
return rc;
71-
}
7270

7371
p->bound_addr = saved;
7472
dev_dbg(&p->pdev->dev, "bound drc 0x%x to %pR\n", p->drc_index, &p->res);
@@ -110,6 +108,42 @@ static void drc_pmem_unbind(struct papr_scm_priv *p)
110108
return;
111109
}
112110

111+
static int drc_pmem_query_n_bind(struct papr_scm_priv *p)
112+
{
113+
unsigned long start_addr;
114+
unsigned long end_addr;
115+
unsigned long ret[PLPAR_HCALL_BUFSIZE];
116+
int64_t rc;
117+
118+
119+
rc = plpar_hcall(H_SCM_QUERY_BLOCK_MEM_BINDING, ret,
120+
p->drc_index, 0);
121+
if (rc)
122+
goto err_out;
123+
start_addr = ret[0];
124+
125+
/* Make sure the full region is bound. */
126+
rc = plpar_hcall(H_SCM_QUERY_BLOCK_MEM_BINDING, ret,
127+
p->drc_index, p->blocks - 1);
128+
if (rc)
129+
goto err_out;
130+
end_addr = ret[0];
131+
132+
if ((end_addr - start_addr) != ((p->blocks - 1) * p->block_size))
133+
goto err_out;
134+
135+
p->bound_addr = start_addr;
136+
dev_dbg(&p->pdev->dev, "bound drc 0x%x to %pR\n", p->drc_index, &p->res);
137+
return rc;
138+
139+
err_out:
140+
dev_info(&p->pdev->dev,
141+
"Failed to query, trying an unbind followed by bind");
142+
drc_pmem_unbind(p);
143+
return drc_pmem_bind(p);
144+
}
145+
146+
113147
static int papr_scm_meta_get(struct papr_scm_priv *p,
114148
struct nd_cmd_get_config_data_hdr *hdr)
115149
{
@@ -430,13 +464,11 @@ static int papr_scm_probe(struct platform_device *pdev)
430464
rc = drc_pmem_bind(p);
431465

432466
/* If phyp says drc memory still bound then force unbound and retry */
433-
if (rc == H_OVERLAP) {
434-
dev_warn(&pdev->dev, "Retrying bind after unbinding\n");
435-
drc_pmem_unbind(p);
436-
rc = drc_pmem_bind(p);
437-
}
467+
if (rc == H_OVERLAP)
468+
rc = drc_pmem_query_n_bind(p);
438469

439470
if (rc != H_SUCCESS) {
471+
dev_err(&p->pdev->dev, "bind err: %d\n", rc);
440472
rc = -ENXIO;
441473
goto err;
442474
}

0 commit comments

Comments
 (0)