Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp349070ybi; Fri, 26 Jul 2019 10:46:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpGRwLWg+kqHwJXF0GuxbYRON+jHYJ6uRTOh7dC8LnsKCc45D49C80rp++OYSo3UkD25ts X-Received: by 2002:a17:90a:db52:: with SMTP id u18mr100182597pjx.107.1564163182260; Fri, 26 Jul 2019 10:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564163182; cv=none; d=google.com; s=arc-20160816; b=w9qoGq15gMW3WwkNG1XaoqPzjJXXLFJmTI1BDmb0eS61413Y8oFXHuZStiHlIXRQqq P1rH5DM6NKS00ZBYXodQw+V4sQD20OhAwrtoQqoOxcSu7l1Ufv6igMsjLhtgz1RnqzHT 8SDr/Gl80waqmCiH9dCIYW9f+Mluw8zNA5UKZGcJhyAAdWnVxgUwAhWjDqrtXY27Obyt m6LJv2AyJ0rH1ryMR4KaAxwFOho0erJ04hraY3J7I3MbWYsPO35INoddfq1VB+4bW9jC yPWA49hZxntswDMdzC0uPoBXNTqdWTE+qXY/YzMiBUWX9OLDEJO7Ip93DYJhV8nWOJN7 OCfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ie2ZbaQKVdgLYaOBdg6LpPsTHQHH71pjfwd4jPBgXYs=; b=CPoioVRPdVeiKxxhA6gDBJ+J1pMKGubc73f3gdBD2Ak2jYglTEn8QAcWcac3QzAwjt bZI9Exz2dPA+4HkVsOcKJk56sNzuMxCfvhC7lKqhfN7pelMYTy+mnIeSvLEdoDqaywBI 6HVxzoqpKMsbKrIEVk4GnhRddCXEoeaVQK63S5n9zty4pYL7cCF86p8OrLkhl2eOLD7n tmy+XvVscWjZv8FB4HHrtIrrjfQcTd29hQnY//h2TkqakSCp9Y0xow52k+UyhvsvqFTT 9khjkUuGL4qRgzSesFoyUVfVz3tcp2i5RG8IRQWew1H55DkIPrfKNVawn/m9X7EqTR6k /Q4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="YvU/rChB"; 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 a1si22333020pff.73.2019.07.26.10.46.00; Fri, 26 Jul 2019 10:46:22 -0700 (PDT) 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="YvU/rChB"; 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 S1727997AbfGZOJo (ORCPT + 99 others); Fri, 26 Jul 2019 10:09:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:45028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726902AbfGZOJo (ORCPT ); Fri, 26 Jul 2019 10:09:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 66DB521850; Fri, 26 Jul 2019 14:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564150182; bh=tkXLEuLkLzPDR2w8WjxNouA5Bu/rM+Uut2ffX26Qtnc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YvU/rChB/CRL8mlz3pbzUgFRM+/BcV9U4s5a6S3GF0wDUrvt4WUm31YCtSt0fgAK+ QttyzzBPX3CX6MCJm6RKI6qyEcjr6kMDfS6vnAiEq3RFDC67SanmomPY2fbkUuReYa g1A9cjRFfHmYO0YS/8ZBDDt2o3URxzEEVS2Bt1dc= Date: Fri, 26 Jul 2019 16:09:40 +0200 From: Greg KH To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, jank@cadence.com, srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com, Sanyog Kale Subject: Re: [RFC PATCH 04/40] soundwire: intel: add debugfs register dump Message-ID: <20190726140940.GE8767@kroah.com> References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-5-pierre-louis.bossart@linux.intel.com> <20190726140635.GB8767@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190726140635.GB8767@kroah.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 26, 2019 at 04:06:35PM +0200, Greg KH wrote: > On Thu, Jul 25, 2019 at 06:39:56PM -0500, Pierre-Louis Bossart wrote: > > Add debugfs file to dump the Intel SoundWire registers > > > > Credits: this patch is based on an earlier internal contribution by > > Vinod Koul, Sanyog Kale, Shreyas Nc and Hardik Shah. The main change > > is the use of scnprintf to avoid known issues with snprintf. > > > > Signed-off-by: Pierre-Louis Bossart > > --- > > drivers/soundwire/intel.c | 115 ++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 115 insertions(+) > > > > diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c > > index 317873bc0555..aeadc341c0a3 100644 > > --- a/drivers/soundwire/intel.c > > +++ b/drivers/soundwire/intel.c > > @@ -6,6 +6,7 @@ > > */ > > > > #include > > +#include > > #include > > #include > > #include > > @@ -16,6 +17,7 @@ > > #include > > #include > > #include "cadence_master.h" > > +#include "bus.h" > > #include "intel.h" > > > > /* Intel SHIM Registers Definition */ > > @@ -98,6 +100,7 @@ struct sdw_intel { > > struct sdw_cdns cdns; > > int instance; > > struct sdw_intel_link_res *res; > > + struct dentry *fs; > > }; > > > > #define cdns_to_intel(_cdns) container_of(_cdns, struct sdw_intel, cdns) > > @@ -161,6 +164,115 @@ static int intel_set_bit(void __iomem *base, int offset, u32 value, u32 mask) > > return -EAGAIN; > > } > > > > +/* > > + * debugfs > > + */ > > + > > +#define RD_BUF (2 * PAGE_SIZE) > > + > > +static ssize_t intel_sprintf(void __iomem *mem, bool l, > > + char *buf, size_t pos, unsigned int reg) > > +{ > > + int value; > > + > > + if (l) > > + value = intel_readl(mem, reg); > > + else > > + value = intel_readw(mem, reg); > > + > > + return scnprintf(buf + pos, RD_BUF - pos, "%4x\t%4x\n", reg, value); > > +} > > + > > +static ssize_t intel_reg_read(struct file *file, char __user *user_buf, > > + size_t count, loff_t *ppos) > > +{ > > + struct sdw_intel *sdw = file->private_data; > > + void __iomem *s = sdw->res->shim; > > + void __iomem *a = sdw->res->alh; > > + char *buf; > > + ssize_t ret; > > + int i, j; > > + unsigned int links, reg; > > + > > + buf = kzalloc(RD_BUF, GFP_KERNEL); > > + if (!buf) > > + return -ENOMEM; > > + > > + links = intel_readl(s, SDW_SHIM_LCAP) & GENMASK(2, 0); > > + > > + ret = scnprintf(buf, RD_BUF, "Register Value\n"); > > + ret += scnprintf(buf + ret, RD_BUF - ret, "\nShim\n"); > > + > > + for (i = 0; i < 4; i++) { > > + reg = SDW_SHIM_LCAP + i * 4; > > + ret += intel_sprintf(s, true, buf, ret, reg); > > + } > > + > > + for (i = 0; i < links; i++) { > > + ret += scnprintf(buf + ret, RD_BUF - ret, "\nLink%d\n", i); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLSCAP(i)); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS0CM(i)); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS1CM(i)); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS2CM(i)); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS3CM(i)); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_PCMSCAP(i)); > > + > > + for (j = 0; j < 8; j++) { > > + ret += intel_sprintf(s, false, buf, ret, > > + SDW_SHIM_PCMSYCHM(i, j)); > > + ret += intel_sprintf(s, false, buf, ret, > > + SDW_SHIM_PCMSYCHC(i, j)); > > + } > > + > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_PDMSCAP(i)); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_IOCTL(i)); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTMCTL(i)); > > + } > > + > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_WAKEEN); > > + ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_WAKESTS); > > + > > + ret += scnprintf(buf + ret, RD_BUF - ret, "\nALH\n"); > > + for (i = 0; i < 8; i++) > > + ret += intel_sprintf(a, true, buf, ret, SDW_ALH_STRMZCFG(i)); > > + > > + ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); > > + kfree(buf); > > + > > + return ret; > > +} > > + > > +static const struct file_operations intel_reg_fops = { > > + .open = simple_open, > > + .read = intel_reg_read, > > + .llseek = default_llseek, > > +}; > > DEFINE_SIMPLE_ATTRIBUTE()? Oops, I mean DEFINE_SHOW_ATTRIBUTE()?