Received: by 10.192.165.148 with SMTP id m20csp1276167imm; Fri, 27 Apr 2018 16:26:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqsttsE+n1BO1zHPXeQrbhxeOkVB4O5G8QX0tK213yWE+Ir/rF4uE8StDQ1ff9pjdT6dE0T X-Received: by 10.98.216.199 with SMTP id e190mr3815446pfg.161.1524871600886; Fri, 27 Apr 2018 16:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524871600; cv=none; d=google.com; s=arc-20160816; b=W/hl1yr6uk3E7TkV6nGBV6C3Cj7lHaao2+HlGO7syFO20nD0ye3dIWOXFpMdUx8SVI 9ciCc4MccfPnIpttUq8B0E+KY2FeTbg1I8TLgpMPvXf1YPFU19WQs6TFuCQctlclwx4Y z0f1DZPgIXjWexsPGOhY8p40By0Z72BcD+b2RhnNtVxM0/pJkFz1GBryuzECgEn/9Y2W 5haJ1WfahVgnxEm5EW+jUprdQj/nBZOAew1+E36F4fOVgo2fnKLiK75HY0lWXbUgnvHM p/+w7gHuS0n+byVJJOMeFki7jZeAhqkhzxGPzo48cNW0kBa4UdiXsgGjVBWWaGVSEkdX +nXA== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=WqYxJR4k0OE/TAcLiydf/rToQ/2TQA2s3M9qnp3Pcq0=; b=T1RuabBf22hUHkBdpnrKj3rW69iFMYT/lM9J4KsKAM0pQ+5jKD/mY/3sunKiZjweVq 4U+hUnxV7p1rqlv81r5fiorP3RCqlw+lFTwKtdYCB56sJbr76PasPFMMr+SYqe8REp4X 6za+25avv5zeQHF87zK+s2f40JdLH4maoeWZ+hiQy5Mj1K89IWHfGd7gpKwuTxOM9aw9 z2qqU80QQXKzwe68J4lpuQxQIHI0k1gCWCsCP4st7I8VaiVJcmyC8kt5RMkID2EUi925 I+Ab+wVpFtsRoCsx0iJyA/zAJIq+23wW7WJD9c+kDydhnETliKDob6ONDzSmLMzrAVoF ttVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=Y12N9B00; dkim=fail header.i=@chromium.org header.s=google header.b=D2Zih46Q; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3-v6si2345858pli.324.2018.04.27.16.26.26; Fri, 27 Apr 2018 16:26:40 -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=fail header.i=@google.com header.s=20161025 header.b=Y12N9B00; dkim=fail header.i=@chromium.org header.s=google header.b=D2Zih46Q; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933071AbeD0XYO (ORCPT + 99 others); Fri, 27 Apr 2018 19:24:14 -0400 Received: from mail-vk0-f48.google.com ([209.85.213.48]:35815 "EHLO mail-vk0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932342AbeD0XYM (ORCPT ); Fri, 27 Apr 2018 19:24:12 -0400 Received: by mail-vk0-f48.google.com with SMTP id h134-v6so2072917vke.2 for ; Fri, 27 Apr 2018 16:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=WqYxJR4k0OE/TAcLiydf/rToQ/2TQA2s3M9qnp3Pcq0=; b=Y12N9B008rUJxdi0nqk6nD0/1+In2O+AXC1bDIUBKDrLlIVgwgoYhtOjQodOGCr/Z3 1KcJsq+ZI4fcj+kf7Xn7LISkm5BGHE7hNOkXUIphQwJRLOGT/08XeuJV57P/rFrJCanJ wxr8rbdL7LcrB9NZACw3TYtuNcm++7UBv9n3qpDbZEMCuFs9t/6o/RyrKp0BPu/dprs6 fbwLpAL2eF7xldAAMSEbCnqygzbMzBKNpUA3PhcDnVWakEPrTqBfm1CQtNLVRNasGhR5 KdffDrzax6bQB2CRM6y91D9VjLrQBDUxo4VrzskUvus8xzbfWg+nHPzGIjbrdenWs9re qN8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=WqYxJR4k0OE/TAcLiydf/rToQ/2TQA2s3M9qnp3Pcq0=; b=D2Zih46Qh7Gld/CFLdhAYSCs/RzAVDQX13Im7iXOgVqeRV8gVk+O4F7HpNXxvM4X6u VmejFfeA4xo31JG7QEfHC4AQbPTwgGm83CItyVEaSusvF8SAHjZ5OkCjk8dGgjmiaz6j ajrpB+IK8Sg8PrS2c441LdG0/tW7MqNe9c20Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=WqYxJR4k0OE/TAcLiydf/rToQ/2TQA2s3M9qnp3Pcq0=; b=fjvVnBr071IrB+5nobzVWsaO977jDhs6z782/UISutcwWbq+Qsaa4VpP4rBDZJzocC rqeM8mWHXyiS0CTZI2RP0UTuve6alKPAiK9NP2pFopmHS6kT5RBLJN1Yw2XgHXfRaNM8 jzsGDd+xLCWWr3MS5Sy+KaaQ7UZ9ohjFFgTtvITjbrYYYnhSX1n+G1AbmGmIjRZtiIz6 OhU7ZfvCem/UzDgeY5PcvES7kr8GoDSZUheQqtRYYan99037NjvLTLMzwMCe1W75Ve0s 4YakYjvlBvGZHSvc29Fvzpfc9aL73TX1vEeJ2dYNatWg0PQi3ZWUtn9d390MKwEbs4KD VpNA== X-Gm-Message-State: ALQs6tBjjY+qQmA3Uvm0Hhdl9YHzlsvnG5Y5GMwr903owZCWYX8A/OVP /reqLBUc7sEaOtO4Aa+p14Dg7HJiAFDSOB10OQgDmQ== X-Received: by 2002:a1f:29c9:: with SMTP id p192-v6mr2799961vkp.1.1524871450652; Fri, 27 Apr 2018 16:24:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.137.13 with HTTP; Fri, 27 Apr 2018 16:24:10 -0700 (PDT) In-Reply-To: <20180427215449.GA133494@google.com> References: <20180419221635.17849-1-ilina@codeaurora.org> <20180419221635.17849-6-ilina@codeaurora.org> <20180425214111.GC243180@google.com> <20180427173943.GD6380@codeaurora.org> <20180427184017.GI243180@google.com> <20180427194559.GE6380@codeaurora.org> <20180427200605.GJ243180@google.com> <20180427213201.GA23157@codeaurora.org> <20180427215449.GA133494@google.com> From: Doug Anderson Date: Fri, 27 Apr 2018 16:24:10 -0700 X-Google-Sender-Auth: XQV7HsJrGQGNCXimyF1DhJ-b1g0 Message-ID: Subject: Re: [PATCH v6 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS To: Matthias Kaehlcke Cc: Lina Iyer , Andy Gross , David Brown , linux-arm-msm@vger.kernel.org, "open list:ARM/QUALCOMM SUPPORT" , Rajendra Nayak , Bjorn Andersson , LKML , Stephen Boyd , Evan Green 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, On Fri, Apr 27, 2018 at 2:54 PM, Matthias Kaehlcke wrote: >> > Am I getting something wrong here? >> >> The for_each_set_bit() should increment the 'i' and we would attempt to >> compare the first address in the request with the next command in the >> TCS cache. If they don't match we repeat the process again. If it does, >> then we loop through 'j' to find if the sequence matches. >> >> Did I miss something? > > One of us is clearly in need of more caffeine or ready for the > weekend, it might be me :) Maybe another pair of eyeballs could help > to resolve this deadlock ... > > My single stepping above assumes that tcs->cmd_cache[i] matches > cmd[0].addr, i.e. we either found the start of the sequence we are > looking for or another sequence that starts with the same address. My > claim is that the code returns i in either case, whether the > subsequent addresses match or not. I haven't reviewed this patch in detail, but I attempted to be another pair of eyes here. Something is definitely wrong with the "for (j = 0; j < len; j++)" loop. I believe the code that's written right now is equivalent to this much shorter function: +static int find_match(const struct tcs_group *tcs, const struct tcs_cmd *cmd, + int len) +{ + int i, j; + + /* Check for already cached commands */ + for_each_set_bit(i, tcs->slots, MAX_TCS_SLOTS) { + if (tcs->cmd_cache[i] == cmd[0].addr) + return i; + } + + return -ENODATA; +} Specifically the test "if (tcs->cmd_cache[i] != cmd[0].addr)" does not take "j" into account. Thus if it was false when "j == 0" it will continue to be false for "j == 1", "j == 2", etc. Eventually you'll hit the "else if (j == len - 1)" and return. I believe that's what Matthias has been saying. I personally haven't looked at the rest of the patch to see how things out to be fixed, but I'm quite convinced that the function either has a bug or should be written as the shorter version I've written above. -Doug