Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp681262ybh; Sat, 3 Aug 2019 07:36:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9/orcqDBJWHy/2fFFsd3lgjVxARWRpSMWqlf2LFLC8VeV+I8q0Vw5gclEd2VevEdR7Wlx X-Received: by 2002:a17:90a:b00b:: with SMTP id x11mr9538714pjq.120.1564843019288; Sat, 03 Aug 2019 07:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564843019; cv=none; d=google.com; s=arc-20160816; b=tMXv5IHiYKBrOUl40/COyCzyHq+RYLLAMiWW74xtIlYb1424n1bTCfwlAZjDYOonYo yNzKrwQB9Q7J9dHojtOd0T2+nBHjBOByYFq6wFVZh3sF6PO7pxAJhi0f3GneCG0Cb5QR tlWdRFHdx/Q/JhcM6TuPlBH52hbbW8eT5EKBV2bo8+akaLzJiqxSSfxKBGl+/WSyTMjH yx+IHrRuwE+6Ky7RRjLXYS+CjqgOyLLe0eIDRw1nX4ou2AEO0QFBUpQ8PamNQ0AdYiAZ HFq41Z4jiKG2x1YYJWP4DOWsJL+8Ly2kMArvM2QO8E0zKFRVJS4Lp2D8MN+Hcq6ypkM5 X7Dg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ILBcX3ii7HzJYAUqfgo4El3M5RTGMjGTcDTbi4p4aAQ=; b=lziZsYTKkuct8ORpHMfDQNHmKQfaBuuBz1VN+ZKWdF4SFBPszXUWjNWSv6g1W65QQs tOkkDGydYPc3zW1QsAWwxv7yYuPhAh+6UNajSEc3z+rU3wb40Gh3QE37dale2toorg0E xEV3FeX3XgpTXxfDTLmPX/E01g/oDwo76GgdyulYH2rv4LNnkqmeLQkKBVMLzI8zYxN+ R/d8/IjBnq2kP83Nho9zxC9GbRGDaUJ/ma3bwWTmZnjU3zP3kHGH3DZvjG3WaGjpmUEZ hzSxkoAYdapRDdGAvwLTSGV/nK8GK7fceMoZNn3xj/3lF7B6xwRvALKQg7d0mEypk+8W wC0w== 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 m15si40821014pff.267.2019.08.03.07.36.44; Sat, 03 Aug 2019 07:36:59 -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 S1732903AbfHBP33 (ORCPT + 99 others); Fri, 2 Aug 2019 11:29:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:33602 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732701AbfHBP33 (ORCPT ); Fri, 2 Aug 2019 11:29:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Aug 2019 08:29:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,338,1559545200"; d="scan'208";a="175612955" Received: from vivekcha-mobl1.amr.corp.intel.com (HELO [10.251.131.115]) ([10.251.131.115]) by orsmga003.jf.intel.com with ESMTP; 02 Aug 2019 08:29:27 -0700 Subject: Re: [RFC PATCH 15/40] soundwire: cadence_master: handle multiple status reports per Slave To: Vinod Koul Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com, Sanyog Kale References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-16-pierre-louis.bossart@linux.intel.com> <20190802122003.GQ12733@vkoul-mobl.Dlink> From: Pierre-Louis Bossart Message-ID: Date: Fri, 2 Aug 2019 10:29:26 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190802122003.GQ12733@vkoul-mobl.Dlink> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/2/19 7:20 AM, Vinod Koul wrote: > On 25-07-19, 18:40, Pierre-Louis Bossart wrote: >> When a Slave reports multiple status in the sticky bits, find the >> latest configuration from the mirror of the PING frame status and >> update the status directly. >> >> Signed-off-by: Pierre-Louis Bossart >> --- >> drivers/soundwire/cadence_master.c | 34 ++++++++++++++++++++++++------ >> 1 file changed, 28 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c >> index 889fa2cd49ae..25d5c7267c15 100644 >> --- a/drivers/soundwire/cadence_master.c >> +++ b/drivers/soundwire/cadence_master.c >> @@ -643,13 +643,35 @@ static int cdns_update_slave_status(struct sdw_cdns *cdns, >> >> /* first check if Slave reported multiple status */ >> if (set_status > 1) { >> + u32 val; >> + >> dev_warn_ratelimited(cdns->dev, >> - "Slave reported multiple Status: %d\n", >> - mask); >> - /* >> - * TODO: we need to reread the status here by >> - * issuing a PING cmd >> - */ >> + "Slave %d reported multiple Status: %d\n", >> + i, mask); >> + >> + /* re-check latest status extracted from PING commands */ >> + val = cdns_readl(cdns, CDNS_MCP_SLAVE_STAT); >> + val >>= (i * 2); >> + >> + switch (val & 0x3) { >> + case 0: > > why not case CDNS_MCP_SLAVE_INTSTAT_NPRESENT: ok > >> + status[i] = SDW_SLAVE_UNATTACHED; >> + break; >> + case 1: >> + status[i] = SDW_SLAVE_ATTACHED; >> + break; >> + case 2: >> + status[i] = SDW_SLAVE_ALERT; >> + break; >> + default: >> + status[i] = SDW_SLAVE_RESERVED; >> + break; >> + } > > we have same logic in the code block preceding this, maybe good idea to > write a helper and use for both Yes, I am thinking about this. There are multiple cases where we want to re-check the status and clear some bits, so helpers would be good. > > Also IIRC we can have multiple status set right? Yes, the status bits are sticky and mirror all values reported in PING frames. I am still working on how to clear those bits, there are cases where we clear bits and end-up never hearing from that device ever again. classic edge/level issue I suppose.