Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2019291imu; Fri, 14 Dec 2018 04:36:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xh4QIuSp672644vF0VUqjT8QQ/qLITatZ5MmQcss+UsOOeCMd7zsTUoBvvzHhI2NxNjCGS X-Received: by 2002:a17:902:365:: with SMTP id 92mr2578392pld.327.1544790973892; Fri, 14 Dec 2018 04:36:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790973; cv=none; d=google.com; s=arc-20160816; b=E4yosW7yR1apmU4QZb39J16P0KTgjbvpV2/e7ET6MOHVWdsl9uxTnDkK3CANo+g6Oh cX/Km/dCVVvQxroRq6/+aLyOmx4OfVWjoCq6PKYSnckOXPLAip1MVlg1wBUSgT4zsaZY svZfKiRd7Z0P6J0QmyJDEZ7JApaUxffWO7eOZR0jCt17/kyby//+kBZX82xQWF4A5hEu 3wU/XTP1qvtlwGMpMzyk/RazmKe1cqCEvy2yIfcsMnd5ecbGSV+SFlLuRZpZsNSqRhlD uVfLtWHAOWKs8bnKXjtMEjz0aTwNffku2o3L2ZBfTC259Fwv0TIdLNoqzBbcW4BGJWZM potA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hQFdN7g+mZsDcAo9+AidL+U7ijMUeK/aWPu8wrCrnrM=; b=ieaXelRh33tIxd8RuVRvIiJ81ZeGUFKrUJTS/fR2Bg+/TFF1+ablLNOniWTWCsJ8Ow MTc9GHJh5faBCkvKdZ5NkIWACKQn6R2Z6iWHQ1Pn8VijyS8Q3B0WGOv0FjlBjgdu+tjO GXX4eHkzJ5Bl9usPC5AUnG1FbIwC/4pCSLTnzMstpLjoY2UwgyHop0QoMD1HAqQ73CZK nZk8kHYuQcqDg3w13OTvnaY0zyD2YIpcqmXAZvCg0QLCgqnanmcvVsbdsHgswdhfRGt7 AxWe4IQvEorYThS1qE1v/JQdNtXKcl8dy8SSfdIFDsuq9hx7kh4mcKN2I0gHXftjyaum PUuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e4PMohSR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si3944916pgm.462.2018.12.14.04.35.56; Fri, 14 Dec 2018 04:36: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=@kernel.org header.s=default header.b=e4PMohSR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731075AbeLNMeF (ORCPT + 99 others); Fri, 14 Dec 2018 07:34:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:53578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731223AbeLNMIK (ORCPT ); Fri, 14 Dec 2018 07:08:10 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 96C8321486; Fri, 14 Dec 2018 12:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789289; bh=HTlKL/VmjP7yJYYvsMnPaUxdkOfNU2kC9Pa8PLhiHac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e4PMohSR/yfri9su/YJzwsv3BZVpzg9v3ovsg7CRg2bPZ97lekDbM3+U/3FdAOwgY HwtXjc7wIFh+Sp+k5MDWkPXBdPU6eH2ugJU2SWPUVE1o8SpNy1Q3Rx5EnQSUBc787n +LQJHg70Rtl0WB5vmClMXGhsX2JsHBOXU/IXCfYY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Fitzgerald , Mark Brown , Sasha Levin Subject: [PATCH 4.14 25/89] ASoC: wm_adsp: Fix dma-unsafe read of scratch registers Date: Fri, 14 Dec 2018 12:59:38 +0100 Message-Id: <20181214115730.922488187@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115729.658859279@linuxfoundation.org> References: <20181214115729.658859279@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 20e00db2f59bdddf8a8e241473ef8be94631d3ae ] Stack memory isn't DMA-safe so it isn't safe to use either regmap_raw_read or regmap_bulk_read to read into stack memory. The two functions to read the scratch registers were using stack memory and regmap_raw_read. It's not worth allocating memory just for this trivial read, and it isn't time-critical. A simple regmap_read for each register is sufficient. Signed-off-by: Richard Fitzgerald Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wm_adsp.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 989d093abda7..67330b6ab204 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -787,38 +787,41 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem, static void wm_adsp2_show_fw_status(struct wm_adsp *dsp) { - u16 scratch[4]; + unsigned int scratch[4]; + unsigned int addr = dsp->base + ADSP2_SCRATCH0; + unsigned int i; int ret; - ret = regmap_raw_read(dsp->regmap, dsp->base + ADSP2_SCRATCH0, - scratch, sizeof(scratch)); - if (ret) { - adsp_err(dsp, "Failed to read SCRATCH regs: %d\n", ret); - return; + for (i = 0; i < ARRAY_SIZE(scratch); ++i) { + ret = regmap_read(dsp->regmap, addr + i, &scratch[i]); + if (ret) { + adsp_err(dsp, "Failed to read SCRATCH%u: %d\n", i, ret); + return; + } } adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", - be16_to_cpu(scratch[0]), - be16_to_cpu(scratch[1]), - be16_to_cpu(scratch[2]), - be16_to_cpu(scratch[3])); + scratch[0], scratch[1], scratch[2], scratch[3]); } static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp) { - u32 scratch[2]; + unsigned int scratch[2]; int ret; - ret = regmap_raw_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH0_1, - scratch, sizeof(scratch)); - + ret = regmap_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH0_1, + &scratch[0]); if (ret) { - adsp_err(dsp, "Failed to read SCRATCH regs: %d\n", ret); + adsp_err(dsp, "Failed to read SCRATCH0_1: %d\n", ret); return; } - scratch[0] = be32_to_cpu(scratch[0]); - scratch[1] = be32_to_cpu(scratch[1]); + ret = regmap_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH2_3, + &scratch[1]); + if (ret) { + adsp_err(dsp, "Failed to read SCRATCH2_3: %d\n", ret); + return; + } adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", scratch[0] & 0xFFFF, -- 2.19.1