From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753485AbdLDDww (ORCPT ); Sun, 3 Dec 2017 22:52:52 -0500 Received: from mga14.intel.com ([192.55.52.115]:50331 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752060AbdLDDwv (ORCPT ); Sun, 3 Dec 2017 22:52:51 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,357,1508828400"; d="scan'208";a="183216937" Subject: Re: [alsa-devel] [PATCH v4 09/15] soundwire: Add slave status handling To: Vinod Koul Cc: Greg Kroah-Hartman , LKML , ALSA , Mark , Takashi , patches.audio@intel.com, alan@linux.intel.com, Charles Keepax , Sagar Dharia , srinivas.kandagatla@linaro.org, plai@codeaurora.org, Sudheer Papothi References: <1512122177-2889-1-git-send-email-vinod.koul@intel.com> <1512122177-2889-10-git-send-email-vinod.koul@intel.com> <693f15b3-3751-2416-5d81-abd362464309@linux.intel.com> <20171203171139.GQ32417@localhost> <20171204032059.GY32417@localhost> From: Pierre-Louis Bossart Message-ID: <382cc7a0-a478-fb30-9ea4-22f828cd9093@linux.intel.com> Date: Sun, 3 Dec 2017 21:52:48 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171204032059.GY32417@localhost> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/3/17 9:21 PM, Vinod Koul wrote: > On Sun, Dec 03, 2017 at 09:11:39PM -0600, Pierre-Louis Bossart wrote: >> On 12/3/17 11:11 AM, Vinod Koul wrote: >>> On Fri, Dec 01, 2017 at 05:52:03PM -0600, Pierre-Louis Bossart wrote: >>> >>>>> + status = sdw_read(slave, SDW_DP0_INT); >>>>> + if (status < 0) { >>>>> + dev_err(slave->bus->dev, >>>>> + "SDW_DP0_INT read failed:%d", status); >>>>> + return status; >>>>> + } >>>>> + >>>>> + count++; >>>>> + >>>>> + /* we can get alerts while processing so keep retrying */ >>>> >>>> This is not incorrect, but this goes beyond what the spec requires. >>>> >>>> The additional read is to make sure some interrupts are not lost due to a >>>> known race condition. It would be enough to mask the status read the second >>>> time to only check if the interrupts sources which were cleared are still >>>> signaling something. >>>> >>>> With the code as it is, you may catch *new* interrupt sources, which could >>>> impact the arbitration/priority/policy in handling interrupts. It's not >>>> necessarily bad, but you'd need to document whether you want to deal with >>>> the race condition described in the MIPI spec or try to be smarter. >>> >>> This was based on your last comment, lets discuss more offline on this to >>> see what else is required here. >> >> I am fine if you leave the code as is for now, it's not bad but can be >> optimized. > > Not bad is not good here :) > > Okay I still havent grabbed my coffee, so help me out here. I am not sure I > understand here, can you point me to the part of spec handling you were > referring and what should be *ideally* done You first read the status, then clear the interrupts then re-read the status. I'd be good enough in the second read to mask with the settings of the first read. This is intended to detect alert sources that fired between the last successful read and the write to clear interrupts (see Figure 92 in the 1.1 spec) e.g. do { status1= sdw_read() deal with interrupts status2 = sdw_read() status2 &= status1; /* filter initial sources */ /* we can get alerts while processing so keep retrying */ } while (status2 != 0 && count < SDW_READ_INTR_CLEAR_RETRY);