Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Browse files Browse the repository at this point in the history
Merge the crypto tree to resolve conflict between caam changes.
  • Loading branch information
herbertx committed Apr 5, 2017
2 parents 796b40c + 40c98cb commit c6dc060
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 79 deletions.
3 changes: 2 additions & 1 deletion Documentation/devicetree/bindings/rng/omap_rng.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Required properties:
- reg : Offset and length of the register set for the module
- interrupts : the interrupt number for the RNG module.
Used for "ti,omap4-rng" and "inside-secure,safexcel-eip76"
- clocks: the trng clock source
- clocks: the trng clock source. Only mandatory for the
"inside-secure,safexcel-eip76" compatible.

Example:
/* AM335x */
Expand Down
7 changes: 5 additions & 2 deletions crypto/lrw.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,11 @@ static int init_crypt(struct skcipher_request *req, crypto_completion_t done)

subreq->cryptlen = LRW_BUFFER_SIZE;
if (req->cryptlen > LRW_BUFFER_SIZE) {
subreq->cryptlen = min(req->cryptlen, (unsigned)PAGE_SIZE);
rctx->ext = kmalloc(subreq->cryptlen, gfp);
unsigned int n = min(req->cryptlen, (unsigned int)PAGE_SIZE);

rctx->ext = kmalloc(n, gfp);
if (rctx->ext)
subreq->cryptlen = n;
}

rctx->src = req->src;
Expand Down
7 changes: 5 additions & 2 deletions crypto/xts.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,11 @@ static int init_crypt(struct skcipher_request *req, crypto_completion_t done)

subreq->cryptlen = XTS_BUFFER_SIZE;
if (req->cryptlen > XTS_BUFFER_SIZE) {
subreq->cryptlen = min(req->cryptlen, (unsigned)PAGE_SIZE);
rctx->ext = kmalloc(subreq->cryptlen, gfp);
unsigned int n = min(req->cryptlen, (unsigned int)PAGE_SIZE);

rctx->ext = kmalloc(n, gfp);
if (rctx->ext)
subreq->cryptlen = n;
}

rctx->src = req->src;
Expand Down
42 changes: 34 additions & 8 deletions drivers/char/hw_random/amd-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
struct amd768_priv {
void __iomem *iobase;
struct pci_dev *pcidev;
u32 pmbase;
};

static int amd_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
Expand Down Expand Up @@ -148,33 +149,58 @@ static int __init mod_init(void)
if (pmbase == 0)
return -EIO;

priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;

if (!devm_request_region(&pdev->dev, pmbase + PMBASE_OFFSET,
PMBASE_SIZE, DRV_NAME)) {
if (!request_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE, DRV_NAME)) {
dev_err(&pdev->dev, DRV_NAME " region 0x%x already in use!\n",
pmbase + 0xF0);
return -EBUSY;
err = -EBUSY;
goto out;
}

priv->iobase = devm_ioport_map(&pdev->dev, pmbase + PMBASE_OFFSET,
PMBASE_SIZE);
priv->iobase = ioport_map(pmbase + PMBASE_OFFSET, PMBASE_SIZE);
if (!priv->iobase) {
pr_err(DRV_NAME "Cannot map ioport\n");
return -ENOMEM;
err = -EINVAL;
goto err_iomap;
}

amd_rng.priv = (unsigned long)priv;
priv->pmbase = pmbase;
priv->pcidev = pdev;

pr_info(DRV_NAME " detected\n");
return devm_hwrng_register(&pdev->dev, &amd_rng);
err = hwrng_register(&amd_rng);
if (err) {
pr_err(DRV_NAME " registering failed (%d)\n", err);
goto err_hwrng;
}
return 0;

err_hwrng:
ioport_unmap(priv->iobase);
err_iomap:
release_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE);
out:
kfree(priv);
return err;
}

static void __exit mod_exit(void)
{
struct amd768_priv *priv;

priv = (struct amd768_priv *)amd_rng.priv;

hwrng_unregister(&amd_rng);

ioport_unmap(priv->iobase);

release_region(priv->pmbase + PMBASE_OFFSET, PMBASE_SIZE);

kfree(priv);
}

module_init(mod_init);
Expand Down
50 changes: 35 additions & 15 deletions drivers/char/hw_random/geode-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include <linux/module.h>
#include <linux/pci.h>


#define PFX KBUILD_MODNAME ": "

