Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp557571ybi; Fri, 26 Jul 2019 14:46:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqww8IaK5ZI1hNgeVOaPCOlX7JC14vlDOQQtpKUOpZ35Je078uibitbhN+HTaEc4YGWfhl+O X-Received: by 2002:a62:1b0c:: with SMTP id b12mr24025865pfb.17.1564177605639; Fri, 26 Jul 2019 14:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564177605; cv=none; d=google.com; s=arc-20160816; b=zmjMgeBs25QWVQdZUvUxAzfKyWK5+8vaJYvzeAVSQleoffsNv8MkoS6N4OEna49tSc NdIMfWhHxknLBA3xaEObfPhU8nGhXRs/F0L61vSfYtf9c1IluoHLO6kithPT9A+Fa2AX eNZ7wsYCh5oaeaGN81KaSXQPwrJGbKexjQZDc1LaigGnD6QoR3qimMFUUporSe9o+EOi us/tgfVskSdbWvqxK/iv2qEgxELSXGQk/0Y4FsD3AylH9cgQgiUpFPOuCx1qrYdxcGlT umRswNdX5yqnVesDKRzlQ8k2YfPkExd4Rt8K504yadGqymyPCmeIfxz6MInOMbqwLsKT uncg== 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; bh=BLdQoEWKDh558Wq3p6+Qug78B8KmlFA5gQwYPtvQkYc=; b=EgZ55eHSZZcsaHuBGbmmBOIz9BcFnxZx8E5ayT+4VgRuNjC2pyiUoWB69UK/ufRZw+ gleA40zHoVmDqyADxMidXwiznFtjgjmIqf7QSJluynEHBWWyLwnx1jkJ2bWelEIMUuCU YZudobMS9E+wITOwndDfg+p3XRgoCxWso6lNV+CewC6aC3GT3mR7Y85ZnCnBUus9jLDG vAPVnzQnF7LbbUg7C6/oe173pNqUbxl8X723X9i/HtGmxYjNpFZsR9gKG3Mi8reyRSvp A/Ir28A6szgUP9Qg9xPth2nsg4PO5JAm2aD3Hc/jd6MUExoLe3HSWFXNTMkUOPxT3GHf 91Nw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si6894164pgh.434.2019.07.26.14.46.29; Fri, 26 Jul 2019 14:46:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726440AbfGZPzZ (ORCPT + 99 others); Fri, 26 Jul 2019 11:55:25 -0400 Received: from mga18.intel.com ([134.134.136.126]:59152 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbfGZPzZ (ORCPT ); Fri, 26 Jul 2019 11:55:25 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2019 08:55:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,311,1559545200"; d="scan'208";a="172261960" Received: from gliakhov-mobl2.ger.corp.intel.com (HELO ubuntu) ([10.249.35.244]) by fmsmga007.fm.intel.com with ESMTP; 26 Jul 2019 08:55:21 -0700 Date: Fri, 26 Jul 2019 17:55:20 +0200 From: Guennadi Liakhovetski To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, tiwai@suse.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, srinivas.kandagatla@linaro.org, jank@cadence.com, slawomir.blauciak@intel.com, Sanyog Kale Subject: Re: [alsa-devel] [RFC PATCH 36/40] soundwire: intel: disable interrupts on suspend Message-ID: <20190726155520.GL16003@ubuntu> References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-37-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190725234032.21152-37-pierre-louis.bossart@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 25, 2019 at 06:40:28PM -0500, Pierre-Louis Bossart wrote: > Signed-off-by: Pierre-Louis Bossart > --- > drivers/soundwire/cadence_master.c | 42 +++++++++++++++++------------- > drivers/soundwire/cadence_master.h | 2 +- > drivers/soundwire/intel.c | 6 +++-- > 3 files changed, 29 insertions(+), 21 deletions(-) > > diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c > index f486fe15fb46..fa7230b0f200 100644 > --- a/drivers/soundwire/cadence_master.c > +++ b/drivers/soundwire/cadence_master.c > @@ -814,33 +814,39 @@ EXPORT_SYMBOL(sdw_cdns_exit_reset); > * sdw_cdns_enable_interrupt() - Enable SDW interrupts and update config > * @cdns: Cadence instance > */ > -int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns) > +int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state) > { > u32 mask; > > - cdns_writel(cdns, CDNS_MCP_SLAVE_INTMASK0, > - CDNS_MCP_SLAVE_INTMASK0_MASK); > - cdns_writel(cdns, CDNS_MCP_SLAVE_INTMASK1, > - CDNS_MCP_SLAVE_INTMASK1_MASK); > + if (state) { > + cdns_writel(cdns, CDNS_MCP_SLAVE_INTMASK0, > + CDNS_MCP_SLAVE_INTMASK0_MASK); > + cdns_writel(cdns, CDNS_MCP_SLAVE_INTMASK1, > + CDNS_MCP_SLAVE_INTMASK1_MASK); > > - /* enable detection of slave state changes */ > - mask = CDNS_MCP_INT_SLAVE_RSVD | CDNS_MCP_INT_SLAVE_ALERT | > - CDNS_MCP_INT_SLAVE_ATTACH | CDNS_MCP_INT_SLAVE_NATTACH; > + /* enable detection of slave state changes */ > + mask = CDNS_MCP_INT_SLAVE_RSVD | CDNS_MCP_INT_SLAVE_ALERT | > + CDNS_MCP_INT_SLAVE_ATTACH | CDNS_MCP_INT_SLAVE_NATTACH; > > - /* enable detection of bus issues */ > - mask |= CDNS_MCP_INT_CTRL_CLASH | CDNS_MCP_INT_DATA_CLASH | > - CDNS_MCP_INT_PARITY; > + /* enable detection of bus issues */ > + mask |= CDNS_MCP_INT_CTRL_CLASH | CDNS_MCP_INT_DATA_CLASH | > + CDNS_MCP_INT_PARITY; > > - /* no detection of port interrupts for now */ > + /* no detection of port interrupts for now */ > > - /* enable detection of RX fifo level */ > - mask |= CDNS_MCP_INT_RX_WL; > + /* enable detection of RX fifo level */ > + mask |= CDNS_MCP_INT_RX_WL; > > - /* now enable all of the above */ > - mask |= CDNS_MCP_INT_IRQ; > + /* now enable all of the above */ > + mask |= CDNS_MCP_INT_IRQ; > > - if (interrupt_mask) /* parameter override */ > - mask = interrupt_mask; > + if (interrupt_mask) /* parameter override */ > + mask = interrupt_mask; > + } else { > + cdns_writel(cdns, CDNS_MCP_SLAVE_INTMASK0, 0); > + cdns_writel(cdns, CDNS_MCP_SLAVE_INTMASK1, 0); > + mask = 0; > + } Looks like this should be two functions? Especially since "state" is always a constant when it is called. If there is still a lot of common code below, maybe make it a helper function. Thanks Guennadi > > cdns_writel(cdns, CDNS_MCP_INTMASK, mask); > > diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h > index 2b551f9226f3..1a0ba36dd78f 100644 > --- a/drivers/soundwire/cadence_master.h > +++ b/drivers/soundwire/cadence_master.h > @@ -162,7 +162,7 @@ int sdw_cdns_init(struct sdw_cdns *cdns); > int sdw_cdns_pdi_init(struct sdw_cdns *cdns, > struct sdw_cdns_stream_config config); > int sdw_cdns_exit_reset(struct sdw_cdns *cdns); > -int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns); > +int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state); > > void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root); > > diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c > index 9ebe38e4d979..1192d5775484 100644 > --- a/drivers/soundwire/intel.c > +++ b/drivers/soundwire/intel.c > @@ -1110,7 +1110,7 @@ static int intel_probe(struct platform_device *pdev) > goto err_init; > } > > - ret = sdw_cdns_enable_interrupt(&sdw->cdns); > + ret = sdw_cdns_enable_interrupt(&sdw->cdns, true); > > ret = sdw_cdns_exit_reset(&sdw->cdns); > > @@ -1169,6 +1169,8 @@ static int intel_suspend(struct device *dev) > return 0; > } > > + sdw_cdns_enable_interrupt(&sdw->cdns, false); > + > ret = intel_link_power_down(sdw); > if (ret) { > dev_err(dev, "Link power down failed: %d", ret); > @@ -1199,7 +1201,7 @@ static int intel_resume(struct device *dev) > return ret; > } > > - sdw_cdns_enable_interrupt(&sdw->cdns); > + sdw_cdns_enable_interrupt(&sdw->cdns, true); > > ret = sdw_cdns_exit_reset(&sdw->cdns); > > -- > 2.20.1 > > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > https://mailman.alsa-project.org/mailman/listinfo/alsa-devel