Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1038732ybh; Wed, 11 Mar 2020 16:15:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvVn/ENYKqyfWTR+0f7vuk5cAvVJjR+qPKI84VyZrPKsBToVbPxVL49jsscQG0S9WfiaVnd X-Received: by 2002:a4a:ab46:: with SMTP id j6mr1969448oon.46.1583968511252; Wed, 11 Mar 2020 16:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583968511; cv=none; d=google.com; s=arc-20160816; b=sd30t5zKTpelh49SiAO1WtfJKVs08i49YobpXN5dWNDCcalWkeSJn4ulx+Uz0oyUL4 Iv6VnNw/yXs8viCfmzYAlKR2YG+Int5OdbXrH4o9R4CaD3Gko4fwgrxNMvgJl6wTIeVV fQg1733QnKXqTijA7GOs7MtIaROBht/z9qP87Vwpyq/+wOdaIuRE3xUnFRPK2xEilyXz mtAmMj4FB/nKh0qJViTGTQNvHsL3q6w+lLRF/PG6B/hMaR5H/m6W1RjIjKADzFSgkjEY QCyC9Q1nxL7LbbNhjcI4x4Hyo7/7v/d7cTAoNAlAnvNbK/EyuHUdmDhMFm+ZeT/PPxan O2gg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kG1+YVl0s8o9smr2trKOZ7NbvC55EDPcXtr8oUkRgXE=; b=BdMZrG/tsRrH+IbOUNgEhvVp6mUY/i2wo6Ldpkmdiz4W+zKstEdeL0wZ4uIWQJukGq UdDs7C7TWsYe1y2J+A904dGW1ON5J0/CjEbTdC//a1eZh5ylkzvN7el/vLLAl5/CtHqC 8StJ8uykSCaaR+qlNL1SWMtgGv4xYqNzH5wcHwAGLEk/AplkEGr58rX7FufTlcTOk3tI J6L/vUtogOtDh9swHlVFxSKtZrNsYWPb/H7hiXAtSLK5TbOhN08exDqOLZ2enwWtBM+l HPKAylvEgbKFpXDz4iuscu1fsGd7Jd4nZiBHBi5hXRMnW/55tUwtP0G0PmF9CGdDGy4L ZfWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ClKgrdpC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si1948847otf.46.2020.03.11.16.14.54; Wed, 11 Mar 2020 16:15:11 -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; dkim=pass header.i=@chromium.org header.s=google header.b=ClKgrdpC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731532AbgCKXOY (ORCPT + 99 others); Wed, 11 Mar 2020 19:14:24 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35592 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731493AbgCKXOU (ORCPT ); Wed, 11 Mar 2020 19:14:20 -0400 Received: by mail-pg1-f195.google.com with SMTP id 7so2032667pgr.2 for ; Wed, 11 Mar 2020 16:14:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kG1+YVl0s8o9smr2trKOZ7NbvC55EDPcXtr8oUkRgXE=; b=ClKgrdpCmsvoy2gfXgwaLyaAM1AihCtYKyvZqzuy05EGgTbYcUN7uJ0SPLSwc4/4cw aR5se+RbOXCoyHSA33S+YdUlP0iiAd58cRs0M6QOrypjdzfoVRRp2d0QynUiBGxMZtd1 54mJCAn4YFUnZWaGt34SJYmeqmweS894Ge5Uw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kG1+YVl0s8o9smr2trKOZ7NbvC55EDPcXtr8oUkRgXE=; b=ETfHakJGQg/Pjcc8CXQF2OVkz89ETz6ZBScGC2o9rzomZq4fHI3MP5TSjqrOOF8Wf4 Cz6WKKJOfYcj1nASxAMabQxfB7sPUwS6dab56gJJ46M+3obqTd57uEd/N1igPCoQR3/L cX8nXFWckAKdqWHzPn3Obbv0jw7VPh0FnvXjNiWA5nhTs1Lpf84iKQ1BnwT9WgUDUu5o 5LZyoac1R5yYvCKJXQOse4RgCTvB92dWQkINIJvUmMkVQEtURvIomZLas8NGIEr8LxPz 2Vwa4w4CnjxBVp/qdwDb62mdyJolVSCHlpm1vxkpHogbP/FBR01G2EjBh9qm+HXjasSs J+4Q== X-Gm-Message-State: ANhLgQ2dLsrRacwMFPORCLV1tj9wznbBT960LVhqmSpo+wiDgZ0rLq90 UlvEJpI+GpoI7WRPXELPABDklQ== X-Received: by 2002:a63:58a:: with SMTP id 132mr5025730pgf.216.1583968459378; Wed, 11 Mar 2020 16:14:19 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id g75sm2606334pje.37.2020.03.11.16.14.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 16:14:18 -0700 (PDT) From: Douglas Anderson To: Andy Gross , Bjorn Andersson , Maulik Shah Cc: mka@chromium.org, Rajendra Nayak , evgreen@chromium.org, Lina Iyer , swboyd@chromium.org, Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFT PATCH v2 06/10] drivers: qcom: rpmh-rsc: Comment tcs_is_free() + warn if state mismatch Date: Wed, 11 Mar 2020 16:13:44 -0700 Message-Id: <20200311161104.RFT.v2.6.Icf2213131ea652087f100129359052c83601f8b0@changeid> X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog In-Reply-To: <20200311231348.129254-1-dianders@chromium.org> References: <20200311231348.129254-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tcs_is_free() had two checks in it: does the software think that the TCS is free and does the hardware think that the TCS is free. Let's comment this and also add a warning in the case that software and hardware disagree, at least for ACTIVE_ONLY TCS. Signed-off-by: Douglas Anderson --- Changes in v2: - Comment tcs_is_free() new for v2; replaces old patch 6. drivers/soc/qcom/rpmh-rsc.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 9d2669cbd994..93f5d1fb71ca 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -181,8 +181,27 @@ static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, int tcs_id, */ static bool tcs_is_free(struct rsc_drv *drv, int tcs_id) { - return !test_bit(tcs_id, drv->tcs_in_use) && - read_tcs_reg(drv, RSC_DRV_STATUS, tcs_id); + /* If software thinks it's in use then it's definitely in use */ + if (test_bit(tcs_id, drv->tcs_in_use)) + return false; + + /* If hardware agrees it's free then it's definitely free */ + if (read_tcs_reg(drv, RSC_DRV_STATUS, tcs_id) != 0) + return true; + + /* + * If we're here then software and hardware disagree about whether + * the TCS is free. Software thinks it is free and hardware thinks + * it is not. + * + * Maybe this should be a warning in all cases, but it's almost + * certainly a warning for the ACTIVE_TCS where nobody else should + * be doing anything else behind our backs. For now we'll just + * warn there and then still return that we're in use. + */ + WARN(drv->tcs[tcs_id].type == ACTIVE_TCS, + "Driver thought TCS was free but HW reported busy\n"); + return false; } /** -- 2.25.1.481.gfbce0eb801-goog