#define GEODE_RNG_DATA_REG 0x50
#define GEODE_RNG_STATUS_REG 0x54

Expand Down Expand Up @@ -82,34 +85,51 @@ static struct hwrng geode_rng = {

static int __init mod_init(void)
{
int err = -ENODEV;
struct pci_dev *pdev = NULL;
const struct pci_device_id *ent;
void __iomem *mem;
unsigned long rng_base;

for_each_pci_dev(pdev) {
ent = pci_match_id(pci_tbl, pdev);
if (ent) {
rng_base = pci_resource_start(pdev, 0);
if (rng_base == 0)
return -ENODEV;

mem = devm_ioremap(&pdev->dev, rng_base, 0x58);
if (!mem)
return -ENOMEM;
geode_rng.priv = (unsigned long)mem;

pr_info("AMD Geode RNG detected\n");
return devm_hwrng_register(&pdev->dev, &geode_rng);
}
if (ent)
goto found;
}

/* Device not found. */
return -ENODEV;
goto out;

found:
rng_base = pci_resource_start(pdev, 0);
if (rng_base == 0)
goto out;
err = -ENOMEM;
mem = ioremap(rng_base, 0x58);
if (!mem)
goto out;
geode_rng.priv = (unsigned long)mem;

pr_info("AMD Geode RNG detected\n");
err = hwrng_register(&geode_rng);
if (err) {
pr_err(PFX "RNG registering failed (%d)\n",
err);
goto err_unmap;
}
out:
return err;

err_unmap:
iounmap(mem);
goto out;
}

static void __exit mod_exit(void)
{
void __iomem *mem = (void __iomem *)geode_rng.priv;

hwrng_unregister(&geode_rng);
iounmap(mem);
}

module_init(mod_init);
Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/caam/caampkc.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static int caam_rsa_init_tfm(struct crypto_akcipher *tfm)
ctx->dev = caam_jr_alloc();

if (IS_ERR(ctx->dev)) {
dev_err(ctx->dev, "Job Ring Device allocation for transform failed\n");
pr_err("Job Ring Device allocation for transform failed\n");
return PTR_ERR(ctx->dev);
}

Expand Down
67 changes: 22 additions & 45 deletions drivers/crypto/caam/ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ static int deinstantiate_rng(struct device *ctrldev, int state_handle_mask)
/* Try to run it through DECO0 */
ret = run_descriptor_deco0(ctrldev, desc, &status);

if (ret || status) {
if (ret ||
(status && status != JRSTA_SSRC_JUMP_HALT_CC)) {
dev_err(ctrldev,
"Failed to deinstantiate RNG4 SH%d\n",
sh_idx);
Expand All @@ -305,15 +306,13 @@ static int caam_remove(struct platform_device *pdev)
struct device *ctrldev;
struct caam_drv_private *ctrlpriv;
struct caam_ctrl __iomem *ctrl;
int ring;

ctrldev = &pdev->dev;
ctrlpriv = dev_get_drvdata(ctrldev);
ctrl = (struct caam_ctrl __iomem *)ctrlpriv->ctrl;

/* Remove platform devices for JobRs */
for (ring = 0; ring < ctrlpriv->total_jobrs; ring++)
of_device_unregister(ctrlpriv->jrpdev[ring]);
/* Remove platform devices under the crypto node */
of_platform_depopulate(ctrldev);

#ifdef CONFIG_CAAM_QI
if (ctrlpriv->qidev)
Expand Down Expand Up @@ -410,10 +409,21 @@ int caam_get_era(void)
}
EXPORT_SYMBOL(caam_get_era);

static const struct of_device_id caam_match[] = {
{
.compatible = "fsl,sec-v4.0",
},
{
.compatible = "fsl,sec4.0",
},
{},
};
MODULE_DEVICE_TABLE(of, caam_match);

/* Probe routine for CAAM top (controller) level */
static int caam_probe(struct platform_device *pdev)
{
int ret, ring, ridx, rspec, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN;
int ret, ring, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN;
u64 caam_id;
struct device *dev;
struct device_node *nprop, *np;
Expand Down Expand Up @@ -589,21 +599,9 @@ static int caam_probe(struct platform_device *pdev)
goto iounmap_ctrl;
}

/*
* Detect and enable JobRs
* First, find out how many ring spec'ed, allocate references
* for all, then go probe each one.
*/
rspec = 0;
for_each_available_child_of_node(nprop, np)
if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") ||
of_device_is_compatible(np, "fsl,sec4.0-job-ring"))
rspec++;

ctrlpriv->jrpdev = devm_kcalloc(&pdev->dev, rspec,
sizeof(*ctrlpriv->jrpdev), GFP_KERNEL);
if (ctrlpriv->jrpdev == NULL) {
ret = -ENOMEM;
ret = of_platform_populate(nprop, caam_match, NULL, dev);
if (ret) {
dev_err(dev, "JR platform devices creation error\n");
goto iounmap_ctrl;
}

Expand All @@ -618,29 +616,19 @@ static int caam_probe(struct platform_device *pdev)
ctrlpriv->dfs_root = debugfs_create_dir(dev_name(dev), NULL);
ctrlpriv->ctl = debugfs_create_dir("ctl", ctrlpriv->dfs_root);
#endif

ring = 0;
ridx = 0;
ctrlpriv->total_jobrs = 0;
for_each_available_child_of_node(nprop, np)
if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") ||
of_device_is_compatible(np, "fsl,sec4.0-job-ring")) {
ctrlpriv->jrpdev[ring] =
of_platform_device_create(np, NULL, dev);
if (!ctrlpriv->jrpdev[ring]) {
pr_warn("JR physical index %d: Platform device creation error\n",
ridx);
ridx++;
continue;
}
ctrlpriv->jr[ring] = (struct caam_job_ring __iomem __force *)
((__force uint8_t *)ctrl +
(ridx + JR_BLOCK_NUMBER) *
(ring + JR_BLOCK_NUMBER) *
BLOCK_OFFSET
);
ctrlpriv->total_jobrs++;
ring++;
ridx++;
}
}

