Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp351984imb; Fri, 1 Mar 2019 02:23:13 -0800 (PST) X-Google-Smtp-Source: APXvYqxskCPXDtan9gB6osLK7Ai2xcylTUjPAFzV4kNtot5AEJmF8pHzWJVPMrPRgjkJHauB9Dlf X-Received: by 2002:a62:11ca:: with SMTP id 71mr4778990pfr.18.1551435793447; Fri, 01 Mar 2019 02:23:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551435793; cv=none; d=google.com; s=arc-20160816; b=0LN2UEEeQBfctVJfUezNqaK9pm2Yh0KZOpvwdFmd00a777XQPk6TshaxCj9cCi3YEf tL3Fl2RSuotrMmUeZ3/Lvl9RTRJ2+E0QduIRbrIqMUWkdjNsSQgNiwlzZW+BhMyIwJVH C4HtlDtb24Axh3CxuSLnDKbO4qsnWy4w6g3tEzrwxiimjr0XfWXo1hmXYij6sl1EpVky Hc+a6eY1zwV3XgBc+HZx9qGNa/lqdx9c5X+ctQol/SA4M45Xg6FBoy1sfsJrYluaC/jT yBMbFcfKhqsoWp3bRXCIlEfcZ+stjN+iCOgQlRqlL1YEAly+Xp21YheH6wGtKQvPPekn 87Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LG6JncRnG3r386DmLZKM+48qPJD8K/l3MztsfA3x/jo=; b=IHQqcpByi8sR1ga25j8+zXz0hGC4P4fOdr29ZxUAsZw3FD98fMlQJ6NmgwSsCZ//l5 MjX2JxejVeQEmziG5YKdwaI1h9O/GrldNGcaIWHrZqoYgY9KrdWmJ8wtcUkdv5AZH5cf FPb63rV+0viZil2ZEK5PKQpIjbhBPRhoWENaWfqvj7GRnxDKKbMY2XkbKtuTpWQ0VHf1 xUGdTH6n4sbJaEN1k/XKl2M7AQljrBgvcAAJN99s0Yttf52lYXKrZMztJA3FRqGIpNR5 IxWn8+E6N/VUyw7cFTdG+sbZUVzkV1/QQAMz4wIfFpQgtXx2DqT4fZeNF5nEnos7/yAk 3Q7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fz9mVTBR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id go2si20741314plb.270.2019.03.01.02.22.57; Fri, 01 Mar 2019 02:23:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fz9mVTBR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387783AbfCAKHc (ORCPT + 99 others); Fri, 1 Mar 2019 05:07:32 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:45439 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387518AbfCAKHb (ORCPT ); Fri, 1 Mar 2019 05:07:31 -0500 Received: by mail-io1-f68.google.com with SMTP id x9so19078913iog.12 for ; Fri, 01 Mar 2019 02:07:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LG6JncRnG3r386DmLZKM+48qPJD8K/l3MztsfA3x/jo=; b=Fz9mVTBRSYCdK4UbA6m9P33P6LmXhX4eIFSAEUxj+ZuGFr+wckhSAk2cDRFMG061gz j+LpoSPU2dv7s/BHYgSSQUG9YWwV7kELzbyhwrWrIWTqbTLwuS+kolhzFBnEXsU+zBU8 Bn5u8Y9KHh614FdQYz3oRRWxSZKlIQLmHTdRuGBOSJZyzQQcTaNr5Rcn5fBNMoJUzpKE neolS3HIDU4xs6lawC7yOYZShXW698axYMawHuOpOB6WoLGC3GQ6VlvK4M1qGEOhLew3 LXqr+n6AZQyG3Nd78x1kSw+UfZpbPpO+SigiMbC3MfACt49u0LXGLLU4u6jUrxiS7l7a bKSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LG6JncRnG3r386DmLZKM+48qPJD8K/l3MztsfA3x/jo=; b=uVawH4xU43x5C6ReM4tykPsiw5QF/a9kjWPzMJvDzQJec1vfDUyJDTA4Gy1Aw498MB PqI6ajRBWs8zgUzt0HEQY9ij8PfxMtBk62xXNj8C75MV/+dbcKP0rPnhHFUJVn+mXicc Azh5HTiBTvxo6SKqt70Nn99pl8GQSS2E7EUAg9NB8jpysq9pH64RBoZLCcvGtP2bldCn 6/2Px89mKPZXrk+A8+88UqFMcs7ZVdOSACN34MedwGYLzAL/iJiwoqa+INKl66cZhPtN cwwBOacYzNoLXfDXciiDrn5FIZBsXtmf8XlH10dtbnChRfkKHJg0xaxVXaFDwiX0nEiQ FOvg== X-Gm-Message-State: APjAAAUBkqQYHhmb6KcHDqyhOe/foFDTQvhmf2rxA7BLGrVv7Khc2XzY SgarP4j8E2L39khnPbtRX4pJYBOyyxMvzlRWg6uKcQ== X-Received: by 2002:a6b:7b02:: with SMTP id l2mr2322929iop.60.1551434849469; Fri, 01 Mar 2019 02:07:29 -0800 (PST) MIME-Version: 1.0 References: <20190222122144.19024-1-k.konieczny@partner.samsung.com> <20190222122144.19024-4-k.konieczny@partner.samsung.com> In-Reply-To: From: Ard Biesheuvel Date: Fri, 1 Mar 2019 11:07:17 +0100 Message-ID: Subject: Re: [PATCH v4 3/3] crypto: s5p: add AES support for Exynos5433 To: Krzysztof Kozlowski Cc: Kamil Konieczny , Vladimir Zapolskiy , Herbert Xu , "David S. Miller" , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , "linux-samsung-soc@vger.kernel.org" , Linux Kernel Mailing List , Bartlomiej Zolnierkiewicz , Marek Szyprowski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 Mar 2019 at 10:56, Krzysztof Kozlowski wrote: > > On Fri, 22 Feb 2019 at 13:22, Kamil Konieczny > wrote: > > > > Add AES crypto HW acceleration for Exynos5433, with the help of SlimSSS IP. > > > > Reviewed-by: Krzysztof Kozlowski > > Signed-off-by: Kamil Konieczny > > --- > > drivers/crypto/s5p-sss.c | 50 ++++++++++++++++++++++++++++++++++++---- > > 1 file changed, 46 insertions(+), 4 deletions(-) > > diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c > > index 0064be0e3941..3f45cc5cb94a 100644 > > --- a/drivers/crypto/s5p-sss.c > > +++ b/drivers/crypto/s5p-sss.c > > @@ -232,6 +232,7 @@ > > * struct samsung_aes_variant - platform specific SSS driver data > > * @aes_offset: AES register offset from SSS module's base. > > * @hash_offset: HASH register offset from SSS module's base. > > + * @clk_names: names of clocks needed to run SSS IP > > * > > * Specifies platform specific configuration of SSS module. > > * Note: A structure for driver specific platform data is used for future > > @@ -240,6 +241,7 @@ > > struct samsung_aes_variant { > > unsigned int aes_offset; > > unsigned int hash_offset; > > + const char *clk_names[]; > > }; > > > > struct s5p_aes_reqctx { > > @@ -296,6 +298,7 @@ struct s5p_aes_ctx { > > struct s5p_aes_dev { > > struct device *dev; > > struct clk *clk; > > + struct clk *pclk; > > void __iomem *ioaddr; > > void __iomem *aes_ioaddr; > > int irq_fc; > > @@ -384,11 +387,19 @@ struct s5p_hash_ctx { > > static const struct samsung_aes_variant s5p_aes_data = { > > .aes_offset = 0x4000, > > .hash_offset = 0x6000, > > + .clk_names = { "secss", }, > > }; > > > > static const struct samsung_aes_variant exynos_aes_data = { > > .aes_offset = 0x200, > > .hash_offset = 0x400, > > + .clk_names = { "secss", }, > > +}; > > + > > +static const struct samsung_aes_variant exynos5433_slim_aes_data = { > > + .aes_offset = 0x400, > > + .hash_offset = 0x800, > > + .clk_names = { "pclk", "aclk", }, > > }; > > > > static const struct of_device_id s5p_sss_dt_match[] = { > > @@ -400,6 +411,10 @@ static const struct of_device_id s5p_sss_dt_match[] = { > > .compatible = "samsung,exynos4210-secss", > > .data = &exynos_aes_data, > > }, > > + { > > + .compatible = "samsung,exynos5433-slim-sss", > > + .data = &exynos5433_slim_aes_data, > > + }, > > { }, > > }; > > MODULE_DEVICE_TABLE(of, s5p_sss_dt_match); > > @@ -2208,18 +2223,39 @@ static int s5p_aes_probe(struct platform_device *pdev) > > return PTR_ERR(pdata->ioaddr); > > } > > > > - pdata->clk = devm_clk_get(dev, "secss"); > > + pdata->clk = devm_clk_get(dev, variant->clk_names[0]); > > if (IS_ERR(pdata->clk)) { > > - dev_err(dev, "failed to find secss clock source\n"); > > + dev_err(dev, "failed to find secss clock %s\n", > > + variant->clk_names[0]); > > return -ENOENT; > > } > > > > err = clk_prepare_enable(pdata->clk); > > if (err < 0) { > > - dev_err(dev, "Enabling SSS clk failed, err %d\n", err); > > + dev_err(dev, "Enabling clock %s failed, err %d\n", > > + variant->clk_names[0], err); > > return err; > > } > > > > + if (variant->clk_names[1]) { > > + pdata->pclk = devm_clk_get(dev, variant->clk_names[1]); > > I see on today's linux next: > [ 6.391256] Unable to handle kernel paging request at virtual address 00004000 > on all my Exynos boards (U3, XU, XU3, HC1). > I did not do a bisect yet but it might be connected with this commit. > > The call trace is: > (strcmp) from [] (of_property_match_string+0x58/0xd0) > (of_property_match_string) from [] (__of_clk_get_by_name+0x5c/0x130) > (__of_clk_get_by_name) from [] (clk_get+0x34/0x70) > (clk_get) from [] (devm_clk_get+0x38/0x74) > (devm_clk_get) from [] (s5p_aes_probe+0xd4/0x4a0) > (s5p_aes_probe) from [] (platform_drv_probe+0x6c/0xa4) > (platform_drv_probe) from [] (really_probe+0x280/0x414) > (really_probe) from [] (driver_probe_device+0x78/0x1c0) > (driver_probe_device) from [] (device_driver_attach+0x58/0x60) > (device_driver_attach) from [] (__driver_attach+0xfc/0x160) > (__driver_attach) from [] (bus_for_each_dev+0x68/0xb4) > (bus_for_each_dev) from [] (bus_add_driver+0x158/0x214) > (bus_add_driver) from [] (driver_register+0x78/0x110) > (driver_register) from [] (do_one_initcall+0x8c/0x404) > > Full log: > https://krzk.eu/#/builders/21/builds/1153/steps/12/logs/serial0 > > The s5p_aes_probe address points here. > It seems that dereferencing clk_names[1] of struct samsung_aes_variant exynos_aes_data > > + .clk_names = { "secss", }, returns the first member of > > static const struct samsung_aes_variant s5p_aes_data = { > > .aes_offset = 0x4000, since the array has only one entry in this case, and so the second, non-existing entry overlaps with the next data item in the object file. So the fix would be to use .clk_names = { "secss", NULL }, instead (or define the array to have 2 members) > > > > > + if (IS_ERR(pdata->pclk)) { > > + dev_err(dev, "failed to find clock %s\n", > > + variant->clk_names[1]); > > + err = -ENOENT; > > + goto err_clk; > > + } > > + > > + err = clk_prepare_enable(pdata->pclk); > > + if (err < 0) { > > + dev_err(dev, "Enabling clock %s failed, err %d\n", > > + variant->clk_names[0], err); > > + goto err_clk; > > + } > > + } else { > > + pdata->pclk = NULL; > > + } > > + > > spin_lock_init(&pdata->lock); > > spin_lock_init(&pdata->hash_lock); > > > > @@ -2295,8 +2331,11 @@ static int s5p_aes_probe(struct platform_device *pdev) > > tasklet_kill(&pdata->tasklet); > > > > err_irq: > > - clk_disable_unprepare(pdata->clk); > > + if (pdata->pclk) > > + clk_disable_unprepare(pdata->pclk); > > > > +err_clk: > > + clk_disable_unprepare(pdata->clk); > > s5p_dev = NULL; > > > > return err; > > @@ -2323,6 +2362,9 @@ static int s5p_aes_remove(struct platform_device *pdev) > > pdata->use_hash = false; > > } > > > > + if (pdata->pclk) > > + clk_disable_unprepare(pdata->pclk); > > + > > clk_disable_unprepare(pdata->clk); > > s5p_dev = NULL; > > > > -- > > 2.20.1 > >