Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8985333ybi; Tue, 23 Jul 2019 19:29:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyulZQsY/s0TP3ZIapNgjEYW6itfDdQXzsUk1E9zdlzMmPO/x3k+4PJHtTtIsEaeQognTNg X-Received: by 2002:a17:902:aa83:: with SMTP id d3mr81166069plr.74.1563935383560; Tue, 23 Jul 2019 19:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563935383; cv=none; d=google.com; s=arc-20160816; b=DRu3WpYjnXiII9WGe3mlWHB+huM/oum/eWxEaKUBfASG/medPpnsXQgIwcUQtl1F2c PL5NqFmrtxnSgQdx1WKqI/frNsK+b0MjBtLxXXnZYSJiG+4tnixYyKQJdLHSYSTQlv3d xmPYYycvYduDMQ3iEqko66J8tjzIqGyVNUO4BVuoJ8r4sTCV16aoXlMu2pIFdLxLpbwz hPu46kMCGwz3u/OCAFa+2Phxjia9pOKG3LnIicxXcdIIN3JQaalZKk4nlQR1H97/qyAN yF901CCUM2tqRvOsJ+dhyWuZ/9uG2yf7Ai5i62mSs5g5dm3vaYERjToEOw1IQYIGYKbP VRuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:from:cc:to:subject :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=j+oQw2jdtWVrhOuLyebLNsd7ea1r8/8WD8EWU9cDAVo=; b=oJtoKvAEbHLDUTfsDpaPgGu239Pn/Z8s8qS7zM0Rso3ysnydT336mVJkULn13pguIw orDtrR18u92Y40w5SHIcxADjV6AMnrAkact8NQXN9NsreHnsKL+bjEkjEt+Pu2ACLWrQ 5/Ba4NiSSnTlM6SYytvM1zoFcRI78AhpoIzyj4ytb1vNzrG0MalM6O37lagAf3luOtHW oqw7gFEzkZ5ZJThqzsXrY37VevY+eGy9ZRmt8i4AP3BYkoPqTqtUepak7Zb4ICseLTb4 5tTt07xEdiwMe0O0ljFZqrM32YNcRM0KYkLd57tR4jpqxEXU/DM78UjfW3liZn8N8XD9 6rmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="NSMsF/Zh"; 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 61si12758994ple.275.2019.07.23.19.29.28; Tue, 23 Jul 2019 19:29:43 -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="NSMsF/Zh"; 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 S1731128AbfGWUTB (ORCPT + 99 others); Tue, 23 Jul 2019 16:19:01 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39004 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728389AbfGWUTA (ORCPT ); Tue, 23 Jul 2019 16:19:00 -0400 Received: by mail-pf1-f194.google.com with SMTP id f17so15696188pfn.6 for ; Tue, 23 Jul 2019 13:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:mime-version:content-transfer-encoding:in-reply-to :references:subject:to:cc:from:user-agent:date; bh=j+oQw2jdtWVrhOuLyebLNsd7ea1r8/8WD8EWU9cDAVo=; b=NSMsF/ZhLMfKzsKJ2MspdGWNCHdp7/PJbl+7N68yde2T9b7DjaJfjPc857JDqwI1qG ztbRuSuLw0ZiEngAIk2lr7lgbNw92V5Ke9JI45W9JpPLiUqz9GAyeFXMO/N0XaYJLgVe Usz6WsyTsIwMMnJcc6EmsOhMRqeNtKrfT2vWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:in-reply-to:references:subject:to:cc:from :user-agent:date; bh=j+oQw2jdtWVrhOuLyebLNsd7ea1r8/8WD8EWU9cDAVo=; b=O3GivmWSmQYZHUT7DB5vo8Z7L/NoDHnX4mHX//+voZVWO7J7cRrOxgkvzDYsjSf291 3Nh3c5pYwc63+HSCZ+Pza7c5oCFjYv89iKJo0UrmNYMDdTiVpqMRWh5aaeEKxlXYp0RE 7HCyOD8+4xjpctHiOuNirP+8/JUMTZDHqfWxQ7FckyPBwymOEy/y8K+cf9u0NygY5ySq wxyX4UVY8iBHyRm4iHCnNXGraKx0BGXfwH7bPycTBTIUDwA18FhrkInzDPiBksyj97AR 7lHs4EynWkltmoGN8Cs4rKHJ5GRNhcr3XL4VB5seaR9M9ELC+Rb98/C8Jq2guMl34nXc wBHQ== X-Gm-Message-State: APjAAAUetRSwZvRLQVQYjDhmTCnRzS9v/NMBiplG1AzDqGUwAQKXqsJz 1sC1sW8QnW9p7tEX0rvIRdoNXQ== X-Received: by 2002:a63:c748:: with SMTP id v8mr46673106pgg.418.1563913140016; Tue, 23 Jul 2019 13:19:00 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id k6sm53132496pfi.12.2019.07.23.13.18.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 23 Jul 2019 13:18:59 -0700 (PDT) Message-ID: <5d376bb3.1c69fb81.2bb4e.7771@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20190723192159.GA18620@codeaurora.org> References: <20190722215340.3071-1-ilina@codeaurora.org> <5d375054.1c69fb81.7ce3f.3591@mx.google.com> <20190723192159.GA18620@codeaurora.org> Subject: Re: [PATCH V2 1/4] drivers: qcom: rpmh-rsc: simplify TCS locking To: Lina Iyer Cc: agross@kernel.org, bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dianders@chromium.org, mkshah@codeaurora.org, "Raju P.L.S.S.S.N" From: Stephen Boyd User-Agent: alot/0.8.1 Date: Tue, 23 Jul 2019 13:18:58 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Lina Iyer (2019-07-23 12:21:59) > On Tue, Jul 23 2019 at 12:22 -0600, Stephen Boyd wrote: > >Quoting Lina Iyer (2019-07-22 14:53:37) > >> From: "Raju P.L.S.S.S.N" > >> > >> The tcs->lock was introduced to serialize access with in TCS group. Bu= t, > >> drv->lock is still needed to synchronize core aspects of the > >> communication. This puts the drv->lock in the critical and high latency > >> path of sending a request. drv->lock provides the all necessary > >> synchronization. So remove locking around TCS group and simply use the > >> drv->lock instead. > > > >This doesn't talk about removing the irq saving and restoring though. > You mean for drv->lock? It was not an _irqsave/_irqrestore anyways and > we were only removing the tcs->lock. Yes drv->lock wasn't an irqsave/restore variant because it was a spinlock inside of an obviously already irqsaved region of code because the tcs->lock was outside the drv->lock and that was saving the irq flags. >=20 > >Can you keep irq saving and restoring in this patch and then remove that > >in the next patch with reasoning? It probably isn't safe if the lock is > >taken in interrupt context anyway. > > > Yes, the drv->lock should have been irqsave/irqrestore, but it hasn't > been changed by this patch. It needs to be changed to maintain the irqsaving/restoring of the code. > >> @@ -349,41 +349,35 @@ static int tcs_write(struct rsc_drv *drv, const = struct tcs_request *msg) > >> { > >> struct tcs_group *tcs; > >> int tcs_id; > >> - unsigned long flags; > >> int ret; > >> > >> tcs =3D get_tcs_for_msg(drv, msg); > >> if (IS_ERR(tcs)) > >> return PTR_ERR(tcs); > >> > >> - spin_lock_irqsave(&tcs->lock, flags); > >> spin_lock(&drv->lock); > >> /* > >> * The h/w does not like if we send a request to the same addr= ess, > >> * when one is already in-flight or being processed. > >> */ > >> ret =3D check_for_req_inflight(drv, tcs, msg); > >> - if (ret) { > >> - spin_unlock(&drv->lock); > >> + if (ret) > >> goto done_write; > >> - } > >> > >> tcs_id =3D find_free_tcs(tcs); > >> if (tcs_id < 0) { > >> ret =3D tcs_id; > >> - spin_unlock(&drv->lock); > >> goto done_write; > >> } > >> > >> tcs->req[tcs_id - tcs->offset] =3D msg; > >> set_bit(tcs_id, drv->tcs_in_use); > >> - spin_unlock(&drv->lock); > >> > >> __tcs_buffer_write(drv, tcs_id, 0, msg); > >> __tcs_trigger(drv, tcs_id); > >> > >> done_write: > >> - spin_unlock_irqrestore(&tcs->lock, flags); > >> + spin_unlock(&drv->lock); > >> return ret; > >> } > >> > >> @@ -481,19 +475,18 @@ static int tcs_ctrl_write(struct rsc_drv *drv, c= onst struct tcs_request *msg) > >> { > >> struct tcs_group *tcs; > >> int tcs_id =3D 0, cmd_id =3D 0; > >> - unsigned long flags; > >> int ret; > >> > >> tcs =3D get_tcs_for_msg(drv, msg); > >> if (IS_ERR(tcs)) > >> return PTR_ERR(tcs); > >> > >> - spin_lock_irqsave(&tcs->lock, flags); > >> + spin_lock(&drv->lock); > >> /* find the TCS id and the command in the TCS to write to */ > >> ret =3D find_slots(tcs, msg, &tcs_id, &cmd_id); > >> if (!ret) > >> __tcs_buffer_write(drv, tcs_id, cmd_id, msg); > >> - spin_unlock_irqrestore(&tcs->lock, flags); > >> + spin_unlock(&drv->lock); > >> > > > >These ones, just leave them doing the irq save restore for now? > > > drv->lock ?? >=20 Yes, it should have irq save/restore still.