/* Check to see if QI present. If so, enable */
ctrlpriv->qi_present =
Expand Down Expand Up @@ -849,17 +837,6 @@ static int caam_probe(struct platform_device *pdev)
return ret;
}

static struct of_device_id caam_match[] = {
{
.compatible = "fsl,sec-v4.0",
},
{
.compatible = "fsl,sec4.0",
},
{},
};
MODULE_DEVICE_TABLE(of, caam_match);

static struct platform_driver caam_driver = {
.driver = {
.name = "caam",
Expand Down
1 change: 0 additions & 1 deletion drivers/crypto/caam/intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ struct caam_drv_private_jr {
struct caam_drv_private {

struct device *dev;
struct platform_device **jrpdev; /* Alloc'ed array per sub-device */
#ifdef CONFIG_CAAM_QI
struct device *qidev;
#endif
Expand Down
1 change: 1 addition & 0 deletions drivers/crypto/ccp/ccp-dev-v5.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,7 @@ const struct ccp_vdata ccpv5a = {

const struct ccp_vdata ccpv5b = {
.version = CCP_VERSION(5, 0),
.dma_chan_attr = DMA_PRIVATE,
.setup = ccp5other_config,
.perform = &ccp5_actions,
.bar = 2,
Expand Down
5 changes: 4 additions & 1 deletion drivers/crypto/ccp/ccp-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,14 @@ EXPORT_SYMBOL_GPL(ccp_version);
*/
int ccp_enqueue_cmd(struct ccp_cmd *cmd)
{
struct ccp_device *ccp = ccp_get_device();
struct ccp_device *ccp;
unsigned long flags;
unsigned int i;
int ret;

/* Some commands might need to be sent to a specific device */
ccp = cmd->ccp ? cmd->ccp : ccp_get_device();

if (!ccp)
return -ENODEV;

Expand Down
5 changes: 5 additions & 0 deletions drivers/crypto/ccp/ccp-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@

/* ------------------------ General CCP Defines ------------------------ */

#define CCP_DMA_DFLT 0x0
#define CCP_DMA_PRIV 0x1
#define CCP_DMA_PUB 0x2

#define CCP_DMAPOOL_MAX_SIZE 64
#define CCP_DMAPOOL_ALIGN BIT(5)

Expand Down Expand Up @@ -646,6 +650,7 @@ struct ccp_actions {
/* Structure to hold CCP version-specific values */
struct ccp_vdata {
const unsigned int version;
const unsigned int dma_chan_attr;
void (*setup)(struct ccp_device *);
const struct ccp_actions *perform;
const unsigned int bar;
Expand Down
Loading

0 comments on commit c6dc060

Please sign in to comment.