Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp60669ybh; Fri, 6 Mar 2020 16:01:38 -0800 (PST) X-Google-Smtp-Source: ADFU+vtjwzZ4J7ClKkoIUnFD261LDDRMcsLLx8kaBVJ5m32PZEGlX0MUUsaFlNoRxqKKEVB54aVY X-Received: by 2002:a9d:4d8f:: with SMTP id u15mr4610316otk.261.1583539298114; Fri, 06 Mar 2020 16:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583539298; cv=none; d=google.com; s=arc-20160816; b=FU2psxuVaFdXPNcMQJpAYR68J/bJtnbZngpX7NNSNe4/c6CUDHVcuRiT2tDMX4LMnH xKjIJyLFzIKzisD1aFRRtV5Zf+GnSdY6vBndgUQH5Obzf0K5zd28/2n0nQ6/BDH+fRiu 7z7Hz3+1jECG71/+cQiuXrDkD6bDxtXatEOtMvsJ32T9FjyuQY5e5IeoEC7Lud5R7DZM SmM/bTmpJ7H+jNjwfgAKkwFTPFgweNCgOToTxrFovHUHbRydurGIuGy8CTeljOYscfYe BNTW0OPwbv5pszc5TkzUYWL4igJUN+kpoBuPRVY6swFIEDywCDkQymDSgL7miTgZYEjt ofFQ== 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=gZyZntHsdjoBeCJtjOQp+OOLTX7DtTYf5YMcuIO3+bY=; b=B9RvJigKz/LaLDwVG0ZuvYznQdEtfhh1c1Jgytg+38Wk4cCVusSsBpmp0zDFGpp0Vk aKGHJ/ltl/KIxeJGI5KzHUIDniAiIgO2YQ97bOJEjRuE2t+jNOJFxwM1HxYcGJCxK4EG cl4VhNGuCzQra1dYkhM0Qts2mAw2SPFPYiNtlz3wfGw9ZskWTD/4eeIgf7U3hf6VQ0WX ysFa8JERgeSI8n34lHCmMkuYc+Jy8uL66Da916bWfdkRDK+rBC8i85/3ZgUusx7InnuA 7YypQMZbASiY/7F5VG7iJTEm/bt4I2Hx2isiM2Uj3clTzeahpkj5qFRYBGnw8yQfSPmP 6eYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R90gTXiG; 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 l4si2248088otj.173.2020.03.06.16.01.26; Fri, 06 Mar 2020 16:01:38 -0800 (PST) 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=R90gTXiG; 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 S1727178AbgCGAAn (ORCPT + 99 others); Fri, 6 Mar 2020 19:00:43 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37468 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727005AbgCGAAa (ORCPT ); Fri, 6 Mar 2020 19:00:30 -0500 Received: by mail-pg1-f193.google.com with SMTP id z12so1804165pgl.4 for ; Fri, 06 Mar 2020 16:00:28 -0800 (PST) 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=gZyZntHsdjoBeCJtjOQp+OOLTX7DtTYf5YMcuIO3+bY=; b=R90gTXiG7ER3y25trfX0EcpADXPxxKJhr+jAG6qxSEzfinMu8uRLlrpWR0KH+iYYI2 Tlv2KDoK0QDo7IHf31XUEB8Bfuvmv/py4PBwG30rT3SY/RXHEszHudEua9dqmLwMlD7S 0I6ZmXEElzg+agnr1ovCXuIkUt1xv6mKUx4H0= 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=gZyZntHsdjoBeCJtjOQp+OOLTX7DtTYf5YMcuIO3+bY=; b=i5TrtUCSiQWnU+TdqI8V7DfN3a3ZxlKpcwYDIRYuSpBtNmJ7+XE2gDwJ6sVYLq5LTh ojH85fCnvrOwfqPFHSU4P8KL5ROA8nYq4A43CHY+/NMQOLdrEjuyqDDIMEgwbbNDDx2w yWpMifpZkkdNjPFZXfmt+QUUyCtfSspYzCKHHTZl9SF28eRxODPj82CWBazs3SU4/lHD XZsbBZNqLxgurIFWGySSn4NVJEp690P7DUfbmqBzAhcLSDHtUQVtGskUt5exWCJ63TTA rHKMJUGMkTpg1RqrrsPMFLF3Wx3mUgWopNwMiFytshPhIXXAEk3DmWgJU0vJ982UuD6y UOnQ== X-Gm-Message-State: ANhLgQ30cYNwF4ZpLGVEd3CE6o/lxmpm4jgq34xViBs00vo/JUGrxI7D qLChRuWIlnaBYyllLVS7YLOAE1ds4qw= X-Received: by 2002:a63:f010:: with SMTP id k16mr5502683pgh.328.1583539227860; Fri, 06 Mar 2020 16:00:27 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id 9sm32302246pge.65.2020.03.06.16.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 16:00:27 -0800 (PST) From: Douglas Anderson To: Andy Gross , Bjorn Andersson , Maulik Shah Cc: Rajendra Nayak , mka@chromium.org, evgreen@chromium.org, swboyd@chromium.org, Lina Iyer , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFT PATCH 6/9] drivers: qcom: rpmh-rsc: Only use "tcs_in_use" for ACTIVE_ONLY Date: Fri, 6 Mar 2020 15:59:48 -0800 Message-Id: <20200306155707.RFT.6.Icf2213131ea652087f100129359052c83601f8b0@changeid> X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog In-Reply-To: <20200306235951.214678-1-dianders@chromium.org> References: <20200306235951.214678-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 From trawling through the code (see the "A lot of comments" change) I found that "tcs_in_use" was only kept up-to-date for ACTIVE_ONLY TCSs. ...yet tcs_is_free() was checking the variable called from tcs_invalidate() and tcs_invalidate() is only used for non-ACTIVE_ONLY TCSs. Let's change tcs_invalidate() to just check the "RSC_DRV_STATUS" register, which was presumably the important part. It also feels like for ACTIVE_ONLY TCSs that it probably wasn't important to check the "RSC_DRV_STATUS". We'll keep doing it just in case but we'll add a warning if it ever actually mattered. Signed-off-by: Douglas Anderson --- drivers/soc/qcom/rpmh-rsc.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 190226151029..c63441182358 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -164,7 +164,7 @@ static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, int tcs_id, } /** - * tcs_is_free() - Return if a TCS is totally free. + * tcs_is_free() - Return if an ACTIVE_ONLY TCS is totally free. * @drv: The RSC controller. * @tcs_id: The global ID of this TCS. * @@ -177,8 +177,23 @@ 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 (test_bit(tcs_id, drv->tcs_in_use)) + return false; + + if (read_tcs_reg(drv, RSC_DRV_STATUS, tcs_id) != 0) + return true; + + /* + * If this warning never ever hits then we can change this function + * to just look at "tcs_in_use" and skip the read of the + * RSC_DRV_STATUS register. + * + * If this warning _does_ hit, we should figure out if this is just + * the way the hardware works or if there is some bug being pointed + * out. + */ + WARN(1, "Driver thought TCS was free but HW reported busy\n"); + return false; } /** @@ -204,7 +219,7 @@ static int tcs_invalidate(struct rsc_drv *drv, int type) } for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { - if (!tcs_is_free(drv, m)) { + if (read_tcs_reg(drv, RSC_DRV_STATUS, m) == 0) { spin_unlock(&tcs->lock); return -EAGAIN; } -- 2.25.1.481.gfbce0eb801-goog