Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6155545ybf; Thu, 5 Mar 2020 14:22:06 -0800 (PST) X-Google-Smtp-Source: ADFU+vs+FXEvudDvnled/+s6eQzRCO2x2o9cNkGC9+rqtxRCY7/zVcES8Wtyhwj0wuzOwc7Fg8mO X-Received: by 2002:a9d:6d96:: with SMTP id x22mr92577otp.264.1583446926475; Thu, 05 Mar 2020 14:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583446926; cv=none; d=google.com; s=arc-20160816; b=IVXnpP6uPdHLZd06nZ5UTK40kAeB7sffiriZcsoD0IcwjBRQA7ZluFV7KkoRsE9N7D akY9J37qzQzlAdrtFsceBruGSflLyC3+hIEKgDHCiDvdLWxF4ni4++ns1ycmJdEMF9Zq gJFqsCAJoZMfugI7IjIVJ/25c0Al7Uh6k904PsBXpe8T6fEpnUetMsLLdebaEPw+z0zD KBgVDrrPrHSBBCmcylQfkzziC7aFNGD6sp/HTTkZ7/7ICxMUun3jLZHPtOI3YVVPJKSM Nwuz5fPruFMLedjkc95fy3s2EZ/mG3j0BJnZTgqY81aByjyDYPyl/KCJEzKWNRaJT5Rc yOvw== 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=h2AxTBoBmJUCg/vc71mp7BK/aApbrb7OsDakNbxg7J0=; b=lvb3gnM8nJqdwQMDr7Z8X5RPt6/T+Z4S6y86ES+IRSPc9DuPQRrg5ro4RTq6huPYTL 7eR57CE+MDmVFA+QhdOxDvDlBpvlmMTcuRsK8TClwlz1+fPOVOdhQtVLu62PxXfOVdPJ dYSMflUGsJR+gwfRZznJIcoUqEF1Kz8XddZ+p36gvOfPBz/ZyAWgwjcjmlsetgkwlq3O 2b9K7v8+r5sH6juxjFDwb59EbMNZexpqzVO5fE5cuiGEIa64b04DZ6vkw5OpbnOBmObv E1sQAQ1c6rJdRixBB1kT4abgPvMzmk5Kci/s3XtT/g5RhP9GyjRlBsknj3O08rQjBi0v I+Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TbLhWGSZ; 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 c83si195526oig.116.2020.03.05.14.21.54; Thu, 05 Mar 2020 14:22:06 -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=TbLhWGSZ; 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 S1726251AbgCEWUT (ORCPT + 99 others); Thu, 5 Mar 2020 17:20:19 -0500 Received: from mail-vk1-f195.google.com ([209.85.221.195]:39866 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbgCEWUT (ORCPT ); Thu, 5 Mar 2020 17:20:19 -0500 Received: by mail-vk1-f195.google.com with SMTP id t129so69178vkg.6 for ; Thu, 05 Mar 2020 14:20:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h2AxTBoBmJUCg/vc71mp7BK/aApbrb7OsDakNbxg7J0=; b=TbLhWGSZmSAIAobknaUu7mIX+dWWL4Ms/xJLOdVvP8WkDDOt8BXNWLxlsDoFJQwNcX AP+hKWljaB6OUMDEgbTpZOauzuBKrpGPDLTemFYL162rQmh0bRh3cTIYS1y9ymU5MC/c 3zfG1gK2xl0FfLEHW5RF7D4NU+JtfZIfNppNM= 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=h2AxTBoBmJUCg/vc71mp7BK/aApbrb7OsDakNbxg7J0=; b=h7PFOT3D8F1HRsaLPtbO195GyhoakWId4NG2iSCHsSRhiSAyzzmNfUYcsKvQq+fNq5 9AKyJXn/BNp4FzQZE/08LJrDSLURJ185pB0JoPDasn+z1pspryLqa7g6MI6Bt+PxBS8k CX4Iyu61WMItpAGheKkaa0WkGcTDqW6T3LuLtEQFJrF7DGpF+r7JGkjMt0pjsGfIYf4e Ghu5Akqe/w5zDXhz+aaZk55R1E/Leyx2L8RjTY3dRl9eqH5IxXs8PmLTIwZ/HoWqfV8X rsqowEqxBqOOw/l0wiqV9WGU/J39sbYHtMe5EPYt+thwSJRUDlNnAlE3irYUHWlRdPhX x3aw== X-Gm-Message-State: ANhLgQ2i/MYWrNwcEimwGb26tbMuS0Ye8XKMkw/KWAAV4fYi2yNqDGni kj0Zz5a+XhiozZxuEhunIv3BmG15HvY= X-Received: by 2002:a1f:284:: with SMTP id 126mr932404vkc.16.1583446816307; Thu, 05 Mar 2020 14:20:16 -0800 (PST) Received: from mail-ua1-f41.google.com (mail-ua1-f41.google.com. [209.85.222.41]) by smtp.gmail.com with ESMTPSA id x63sm4298258vkc.33.2020.03.05.14.20.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Mar 2020 14:20:15 -0800 (PST) Received: by mail-ua1-f41.google.com with SMTP id t20so2708891uao.7 for ; Thu, 05 Mar 2020 14:20:14 -0800 (PST) X-Received: by 2002:a9f:300a:: with SMTP id h10mr11953uab.91.1583446814390; Thu, 05 Mar 2020 14:20:14 -0800 (PST) MIME-Version: 1.0 References: <1583238415-18686-1-git-send-email-mkshah@codeaurora.org> <1583238415-18686-4-git-send-email-mkshah@codeaurora.org> <92bf14b7-b7ae-3060-312e-74f57c1f9a63@codeaurora.org> In-Reply-To: <92bf14b7-b7ae-3060-312e-74f57c1f9a63@codeaurora.org> From: Doug Anderson Date: Thu, 5 Mar 2020 14:20:03 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10 3/3] soc: qcom: rpmh: Invoke rpmh_flush() for dirty caches To: Maulik Shah Cc: Stephen Boyd , Matthias Kaehlcke , Evan Green , Bjorn Andersson , LKML , linux-arm-msm , Andy Gross , Rajendra Nayak , Lina Iyer , lsrao@codeaurora.org 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 Thu, Mar 5, 2020 at 3:30 AM Maulik Shah wrote: > > >> + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); > >> + return -EINVAL; > > nit: why not add "int ret = 0" to the top of the function, then here: > > > > if (rpmh_flush(ctrl)) > > ret = -EINVAL; > > > > ...then at the end "return ret". It avoids the 2nd copy of the unlock? > Done. > > > > Also: Why throw away the return value of rpmh_flush and replace it > > with -EINVAL? Trying to avoid -EBUSY? ...oh, should you handle > > -EBUSY? AKA: > > > > if (!psci_has_osi_support()) { > > do { > > ret = rpmh_flush(ctrl); > > } while (ret == -EBUSY); > > } > > Done, the return value from rpmh_flush() can be -EAGAIN, not -EBUSY. > > i will update the comment accordingly and will include below change as well in next series. > > https://patchwork.kernel.org/patch/11364067/ > > this should address for caller to not handle -EAGAIN. A few issues, I guess. 1. I _think_ it's important that you enable interrupts between retries. If you're on the same CPU that the interrupt is routed to and you were waiting for 'tcs_in_use' to be cleared you'll be in trouble otherwise. ...I think we need to audit all of the places that are looping based on -EAGAIN and confirm that interrupts are enabled between retries. Before your patch series the only looping I see was in rpmh_invalidate() and the lock wasn't held. After your series it's also in rpmh_flush() which is called under spin_lock_irqsave() which will be a problem. 2. The RPMH code uses both -EBUSY and -EAGAIN so I looked carefully at this again. You're right that -EBUSY seems to be exclusively returned by things only called by rpmh_rsc_send_data() and that function handles the retries. ...but looking at this made me find a broken corner case with the "zero active tcs" case (assuming you care about this case as per your other thread). Specifically if you have "zero active tcs" then get_tcs_for_msg() can call rpmh_rsc_invalidate() which can return -EAGAIN. That will return the -EAGAIN out of tcs_write() into rpmh_rsc_send_data(). rpmh_rsc_send_data() only handles -EBUSY, not -EAGAIN. -Doug