From patchwork Thu Jun 29 06:56:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guneshwor Singh X-Patchwork-Id: 9816093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DFF8D60365 for ; Thu, 29 Jun 2017 06:57:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4E5228518 for ; Thu, 29 Jun 2017 06:57:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C75212856D; Thu, 29 Jun 2017 06:57:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E351F28518 for ; Thu, 29 Jun 2017 06:57:11 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 99E28266E53; Thu, 29 Jun 2017 08:57:06 +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 8C43F266E4C; Thu, 29 Jun 2017 08:57:04 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id DE122266E3C for ; Thu, 29 Jun 2017 08:56:58 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jun 2017 23:56:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,279,1496127600"; d="scan'208";a="102625539" Received: from g2.iind.intel.com ([10.223.96.134]) by orsmga004.jf.intel.com with ESMTP; 28 Jun 2017 23:56:53 -0700 From: Guneshwor Singh To: alsa-devel@alsa-project.org, Mark Brown Date: Thu, 29 Jun 2017 12:26:01 +0530 Message-Id: <20170629065604.30105-2-guneshwor.o.singh@intel.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170629065604.30105-1-guneshwor.o.singh@intel.com> References: <20170629065604.30105-1-guneshwor.o.singh@intel.com> Cc: Takashi Iwai , Guneshwor Singh , Patches Audio , liam.r.girdwood@linux.intel.com, Vinod Koul , Vunny Sodhi Subject: [alsa-devel] [PATCH v2 1/4] ASoC: Intel: Skylake: Add debugfs support 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 X-Virus-Scanned: ClamAV using ClamSMTP From: Vinod Koul For debug, the kernel debugfs mechanism is available. We can add various debug options for driver like module configuration read, firmware register read etc. This patch adds debugfs root and caller is added for skylake driver to do init and cleanup of debugfs Signed-off-by: Vinod Koul Signed-off-by: Vunny Sodhi Signed-off-by: Guneshwor Singh --- sound/soc/intel/skylake/Makefile | 4 +++ sound/soc/intel/skylake/skl-debug.c | 54 +++++++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl.c | 5 ++++ sound/soc/intel/skylake/skl.h | 16 +++++++++++ 4 files changed, 79 insertions(+) create mode 100644 sound/soc/intel/skylake/skl-debug.c diff --git a/sound/soc/intel/skylake/Makefile b/sound/soc/intel/skylake/Makefile index 60fbc9bbe473..e7d77722d560 100644 --- a/sound/soc/intel/skylake/Makefile +++ b/sound/soc/intel/skylake/Makefile @@ -1,6 +1,10 @@ snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \ skl-topology.o +ifdef CONFIG_DEBUG_FS + snd-soc-skl-objs += skl-debug.o +endif + obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o # Skylake IPC Support diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c new file mode 100644 index 000000000000..c9a387e3d4f6 --- /dev/null +++ b/sound/soc/intel/skylake/skl-debug.c @@ -0,0 +1,54 @@ +/* + * skl-debug.c - Debugfs for skl driver + * + * Copyright (C) 2016-17 Intel Corp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#include +#include +#include "skl.h" + +struct skl_debug { + struct skl *skl; + struct device *dev; + + struct dentry *fs; +}; + +struct skl_debug *skl_debugfs_init(struct skl *skl) +{ + struct skl_debug *d; + + d = devm_kzalloc(&skl->pci->dev, sizeof(*d), GFP_KERNEL); + if (!d) + return NULL; + + /* create the root dir first */ + d->fs = debugfs_create_dir(KBUILD_MODNAME, NULL); + if (IS_ERR(d->fs) || !d->fs) { + dev_err(&skl->pci->dev, "debugfs root creation failed\n"); + return NULL; + } + + d->skl = skl; + d->dev = &skl->pci->dev; + + return d; +} + +void skl_debugfs_exit(struct skl_debug *d) +{ + debugfs_remove_recursive(d->fs); + + kfree(d); + +} diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index e761550c6dad..f4194d189d07 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -815,6 +815,9 @@ static int skl_probe(struct pci_dev *pci, schedule_work(&skl->probe_work); + /* init debugfs */ + skl->debugfs = skl_debugfs_init(skl); + return 0; out_dsp_free: @@ -866,6 +869,8 @@ static void skl_remove(struct pci_dev *pci) /* codec removal, invoke bus_device_remove */ snd_hdac_ext_bus_device_remove(ebus); + skl_debugfs_exit(skl->debugfs); + skl->debugfs = NULL; skl_platform_unregister(&pci->dev); skl_free_dsp(skl); skl_machine_device_unregister(skl); diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 2a630fcb7f08..a47779c819d5 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -42,6 +42,8 @@ struct skl_dsp_resource { u32 mem; }; +struct skl_debug; + struct skl { struct hdac_ext_bus ebus; struct pci_dev *pci; @@ -66,6 +68,8 @@ struct skl { int supend_active; struct work_struct probe_work; + + struct skl_debug *debugfs; }; #define skl_to_ebus(s) (&(s)->ebus) @@ -116,4 +120,16 @@ void skl_update_d0i3c(struct device *dev, bool enable); int skl_nhlt_create_sysfs(struct skl *skl); void skl_nhlt_remove_sysfs(struct skl *skl); +#ifdef CONFIG_DEBUG_FS +struct skl_debug *skl_debugfs_init(struct skl *skl); +void skl_debugfs_exit(struct skl_debug *d); +#else +static inline struct skl_debug *skl_debugfs_init(struct skl *skl) +{ + return NULL; +} +static inline void skl_debugfs_exit(struct skl_debug *d) +{} +#endif + #endif /* __SOUND_SOC_SKL_H */