Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp438616ybt; Wed, 17 Jun 2020 05:09:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE0wD/H2Pr1UeTLCKYUo7QM0UsQdtITQ6JbmyQeKro8EqfdsM7LxzldFJK4295eAWvzrWX X-Received: by 2002:a17:906:33c5:: with SMTP id w5mr3395222eja.275.1592395780706; Wed, 17 Jun 2020 05:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592395780; cv=none; d=google.com; s=arc-20160816; b=suQjakYGKgQmRZzEOtOfaTG1LDTolkxIzvBpVa0wUDOTxgAGm5zVV1oLzZxV9StkOJ 0Svy0QcofuVrVdmSG0yud5AByHqDdiSUha2A0hvqEYBuHl3E0HOnkYNyQscA1d3ohjHE 9NCpLb9AyQDsZ5rzi33F56tXox3mikuE0xj+5TnWbxr4batoI3+8KRxVToWtKT7j6SBr 3woiPL1LW9xnQTl4y36xpx6K/TZ8eOT5cXkAQJrNC99U5jERrCVMiBME4Wq3B0wvhpkV LSTqJfYUBGNrRkBj9STE/g03RjiQNGOxenOpuQFOD7Yxcvhe+qvfKQUYNPpM0OV1hS5n WBhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oK1miWNWYOKPjuspWCCpSQeFxt/H9WWh4wjWuUE9BvY=; b=A78vELohJmj7l135E7gn2WC+6UPPWaZQ/CvRbkzNG+IkCWQU8GXWcztTELVAaL8qvk c2uHpUjqYRky3PngD/ISeO/wluVrCGOAboA+WGi4F8R8Shvy1ci34FcKQPVCgYYIEHlk FAfSWhvjWiKG+mN6o61JaKeDNHju6kvbelccxETesh+/zRnxWjFKPfIkQzlg6IIiRG9A teiKOiyck+hpQw2f/HpBM0lM46i4lu7U8DcfjPBHL+pTGfR24ddcwFRJk+sWT+pbweiA 6JZvzxlIyKM15bGcEzFdRaj4zn27SuUEhuky+FIk++NwBFvs/zTVQliSGNHF/G/3sP3G Jmgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zYAUeoba; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l30si14413634edj.499.2020.06.17.05.09.17; Wed, 17 Jun 2020 05:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zYAUeoba; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726480AbgFQMG5 (ORCPT + 99 others); Wed, 17 Jun 2020 08:06:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbgFQMG5 (ORCPT ); Wed, 17 Jun 2020 08:06:57 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B71AC061573 for ; Wed, 17 Jun 2020 05:06:56 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id k7so336275ooo.12 for ; Wed, 17 Jun 2020 05:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oK1miWNWYOKPjuspWCCpSQeFxt/H9WWh4wjWuUE9BvY=; b=zYAUeobaou6XLm+qcgcX4FwIIvQpXwj8kympi0GOHqzllYblgQdAJTbWQ+SSpNrkNi Xvvq+vhSq7PnW44GFx0iH0+sWZmJVhaORYR8tCJjLuCrEE69i0VeY8Nwf4Gtd+7jAZ43 wazBVn+5m9HsDfxtBQPErV3v1v71e7gS8WGPKcPLkwzyo5QwMyZPWT1v/aHnvCsWKxaY P+sWRMDCSJBZ6Kqt073gt+eU1KBW4qYkaFsUylmV81qBLsNIcePl9hpOSWi2MqmrRd7i K6lMefpLFhqgOKi3wMp/i2DAVs8nZbFT48Le4dqqYHprvOqxAFvbMN48IkZIq9adh8OT uALA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oK1miWNWYOKPjuspWCCpSQeFxt/H9WWh4wjWuUE9BvY=; b=kLaL2pknR46ZGETTTrqUP+9UgLh+BmG+NrrgfEvfAaKB5vsefr+tyvrcKKwLQmfiL8 mtcSD2BQUQ1hrJlBa8gnhtwsd3ISBlB8I8Afshho6zOWltrspqfJwnd2D2Ziqt/Qjl8+ A6y+laCeBIhF9tjDBmeQxfbmKVCkp0PwKH8mXX6+oN/Bi8sZb0S6xj6ULiq4uH0tIZWW ngr7yCrsRdjfvfDX+wJ5OA03adbF0cS5Z/8lablTlYlmxLhO5t8LXIrxr8TLyWtOZVCs fJAhYErR8eZ1eMcS1hSNRZWDV/WEM4ydI5VrKVwPYVmoi2Y9mrShLFcd3hsDLxCZMUPL h2AA== X-Gm-Message-State: AOAM531j7Tp62f6xcuUxOrfJGyfHkjujkw+MO2TKU3Qo2C6VRl3aA7IJ iVSnuGZiMDzRFA+wE3k4dWpVlP6vNfl//yRsrxt6fQ== X-Received: by 2002:a4a:abcb:: with SMTP id o11mr6538059oon.58.1592395615229; Wed, 17 Jun 2020 05:06:55 -0700 (PDT) MIME-Version: 1.0 References: <20200602100924.26256-1-sumit.semwal@linaro.org> <20200602100924.26256-6-sumit.semwal@linaro.org> <20200602122205.GF5684@sirena.org.uk> In-Reply-To: <20200602122205.GF5684@sirena.org.uk> From: Sumit Semwal Date: Wed, 17 Jun 2020 17:36:43 +0530 Message-ID: Subject: Re: [PATCH v4 5/5] regulator: qcom: labibb: Add SC interrupt handling To: Mark Brown Cc: agross@kernel.org, Bjorn Andersson , lgirdwood@gmail.com, robh+dt@kernel.org, Nisha Kumari , linux-arm-msm@vger.kernel.org, LKML , devicetree@vger.kernel.org, kgunda@codeaurora.org, Rajendra Nayak Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, On Tue, 2 Jun 2020 at 17:52, Mark Brown wrote: > > On Tue, Jun 02, 2020 at 03:39:24PM +0530, Sumit Semwal wrote: > > > static int qcom_labibb_regulator_enable(struct regulator_dev *rdev) > > { > > - return regulator_enable_regmap(rdev); > > + int ret; > > + struct labibb_regulator *reg = rdev_get_drvdata(rdev); > > + > > + ret = regulator_enable_regmap(rdev); > > + if (ret >= 0) > > + reg->enabled = true; > > Can we not read the register we just wrote to here? As I mentioned in the other patch, it seems there is a (noticeable) delay in getting the value to reflect in this register for IBB. Also, from the notes from the downstream driver (also copied below), it seems like during short circuit there is another protection system that can cause the registers to be cleared, hence the need to track the current state in software. > > > + /* > > + * The SC(short circuit) fault would trigger PBS(Portable Batch > > + * System) to disable regulators for protection. This would > > + * cause the SC_DETECT status being cleared so that it's not > > + * able to get the SC fault status. > > + * Check if the regulator is enabled in the driver but > > + * disabled in hardware, this means a SC fault had happened > > + * and SCP handling is completed by PBS. > > + */ > > + if (!in_sc_err) { > > + > > + reg = labibb_reg->base + REG_LABIBB_ENABLE_CTL; > > + > > + ret = regmap_read_poll_timeout(labibb_reg->regmap, > > + reg, val, > > + !(val & LABIBB_CONTROL_ENABLE), > > + POLLING_SCP_DONE_INTERVAL_US, > > + POLLING_SCP_TIMEOUT); > > Why do we need a timeout here? IMHO, This seems to be the time required by the PBS to actually disable the regulator? If the PBS is not able to disable the regulator, then it points to a more serious problem? I'm sorry, that's just my understanding based on the downstream driver :/ - not much input is available from the QC teams about it. > > > + NULL); > > + regulator_unlock(labibb_reg->rdev); > > + } > > + return IRQ_HANDLED; > > This returns IRQ_HANDLED even if we didn't detect an interrupt source... > Especially given the need to check to see if the regulator was turned > off by the hardware it seems like there must be some false positives. Right - I'm not sure what else can I do here. > > > + } else { > > + ret = devm_request_threaded_irq(reg->dev, > > + sc_irq, > > + NULL, labibb_sc_err_handler, > > + IRQF_ONESHOT, > > + "sc-err", reg); > > This looks like we're requesting the interrupt before we register the > regulator which means the interrupt might fire without the regulator > being there. The order of registration should be reversed. Agreed, and will update in the next version. Best, Sumit.