From patchwork Wed Jun 20 14:07:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 139346 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp837680lji; Wed, 20 Jun 2018 07:08:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIUV3n9kw3OPuqbz/bgXhehiLwaOQnM/WMbeDyIhHASP/0PQX6wS0HgIun5e+KQrdCLZFQW X-Received: by 2002:a1c:a010:: with SMTP id j16-v6mr1814667wme.61.1529503694362; Wed, 20 Jun 2018 07:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529503694; cv=none; d=google.com; s=arc-20160816; b=WqcRNctRjvHkRmMM0a4LIjc2GFSO8YkzsL4SVVC8M9SGa8cDo7HjzNLKjQGmKf13uR mMpqEOBvlFIGA/xr4HySVokHVF6/vmFAQ2FiXiWrguo1mLrrZ5ceVmlmPQDxU1qFzKp8 +VtqNA4gJgXQolOFASYE+ifG8/bsUfG0f72S/zSWiDJecAClKIKnUKmGGykTqezqZl7Q hs2I+tusRQXVIkcNYprPmdzHQvYGv4Gzwg5+m9zfrvbUQcTdDbDJmBPHRZsWZfBR3+Pa 5Y7siM4YWv/wBcpqHX9iTZNJGLJ6QgahDrCUcewxQP+uRn8roOj3WcBHH/rGoaxXPEwl c4EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=2I8syR58IIV2+LWHLn8qFy3bsWXxLtdLsrVZFXBwTmA=; b=ZXBHW4S9eFik87/PkF9pnaUV6QQf297q5hZbDgK9P/BLCE2EtgMKS7Rz4VkQYZjwQy bZ2u8Qj/aRQoRDD56X3eXY9zov+IOjqhMR2PoqbreNub0IVDz+k1ArPwas6ZAF/PV2qq fEAxE4FROEHGqE/4TICWmsX/T4KYmuGTxRbrzyQsPvn3EXjeHoA5+Mc8jD0M4yJ/TLzp PKDV3ZBObUESFBgMZ5GKm1fFtYDnkBj1C5AzbJRh2jw6n86cJFjbupI/qw/uGEBQktC8 yoLeRhFtQvFpEYpY+Wdg9JxLKrqa12+fmSJ9Ma0ycu4GPVEvtIzddlgoSfSnpIoaKIeb fQ9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=AQaeNVXG; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id k12-v6si2742504wrg.375.2018.06.20.07.08.14; Wed, 20 Jun 2018 07:08:14 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=AQaeNVXG; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0DA9E2676C3; Wed, 20 Jun 2018 16:08:09 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5EDD6267601; Wed, 20 Jun 2018 16:08:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id D3AC62673CF for ; Wed, 20 Jun 2018 16:08:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=8lvbUuEwoq1HARwGGf+2nw6/R8m+V/D6k3n3ljLjXY4=; b=AQaeNVXGdd2s Ctb9uGpNie8i3lGZWZzT93GbJIJ1QZHVA+m+l2Q8chIn6Sy9VscHuiKsmbkxm4FfvZdgOm/Cw+6my PzKZ/aI10LIhzgETvieXdgdtZ1D5fhkEePAV/izhTK0oKIcEzBE6LpcUXf1ep/WEe8N4EWDvjg0zf 3fwKU=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fVdmC-0002Jc-05; Wed, 20 Jun 2018 14:08:00 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fVdmB-0001qH-IM; Wed, 20 Jun 2018 15:07:59 +0100 From: Mark Brown To: Charles Keepax In-Reply-To: <20180620105621.2660-2-ckeepax@opensource.cirrus.com> Message-Id: Date: Wed, 20 Jun 2018 15:07:59 +0100 Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com Subject: [alsa-devel] Applied "ASoC: wm_adsp: Simplify handling of alg offset and length" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: wm_adsp: Simplify handling of alg offset and length has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 7f7cca08abf4c6c58ff1037cff5beec5a10a7da3 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Wed, 20 Jun 2018 11:56:21 +0100 Subject: [PATCH] ASoC: wm_adsp: Simplify handling of alg offset and length The current code that reads the algorithm list from the DSP is somewhat unclear, it converts directly from bytes to registers using a hard coded divide by 2. Most offsets are usually handled in DSP words within the driver and there is a function specifically for converting from words to register addresses. So update the handling to use these. This also removes the assumption that the registers are 16-bit word addressed, which will no longer be true on some of our newer parts. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm_adsp.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) -- 2.17.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 2fcdd84021a5..07c17acc8a4f 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1871,9 +1871,11 @@ static void wm_adsp_ctl_fixup_base(struct wm_adsp *dsp, } static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, + const struct wm_adsp_region *mem, unsigned int pos, unsigned int len) { void *alg; + unsigned int reg; int ret; __be32 val; @@ -1888,7 +1890,9 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, } /* Read the terminator first to validate the length */ - ret = regmap_raw_read(dsp->regmap, pos + len, &val, sizeof(val)); + reg = wm_adsp_region_to_reg(mem, pos + len); + + ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); if (ret != 0) { adsp_err(dsp, "Failed to read algorithm list end: %d\n", ret); @@ -1897,13 +1901,18 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, if (be32_to_cpu(val) != 0xbedead) adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n", - pos + len, be32_to_cpu(val)); + reg, be32_to_cpu(val)); + + /* Convert length from DSP words to bytes */ + len *= sizeof(u32); alg = kcalloc(len, 2, GFP_KERNEL | GFP_DMA); if (!alg) return ERR_PTR(-ENOMEM); - ret = regmap_raw_read(dsp->regmap, pos, alg, len * 2); + reg = wm_adsp_region_to_reg(mem, pos); + + ret = regmap_raw_read(dsp->regmap, reg, alg, len); if (ret != 0) { adsp_err(dsp, "Failed to read algorithm list: %d\n", ret); kfree(alg); @@ -2002,10 +2011,11 @@ static int wm_adsp1_setup_algs(struct wm_adsp *dsp) if (IS_ERR(alg_region)) return PTR_ERR(alg_region); - pos = sizeof(adsp1_id) / 2; - len = (sizeof(*adsp1_alg) * n_algs) / 2; + /* Calculate offset and length in DSP words */ + pos = sizeof(adsp1_id) / sizeof(u32); + len = (sizeof(*adsp1_alg) * n_algs) / sizeof(u32); - adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem->base + pos, len); + adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); if (IS_ERR(adsp1_alg)) return PTR_ERR(adsp1_alg); @@ -2113,10 +2123,11 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp) if (IS_ERR(alg_region)) return PTR_ERR(alg_region); - pos = sizeof(adsp2_id) / 2; - len = (sizeof(*adsp2_alg) * n_algs) / 2; + /* Calculate offset and length in DSP words */ + pos = sizeof(adsp2_id) / sizeof(u32); + len = (sizeof(*adsp2_alg) * n_algs) / sizeof(u32); - adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem->base + pos, len); + adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); if (IS_ERR(adsp2_alg)) return PTR_ERR(adsp2_alg);