Received: by 10.223.185.116 with SMTP id b49csp1262031wrg; Fri, 16 Feb 2018 15:52:36 -0800 (PST) X-Google-Smtp-Source: AH8x227marwOWFHXcY+035g5JK1m+a6UQ1TzXV4EgCTzixeM6prv/5I7okLJ+045BC2+akXlf5rx X-Received: by 10.101.98.201 with SMTP id m9mr6366763pgv.100.1518825156445; Fri, 16 Feb 2018 15:52:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518825156; cv=none; d=google.com; s=arc-20160816; b=rxTpOfJPriMKTfHFS3KGPdT/hNEI4VnK5NU909p6vKqihznosKyAzmgZXYKolk8zE5 RFpVuC/2lbn52mw94NLwyIBFLkdJuCsF5IF1FqoQYaqVs3dLmKvqLJ40+6yBZrjhl4pU lXeYstOH5OQVlPq9AwOs9lsC9yDxOXntuhDmAzUL0Kx0n0Y+TNTw4MaHgYTZqeS//zJE S/W78SuDkrqEkrIwUmQsfLA94zWTUZZOd3lHxvUKOyQVO68vYV7uvhjvgXnRaDXBglLb ZDYgEasHXPUvVbvcD751GUaxFx/DYJ/k+xslNrk7nGJXdnMoiTTutDIfjkCs/gWj233N SRqQ== 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 :arc-authentication-results; bh=Pssl/KgEWmPq0V/eTAfSk+TUuNmlpi+SGQosyTy5KvM=; b=fB7UjjQpSeHo4137UIR38l1W7hQQh48sPxlX15U/N60uCsdeZRbobGuBxOqixmurKA N/Coi3Ly3Hy6qBQjEbZMYmxjJZB3bjbLcjatNYaaaRFbonueEhouC83hKbqcvYy3a6ob rGxla03MNROGUjz1LzHIIjKiiY6mjiO3FJjqv2l5xMH0F7McmwSPqbjZEJMtI+DBbVzE 1PvWPaWwXT0rkA+dbKmltCfdkTo3s32A63JLjd/wFDi4hz5/8PGN9o6V8iA76zrZf6PA bbRrSWvFs5I94gamV870M+jsJpemYlFSx7/ABT+eO3SjEr6aQzEzOO/DG0yp4rQWVGWU qQzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WTTO5fXl; 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 m73si7390349pfj.131.2018.02.16.15.52.21; Fri, 16 Feb 2018 15:52:36 -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=WTTO5fXl; 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 S1751076AbeBPXvP (ORCPT + 99 others); Fri, 16 Feb 2018 18:51:15 -0500 Received: from mail-oi0-f49.google.com ([209.85.218.49]:39841 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750934AbeBPXvN (ORCPT ); Fri, 16 Feb 2018 18:51:13 -0500 Received: by mail-oi0-f49.google.com with SMTP id r144so3523352oie.6 for ; Fri, 16 Feb 2018 15:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Pssl/KgEWmPq0V/eTAfSk+TUuNmlpi+SGQosyTy5KvM=; b=WTTO5fXl3xW8DV8UR+63+77KnWl3uMsqjF1O8n2ymJrHX0AhlJ2EgShzmnTWJGZ9Fk wh6LMtDQI4Z/6E4EdSDG7GxrQUG8Ui5xscX2ROqJcdo7JRs/kP8nzjQjbXCPwURJL0Xl Nh2JeB2feQg8q2hmprqGxVfsWnyzPZyDj+CnQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Pssl/KgEWmPq0V/eTAfSk+TUuNmlpi+SGQosyTy5KvM=; b=cbWOv0Rstsu1+G2FLeHJc3t67RI8RC6VT5dYraosUBaQHdTWLKjCS2DxyCY4x6kZhp MmFNJYMNMnT4WJdI1LhObP5dfo2xQw+4oEaHrrfWLz7KO2y1YWLixOH+wV2z5tUB6XW6 hUTwym/33hiDopzI4FRB+UQVhb2P6iPgLFA8hI9PMPsiUjjc4uPBlYWS/YgF7osatTva I9qKbwIyRQoNC9YkmVIS/o9NQOWOPqe9mZIT210OJatiiDpVUf/xkphFvMbgrjuxFYMK QsWNf1E3f9NHQRXWXJEpQ4OY5ffzgTWszrnKmAH8I7zdq5rptYx5ZzewPP6T16Q3BY0E uDFg== X-Gm-Message-State: APf1xPAnIe4QbUECdaDlp3pF6fXaOcRgjenQVw4NC9syJlYiiKQfklDK TfrtxRPWR14PeptadzrGBakeTkyO8pQ= X-Received: by 10.202.216.69 with SMTP id p66mr5881659oig.100.1518825072400; Fri, 16 Feb 2018 15:51:12 -0800 (PST) Received: from mail-ot0-f180.google.com (mail-ot0-f180.google.com. [74.125.82.180]) by smtp.gmail.com with ESMTPSA id q45sm1639995ota.59.2018.02.16.15.51.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 15:51:11 -0800 (PST) Received: by mail-ot0-f180.google.com with SMTP id w10so4171658ote.13 for ; Fri, 16 Feb 2018 15:51:10 -0800 (PST) X-Received: by 10.157.54.161 with SMTP id h30mr6054542otc.173.1518825070140; Fri, 16 Feb 2018 15:51:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.14.25 with HTTP; Fri, 16 Feb 2018 15:50:29 -0800 (PST) In-Reply-To: <20180215173507.10989-6-ilina@codeaurora.org> References: <20180215173507.10989-1-ilina@codeaurora.org> <20180215173507.10989-6-ilina@codeaurora.org> From: Evan Green Date: Fri, 16 Feb 2018 15:50:29 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS To: Lina Iyer Cc: Andy Gross , David Brown , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Rajendra Nayak , Bjorn Andersson , linux-kernel@vger.kernel.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 Hello Lina, On Thu, Feb 15, 2018 at 9:35 AM, Lina Iyer wrote: > Sleep and wake requests are sent when the application processor > subsystem of the SoC is entering deep sleep states like in suspend. > These requests help lower the system power requirements when the > resources are not in use. > > Sleep and wake requests are written to the TCS slots but are not > triggered at the time of writing. The TCS are triggered by the firmware > after the last of the CPUs has executed its WFI. Since these requests > may come in different batches of requests, it is job of this controller > driver to find arrange the requests into the available TCSes. > > Signed-off-by: Lina Iyer > --- > drivers/soc/qcom/rpmh-internal.h | 7 +++ > drivers/soc/qcom/rpmh-rsc.c | 126 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 133 insertions(+) > [...] > +static int find_slots(struct tcs_group *tcs, struct tcs_request *msg, > + int *m, int *n) > +{ > + int slot, offset; > + int i = 0; > + > + /* Find if we already have the msg in our TCS */ > + slot = find_match(tcs, msg->payload, msg->num_payload); > + if (slot >= 0) > + goto copy_data; > + > + /* Do over, until we can fit the full payload in a TCS */ > + do { > + slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS, > + i, msg->num_payload, 0); > + if (slot == MAX_TCS_SLOTS) > + break; > + i += tcs->ncpt; > + } while (slot + msg->num_payload - 1 >= i); > + > + if (slot == MAX_TCS_SLOTS) > + return -ENOMEM; > + > +copy_data: > + bitmap_set(tcs->slots, slot, msg->num_payload); > + /* Copy the addresses of the resources over to the slots */ > + for (i = 0; tcs->cmd_addr && i < msg->num_payload; i++) I don't think tcs->cmd_addr can be null, can it? Above, find_match() is already reaching through cmd_addr with enthusiasm. If kept, it could at least be moved outside of the loop. Evan