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 <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190903123452.28620-2-aneesh.kumar@linux.ibm.com
This commit is contained in:
Aneesh Kumar K.V 2019-09-03 18:04:52 +05:30 committed by Michael Ellerman
parent 4111cdef0e
commit faa6d21153
1 changed files with 40 additions and 8 deletions

View File

@ -65,10 +65,8 @@ static int drc_pmem_bind(struct papr_scm_priv *p)
cond_resched(); cond_resched();
} while (rc == H_BUSY); } while (rc == H_BUSY);
if (rc) { if (rc)
dev_err(&p->pdev->dev, "bind err: %lld\n", rc);
return rc; return rc;
}
p->bound_addr = saved; p->bound_addr = saved;
dev_dbg(&p->pdev->dev, "bound drc 0x%x to %pR\n", p->drc_index, &p->res); 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)
return; return;
} }
static int drc_pmem_query_n_bind(struct papr_scm_priv *p)
{
unsigned long start_addr;
unsigned long end_addr;
unsigned long ret[PLPAR_HCALL_BUFSIZE];
int64_t rc;
rc = plpar_hcall(H_SCM_QUERY_BLOCK_MEM_BINDING, ret,
p->drc_index, 0);
if (rc)
goto err_out;
start_addr = ret[0];
/* Make sure the full region is bound. */
rc = plpar_hcall(H_SCM_QUERY_BLOCK_MEM_BINDING, ret,
p->drc_index, p->blocks - 1);
if (rc)
goto err_out;
end_addr = ret[0];
if ((end_addr - start_addr) != ((p->blocks - 1) * p->block_size))
goto err_out;
p->bound_addr = start_addr;
dev_dbg(&p->pdev->dev, "bound drc 0x%x to %pR\n", p->drc_index, &p->res);
return rc;
err_out:
dev_info(&p->pdev->dev,
"Failed to query, trying an unbind followed by bind");
drc_pmem_unbind(p);
return drc_pmem_bind(p);
}
static int papr_scm_meta_get(struct papr_scm_priv *p, static int papr_scm_meta_get(struct papr_scm_priv *p,
struct nd_cmd_get_config_data_hdr *hdr) struct nd_cmd_get_config_data_hdr *hdr)
{ {
@ -430,13 +464,11 @@ static int papr_scm_probe(struct platform_device *pdev)
rc = drc_pmem_bind(p); rc = drc_pmem_bind(p);
/* If phyp says drc memory still bound then force unbound and retry */ /* If phyp says drc memory still bound then force unbound and retry */
if (rc == H_OVERLAP) { if (rc == H_OVERLAP)
dev_warn(&pdev->dev, "Retrying bind after unbinding\n"); rc = drc_pmem_query_n_bind(p);
drc_pmem_unbind(p);
rc = drc_pmem_bind(p);
}
if (rc != H_SUCCESS) { if (rc != H_SUCCESS) {
dev_err(&p->pdev->dev, "bind err: %d\n", rc);
rc = -ENXIO; rc = -ENXIO;
goto err; goto err;
} }