Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1241764imm; Fri, 11 May 2018 13:15:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpoLkPyzf44LU5+LhiZ/+lqKSLFR12PI+iwHkRMmSmKBY2mOUH69OuvXUfjSQvn9XKYUKgz X-Received: by 2002:a17:902:1682:: with SMTP id h2-v6mr357863plh.37.1526069727600; Fri, 11 May 2018 13:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526069727; cv=none; d=google.com; s=arc-20160816; b=0s9VI7kHP9vDhIoZ+8nWpOQ/yR73V+SbPreyKHsaLqt5SGFd3PyZeDkIqn0j0LhcYg iNbtEUf6rIdHB+2dq0OWZx81Fpbtu5nI4qJ7vVWIEUhT8FPVimkntFiZjQzg39Tft+4M g9+7w91FB76uXrGHYLNTKCnYupZrBzdnVrjxKuvcGOFLO1joJBDO5Sjuo0rb2qMMPwpC 7ORJBGWbMPPHggfp8J8rEhwcYF/Y7aYNu50fhcu7Gi58np2PupWuPtS+Cj0IuKiRJHCG 6XT5kGIfdVLaB0XJ7ts7JyBjiZmw3/Mqgi60ehupFlBwx4MScoz3Bzi+7RsaJjdLs7cL X2pg== 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=ASImrvnS+Xqw0oPE7zPWRO/TbBPMha+JoAknUQjSwUA=; b=S3fTzJtSUUZVfB3uezQ91oROdjCTpJZbYxyPRtMzTATDbO74bzMiIWUa1xE8+rNqiu 2QnTs/+lG9FhbbGvOlOM3Pwa5wgGO6tcmvtV6MrtmKFp6kGAvY63HZnJKMQ5/JoH1ZVQ /heeLDUILxzx0bq7gxIDAtgxoWDFRNJShm5lLmvR4vI/deh0J7WAZscNca46vm/8SOAS 9IzByy2yZopexLmJByVScAgTEKqX0HFqVMSj2Z9oTFjVa7/9e28gqTiZxFPe9qJS0cPj J8qpQLnx8iYbLaPLbC879mOQNb9YOpDo7lkcz1fS5epIToL0pHx8WkgPVxaJZ+izP6pw 0FDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=aEVlWu6P; dkim=fail header.i=@chromium.org header.s=google header.b=KicD6RJx; 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 r16-v6si3030547pgr.560.2018.05.11.13.15.13; Fri, 11 May 2018 13:15:27 -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=aEVlWu6P; dkim=fail header.i=@chromium.org header.s=google header.b=KicD6RJx; 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 S1752041AbeEKUOz (ORCPT + 99 others); Fri, 11 May 2018 16:14:55 -0400 Received: from mail-ua0-f170.google.com ([209.85.217.170]:44143 "EHLO mail-ua0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752026AbeEKUOx (ORCPT ); Fri, 11 May 2018 16:14:53 -0400 Received: by mail-ua0-f170.google.com with SMTP id h15-v6so4389666uan.11 for ; Fri, 11 May 2018 13:14:52 -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=ASImrvnS+Xqw0oPE7zPWRO/TbBPMha+JoAknUQjSwUA=; b=aEVlWu6P9W0v9DTWoku/Zgzn0zCfD+s5ZEHuBWJNGavvDuenVjj/OHIAtu2dLnwYTv QK0vPtoT0dyL1SjCE0yj6H32pXD0/jmVfhPhRD86AssewzFK6BPqIp7nITWWWHEOzpU2 I8IPmK81EGRMBoCeT4uFW5OY1B0kt9W6afxUdE0/TwIncaM/oH37odm/ruWF1CPWHfwk iuOZjF08tM3//CpgAqmkdDYmB5mMSB3+X+k4I9B8EQ/40QNxWTgUSuOPQANpbHDi/Slh z+5UuNZr9JwsAuKd0kSqQv2tvn1Ozx4xQa68kK5hwQMP26Nl7derOjaI+CFk+XhylK1A ciVA== 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=ASImrvnS+Xqw0oPE7zPWRO/TbBPMha+JoAknUQjSwUA=; b=KicD6RJxfGapTgUtcaZdV4NcLhN2pYLuTzJhCWScMZY8umy7ZWGJjYMUk1OJy7vNTP zC8aKFfbTVaWbC7w1JJY+7Bn/M2DrRXsRoJJmZZOSAuRxGisPHWTfpib35tCqEIdR46q /nl7l68BkB5OfviTXR1jb836A8hr6knTV4T2I= 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=ASImrvnS+Xqw0oPE7zPWRO/TbBPMha+JoAknUQjSwUA=; b=fIb55tr9MhmIKNQyBuGgyZOHnQq31p/Zxk+sbWYNNcfYnqs8JmwmWQ+ns3UU5I3FFn z/hEXGzPhPjLx5Y0bOrOBvgv9kd2ug4rBI6DNZg74CxYNu1sVuqYIQSYnbk0HjG1Qox+ N4wFig/jtSt2uPiS1C5uPKXIgGUM4OiVAnKj0FZM5L8/c2RQD4oVJ3S2+nRJAOXdkmWf +KpqlheIEB317l200IhO54EwiHhfZHlZf0oWuB/A3/E53uE8SXhMgbjc3PKzrpUix7is cngtsaGM0X6qnQGPsEAGl+JsIaQJwcGVTSce/vic3FFeLEJKiUCmH/1DiXTolNbzwLcg VNBg== X-Gm-Message-State: ALKqPwf+7FCXDmbqWDU/FKJ6PHVTF8hd2f8F1iWN2rEobgGJeu7fg8zT nMEoTZN6pqWGlYkHQ0sgoTE5nXhhgWIP+Tf0I3eegA== X-Received: by 2002:a9f:33e3:: with SMTP id y35-v6mr2447152uab.121.1526069691755; Fri, 11 May 2018 13:14:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.48.82 with HTTP; Fri, 11 May 2018 13:14:51 -0700 (PDT) In-Reply-To: <20180511150611.GA30504@codeaurora.org> References: <20180502193749.31004-1-ilina@codeaurora.org> <20180502193749.31004-5-ilina@codeaurora.org> <20180511150611.GA30504@codeaurora.org> From: Doug Anderson Date: Fri, 11 May 2018 13:14:51 -0700 X-Google-Sender-Auth: R3Or4P_govi0u03jhdCWZHdLCpE Message-ID: Subject: Re: [PATCH v7 04/10] drivers: qcom: rpmh: add RPMH helper functions 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 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, May 11, 2018 at 8:06 AM, Lina Iyer wrote: >> As I've said I haven't reviewed RPMh in any amount of detail and so >> perhaps I don't understand something. >> >> OK, I dug a little more and coded up something for you. Basically >> you're doing a whole bunch of iteration / extra work here to try to >> come up with a way to associate an extra bit of data with each "struct >> rsc_drv". Rather than that, just add an extra field into "struct >> rsc_drv". Problem solved. >> >> See http://crosreview.com/1054646 for what I mean. >> > I tried to avoid such pointer references and keep it object oriented > with this approach. I agree that we run through a list of 2 (at the max) > RSC to get the drv* from the rpmh_ctrlr. It is not going to be > expensive. Even if you wanted to keep things "object oriented" then IMHO your code still should change. Sure, it's not computationally expensive to iterate through this list, but it adds an extra level of complexity that doesn't seem justified. If you _really_ needed an abstraction barrier then at least add a "void *client_data" to "struct rsc_drv.c". At least you'd get rid of the ugly global list and store your pointer directly in the correct structure rather than creating an external entity. Now it becomes 100% obvious that there is exactly 1 "struct rpmh_ctrlr" for each controller. ...but IMO there's enough intertwining between "rpmh.c" and "rpmh-rsc.c" that it would just be a waste because now you'd need to do extra memory allocation and freeing. ...and if you just allocated the pointer in get_rpmh_ctrlr() it would also seem non-ideal because this one-time allocation (that affects _all_ RPMh clients) happens whenever one client happens to do the first access. This is one-time init so it makes sense to do it at init time. I say that there's intertwining between "rpmh.c" and "rpmh-rsc.c" because both C files call directly into one another and have intimate knowledge of how the other works. They aren't really separate things. Specifically I see that "rpmh-rsc" directly calls into "rpmh.c" when it calls rpmh_tx_done(), and of coruse "rpmh-rsc.c" directly calls into "rpmh.c". OK, so I've been browsing through the source code more so I can be a little more informed here. As far as I can tell "rpmh.c"'s goal is: 1. Put a simpler API atop "rpmh-rsc.c". ...but why not just put that API directly into "rpmh-rsc.c" anyway? If there was someone that needed the more complex API then having a "simpler" wrapper makes sense, but that's not the case, is it? 2. Add caching atop "rpmh-rsc" I'll respond to some of your other patches too, but I think that the amount of code for caching is not very much. I don't see the benefit of trying to split the code into two files. Put them into one and then delete all the extra code you needed just the try to maintain some abstraction. > Another things this helps with is that, if the driver is not a child of > the RSC nodes in DT, then the drvdata of the parent would not a RSC node > and accessing that would result in a crash. This offers a cleaner exit > path for the error case. Why would the driver not be a child of the RSC nodes? That's kinda like saying "if you try to instantiate an i2c device as a platform device then its probe will crash". Yeah, it will. Doctor, it hurts if I poke myself in my eye with this sharp stick, do you have any medicine that can help fix that? >>>> I'll try to dig into this more so I could just be confused, but in >>>> general it seems really odd to have a spinlock and something called a >>>> "cache" at this level. If we need some sort of mutual exclusion or >>>> caching it seems like it should be stored in memory directly >>>> associated with the RPMh device, not some external global. >>>> >>> The idea behind the locking is not to avoid the race between rpmh.c and >>> rpmh-rsc.c. From the DT, the devices that are dependent on the RSCs are >>> probed following the probe of the controller. And init is not that we are >>> worried about. >>> The condition here is to prevent the rpmh_rsc[] from being modified >>> concurrently by drivers. >> >> >> OK, I see the point of the locking now, but not the list still. >> Sounds like Matthias agrees with me that the list isn't useful. Seems >> like you should squash my patch at http://crosreview.com/1042883 into >> yours. >> > I saw your approach. I am okay with it for your tree, I'm not okay with it for the Chrome OS tree. We need to match upstream, not fork for style reasons. I'd rather take a driver that I think it overly complex but matches upstream than a private driver. > my approach comes > out of experiences in qcom platforms and how things tend to shape up in > the future. I would want you to consider my reasoning as well, before we > go forward. I suppose we can get advice from others who have worked in qcom platforms and see what they think. My opinions come out of years of experience working with Linux drivers, so I guess we both have some experience under our belts that we're trying to leverage. -Doug