Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp835455imm; Tue, 15 May 2018 09:50:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrztPmqJimwJZ1jlvb0IL1AD1aRlt6aAVExiUdCGz1avGl4rgElWvVynW6kWFrGReWDB5vy X-Received: by 2002:a17:902:4301:: with SMTP id i1-v6mr15263222pld.280.1526403057387; Tue, 15 May 2018 09:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526403057; cv=none; d=google.com; s=arc-20160816; b=r4FyWe/t/Rtnz1dQssPH7f/pKuASKpj9Dlw4A1hQoLLGiRKQe/zb/CGF+CzUPSNIQT I/+ilI85fgGL9dLiS4PGGPr2+0IdCk3+2ibpjuvhdr1uhoS5AJ+Va9RBgSE/4ss5liwz QKPlsnFEKohHCfLamutBWyJAlfzlPRA+AuVeSt6g6uo5vp/pFqGgjb1hgz2EIyrb2075 Iuz57y2hHmAP9nrO7SM0FcMUJM2yuk+Bqod1t+hVXa2Ix/e5jyXM/zK09e3AKLPVobtb xTFtHhqCZ8VmiwwxNu9YQZxDVabb8pyXBcwJ3osPI8sTZKYZz18quOLmOHnQQscHIOSU 4AjQ== 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=aLveUwZm2rQgSuGfSK7+a10s3KMSPvMeJ03+0yAFUTE=; b=kuB1iwwUrwLyuqDGYhAi7c2Crw2hyf2XgkWySJVj3g5wkmLZ9tkygjecP18hfhtZyT +SfjCcuPc8O9v1E3awjE26T5Xj+yTmsfH4cMYbzWdCK3uLNNoavio632IaKoE18ZNZFR G76j22MQ3Vg7EijtECWY6mqFLKUNxHRgyq2H4NTPrZ8xwoNysheIAhioetKIl8t6+LPy aHv0pwwjxmvihiox0fzwi2Vdt0nyAXkD2RltfhtAkrYmKfghKV0Q5f+6ze7tm0dP7Hb+ mTfEpxIeWjIO/q01h+R5Cbl4jGizazekDkkWrDFBXATyQjCuTo8SgJ31eA06cQKaJnUM lR9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=K7Nw2Pxa; dkim=fail header.i=@chromium.org header.s=google header.b=MkSeufge; 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 q2-v6si356356pgr.149.2018.05.15.09.50.43; Tue, 15 May 2018 09:50:57 -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=K7Nw2Pxa; dkim=fail header.i=@chromium.org header.s=google header.b=MkSeufge; 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 S1754262AbeEOQu2 (ORCPT + 99 others); Tue, 15 May 2018 12:50:28 -0400 Received: from mail-vk0-f66.google.com ([209.85.213.66]:38674 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754216AbeEOQuZ (ORCPT ); Tue, 15 May 2018 12:50:25 -0400 Received: by mail-vk0-f66.google.com with SMTP id u8-v6so558661vku.5 for ; Tue, 15 May 2018 09:50:25 -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=aLveUwZm2rQgSuGfSK7+a10s3KMSPvMeJ03+0yAFUTE=; b=K7Nw2PxaxxTCo/dzUW2DPUoQ7jzn73BxyfRcyX22+6TQe3/mXwbRaryMaXmaOHYHFL p3m4q242FlzpGmFn9IxU9IMBPfW4IBcfYGcRrxRANs9PQ+h1CeM2BZpxdWNL9XPJM3i/ qDxK4MLpUg6/rjLx+hDeqn3D+Oh5KhAAChPfnurDQvTVptLXrkLjyeGZQbnlc/otcaqz r64kZtIS5SSqDDYbVq7TFk1KTfoiUvg/c/eIDo/mmxK0Xrbu3lE2rbH75sesdDhmQBLd i198jVXIJlyyGeqSCmrFKzRQDJ2jLFyIfttk/tVTgy1O16/lOREZfWrmWtixeUHM+/rC u9uw== 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=aLveUwZm2rQgSuGfSK7+a10s3KMSPvMeJ03+0yAFUTE=; b=MkSeufge+WxrjeYnoFSCyk1iEJUyT8ocRulmJx3bo4QFWpX7YGSCV9xsyvGuzhP8ye 3zVVBrM4KID8KdYDt2HWNF194aKt3dhaOBxMXl+G0uM7alXJHakPLGKwD1BxWY8RtjHi PX1nfCY6GGvF3b1ilet+o//Kf32cRP+K+rD9c= 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=aLveUwZm2rQgSuGfSK7+a10s3KMSPvMeJ03+0yAFUTE=; b=mZCbIT5zyaN6e/dQ8DwLVj3SuPv8WHxRyG2TJP4ym2jVh1FOZhhL3S6dMkEGTHqi7h 6pLER9buzr7Vj0xdqJzOYfSBB1rfiu0doNIyRJ14YuNHH25DtyLbqKeDXE6tJJf7KTdc hrDYafiYBT8PQzYp6VkQTlRXjvTEDSozOVy+L07Ycql4ygMv2UTNkdvsKloOq4HsP74f kd/ygFWUpmp76Ac5HJSA4Cb4dTZ2Tq4F6Db94F7ltYDJc5q+tn/8Kv5oHCptSKlAkSA0 TcPjpy7K0tRQGkAnrUe6pexxiu4e7bdsbXFa4uBD8r8aY4ty+BR3K/Qeg6I6/C/rIcK4 U6ng== X-Gm-Message-State: ALKqPwcJAcQcJamZYC0gxFxPRO24/XhXK4eZqk5waRiYxi3L9elcXIWD l1CxNbtxb9LB83/rU5SMVd5Lv0BwYyU0XAK1XYPXMw== X-Received: by 2002:a1f:fc4a:: with SMTP id a71-v6mr15340206vki.141.1526403023137; Tue, 15 May 2018 09:50:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.48.82 with HTTP; Tue, 15 May 2018 09:50:22 -0700 (PDT) In-Reply-To: <20180515162326.GA28489@codeaurora.org> References: <20180509170159.29682-1-ilina@codeaurora.org> <20180509170159.29682-10-ilina@codeaurora.org> <20180514195929.GA22950@codeaurora.org> <20180515162326.GA28489@codeaurora.org> From: Doug Anderson Date: Tue, 15 May 2018 09:50:22 -0700 X-Google-Sender-Auth: MKTL5tYTd_a6BTszKdiful3UYt0 Message-ID: Subject: Re: [PATCH v8 09/10] drivers: qcom: rpmh: add support for batch RPMH request To: Lina Iyer Cc: Andy Gross , David Brown , linux-arm-msm@vger.kernel.org, "open list:ARM/QUALCOMM SUPPORT" , Rajendra Nayak , Bjorn Andersson , LKML , Stephen Boyd , Evan Green , Matthias Kaehlcke , rplsssn@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 Tue, May 15, 2018 at 9:23 AM, Lina Iyer wrote: > On Tue, May 15 2018 at 09:52 -0600, Doug Anderson wrote: >> >> Hi, >> >> On Mon, May 14, 2018 at 12:59 PM, Lina Iyer wrote: >> >>>>> /** >>>>> @@ -77,12 +82,14 @@ struct rpmh_request { >>>>> * @cache: the list of cached requests >>>>> * @lock: synchronize access to the controller data >>>>> * @dirty: was the cache updated since flush >>>>> + * @batch_cache: Cache sleep and wake requests sent as batch >>>>> */ >>>>> struct rpmh_ctrlr { >>>>> struct rsc_drv *drv; >>>>> struct list_head cache; >>>>> spinlock_t lock; >>>>> bool dirty; >>>>> + const struct rpmh_request *batch_cache[RPMH_MAX_BATCH_CACHE]; >>>> >>>> >>>> >>>> I'm pretty confused about why the "batch_cache" is separate from the >>>> normal cache. As far as I can tell the purpose of the two is the same >>>> but you have two totally separate code paths and data structures. >>>> >>> Due to a hardware limitation, requests made by bus drivers must be set >>> up in the sleep and wake TCS first before setting up the requests from >>> other drivers. Bus drivers use batch mode for any and all RPMH >>> communication. Hence their request are the only ones in the batch_cache. >> >> >> This is totally not obvious and not commented. Why not rename to >> "priority" instead of "batch"? >> >> If the only requirement is that these come first, that's still no >> reason to use totally separate code paths and mechanisms. These >> requests can still use the same data structures / functions and just >> be ordered to come first, can't they? ...or given a boolean >> "priority" and you can do two passes through your queue: one to do the >> priority ones and one to do the secondary ones. >> >> > The bus requests have a certain order and cannot be mutated by the > RPMH driver. It has to be maintained in the TCS in the same order. Please document this requirement in the code. > Also, the bus requests have quite a churn during the course of an > usecase. They are setup and invalidated often. > It is faster to have them separate and invalidate the whole lot of the > batch_cache instead of intertwining them with requests from other > drivers and then figuring out which all must be invalidated and rebuilt > when the next batch requests comes in. Remember, that requests may come > from any driver any time and therefore will be mangled if we use the > same data structure. So to be faster and to avoid having mangled requests > in the TCS, I have kept the data structures separate. If you need to find a certain group of requests then can't you just tag them and it's easy to find them? I'm still not seeing the need for a whole separate code path and data structure. >>>>> + spin_unlock_irqrestore(&ctrlr->lock, flags); >>>>> + >>>>> + return ret; >>>>> +} >>>> >>>> >>>> >>>> As part of my overall confusion about why the batch cache is different >>>> than the normal one: for the normal use case you still call >>>> rpmh_rsc_write_ctrl_data() for things you put in your cache, but you >>>> don't for the batch cache. I still haven't totally figured out what >>>> rpmh_rsc_write_ctrl_data() does, but it seems strange that you don't >>>> do it for the batch cache but you do for the other one. >>>> >>>> >>> flush_batch does write to the controller using >>> rpmh_rsc_write_ctrl_data() >> >> >> My confusion is that they happen at different times. As I understand it: >> >> * For the normal case, you immediately calls >> rpmh_rsc_write_ctrl_data() and then later do the rest of the work. >> >> * For the batch case, you call both later. >> >> Is there a good reason for this, or is it just an arbitrary >> difference? If there's a good reason, it should be documented. >> >> > In both the cases, the requests are cached in the rpmh library and are > only sent to the controller only when the flushed. I am not sure the > work is any different. The rpmh_flush() flushes out batch requests and > then the requests from other drivers. OK then, here are the code paths I see: rpmh_write => __rpmh_write => cache_rpm_request() => (state != RPMH_ACTIVE_ONLY_STATE): rpmh_rsc_send_data() rpmh_write_batch => (state != RPMH_ACTIVE_ONLY_STATE): cache_batch() => No call to rpmh_rsc_send_data() Said another way: * if you call rpmh_write() for something you're going to defer you will still call cache_rpm_request() _before_ rpmh_write() returns. * if you call rpmh_write_batch() for something you're going to defer then you _don't_ call cache_rpm_request() before rpmh_write_batch() returns. Do you find a fault in my analysis of the current code? If you see a fault then please point it out. If you don't see a fault, please say why the behaviors are different. I certainly understand that eventually you will call cache_rpm_request() for both cases. It's just that in one case the call happens right away and the other case it is deferred.