Received: by 10.223.185.116 with SMTP id b49csp2185921wrg; Thu, 22 Feb 2018 09:26:01 -0800 (PST) X-Google-Smtp-Source: AH8x227jjUDbwWrZAmVyK3NJ5+lMjn0Muo1RYrhpl40d/OBKKqoPaM99EtxkRG67vSWNjxOwlo0G X-Received: by 2002:a17:902:ab88:: with SMTP id f8-v6mr6842196plr.325.1519320361489; Thu, 22 Feb 2018 09:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519320361; cv=none; d=google.com; s=arc-20160816; b=aUuk1Qp5K2buGjwkGeV2UQGtur3kZBBVNs9WeZ8NPjdH2j4Iqqbl4Uoflz+29nM4Ge JUYIcb1Jy+wbklTH4zQ9Qq0lWSEPXLee16t0UU9IG7GwbOyGshs9v37NVAqakFUhtSxk 6O6zYYIRnZ00w7/FC6ukpHII+q5kiPCdvVTQo5vHNUEIO52xe5pCvS6XN44Pm2lW2/bt rA34x6yValNUPo3vLX3/tkGN6EBZs5VSVF3qPgRODUEka1Ca5KCACKlbNEWijtSuMrqk esVPoiXv3xgZPQqdNW9NxkEbCr+KjiDyTMhN4eJBA1Cqy/Po1ljFzEr3Pm7rgfI49l+h Uksw== 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:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=Xfz+ex09fSEvfTa9ezSmai/dbBFgPMQKx5ZGo+VcfL0=; b=VVZPAPO6jxaUkQytqDuFVCYlpz6IGbP7ci90glFK2RQ6G4q6x14mjpz2nHfX8bHmt0 +CLEbdq5HaLpNBauDoeBR9i5Dufq7nJITcA3iBkXdEPHV28XFSKHEA6jvlxptG7ymhpj Ht02hDL/l8vHehNxK3v9FG2pYtaWhsBygV1dB4PpBM+ndWWOg2niA8aFgARy/lSlnZM0 I7UhyrhEYk2C4geaOtNiMO6DvhFo6BFSBCe57PP/3PRuvcwor08Bn7G837Hlf7toJsHE X3Q5x74GsKwNPKSzFEn+bOF0miaUXsaAyDbGdH6YkLsM01QjbZOMYMJkR86ctTy5zfIx GrxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ai42tmjq; dkim=pass header.i=@codeaurora.org header.s=default header.b=CuKBTKr1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u128si286438pgc.587.2018.02.22.09.25.45; Thu, 22 Feb 2018 09:26:01 -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=@codeaurora.org header.s=default header.b=Ai42tmjq; dkim=pass header.i=@codeaurora.org header.s=default header.b=CuKBTKr1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933499AbeBVRYx (ORCPT + 99 others); Thu, 22 Feb 2018 12:24:53 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34282 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933210AbeBVRYu (ORCPT ); Thu, 22 Feb 2018 12:24:50 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 868DC6081C; Thu, 22 Feb 2018 17:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519320289; bh=UgwhhYifqK6PF9c8sXcB3Ymp1baNXEbCwxv4iEBj/Cs=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=Ai42tmjqUj1/hW2LnKoP/yXxsI3HOnXCxlNIa+NrkCGBihMf4u2K0NHzACyEY4vxs D6jjB4kc/Qd94h3zrfENarjvR1ujEwFQ1WWVNjcHybwV3JHOYLdJq5F/37PaEe0/wk ryykbB7Cyyt+SZqoOGqgeDPi2mfSn3rfTNZBfl8g= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail-qk0-f169.google.com (mail-qk0-f169.google.com [209.85.220.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0B36860848; Thu, 22 Feb 2018 17:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519320288; bh=UgwhhYifqK6PF9c8sXcB3Ymp1baNXEbCwxv4iEBj/Cs=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=CuKBTKr1VGHrqskUzQYhWmjFgxurLSvNesu7m+roXegnUTXqaoQ9CrGjVvtcyJ3Mx Hzj6yO2M/9venka96R6SrTqROziHHG21L46jIBu0ocDJbeWYPSj/nRbxp+23dIpfGw a7mVUK6ycR6ITUZR7gS30792NFZFcUVd6lz44fnc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0B36860848 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org Received: by mail-qk0-f169.google.com with SMTP id h129so7392709qke.8; Thu, 22 Feb 2018 09:24:47 -0800 (PST) X-Gm-Message-State: APf1xPAJfn4HnsfPUxyTd5Z1vlk6VmG9QD5UhO6bVukyACIA104lFcmy RuETRGZPGuDFEt1K1zSE9EBF5WMuqXOB8elQJHs= X-Received: by 10.55.212.150 with SMTP id s22mr11167924qks.85.1519320287097; Thu, 22 Feb 2018 09:24:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.97.86 with HTTP; Thu, 22 Feb 2018 09:24:46 -0800 (PST) In-Reply-To: References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <7406f1ce-c2c9-a6bd-2886-5a34de45add6@arm.com> <28466b36-b5d3-4f60-a45e-b75d79c2a3cb@arm.com> From: Vivek Gautam Date: Thu, 22 Feb 2018 22:54:46 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 6/6] drm/msm: iommu: Replace runtime calls with runtime suppliers To: Tomasz Figa Cc: Robin Murphy , Will Deacon , "list@263.net:IOMMU DRIVERS" , Joerg Roedel , Rob Herring , Mark Rutland , "Rafael J. Wysocki" , Rob Clark , devicetree@vger.kernel.org, Linux Kernel Mailing List , Linux PM , dri-devel , freedreno , David Airlie , Greg KH , Stephen Boyd , linux-arm-msm , jcrouse@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, Feb 22, 2018 at 7:42 PM, Tomasz Figa wrote: > On Thu, Feb 22, 2018 at 10:45 PM, Robin Murphy wrote: >> [sorry, I had intended to reply sooner but clearly forgot] >> >> >> On 16/02/18 00:13, Tomasz Figa wrote: >>> >>> On Fri, Feb 16, 2018 at 2:14 AM, Robin Murphy >>> wrote: >>>> >>>> On 15/02/18 04:17, Tomasz Figa wrote: >>>> [...] >>>>>> >>>>>> >>>>>> Could you elaborate on what kind of locking you are concerned about? >>>>>> As I explained before, the normally happening fast path would lock >>>>>> dev->power_lock only for the brief moment of incrementing the runtime >>>>>> PM usage counter. >>>>> >>>>> >>>>> >>>>> My bad, that's not even it. >>>>> >>>>> The atomic usage counter is incremented beforehands, without any >>>>> locking [1] and the spinlock is acquired only for the sake of >>>>> validating that device's runtime PM state remained valid indeed [2], >>>>> which would be the case in the fast path of the same driver doing two >>>>> mappings in parallel, with the master powered on (and so the SMMU, >>>>> through device links; if master was not powered on already, powering >>>>> on the SMMU is unavoidable anyway and it would add much more latency >>>>> than the spinlock itself). >>>> >>>> >>>> >>>> We now have no locking at all in the map path, and only a per-domain lock >>>> around TLB sync in unmap which is unfortunately necessary for >>>> correctness; >>>> the latter isn't too terrible, since in "serious" hardware it should only >>>> be >>>> serialising a few cpus serving the same device against each other (e.g. >>>> for >>>> multiple queues on a single NIC). >>>> >>>> Putting in a global lock which serialises *all* concurrent map and unmap >>>> calls for *all* unrelated devices makes things worse. Period. Even if the >>>> lock itself were held for the minimum possible time, i.e. trivially >>>> "spin_lock(&lock); spin_unlock(&lock)", the cost of repeatedly bouncing >>>> that >>>> one cache line around between 96 CPUs across two sockets is not >>>> negligible. >>> >>> >>> Fair enough. Note that we're in a quite interesting situation now: >>> a) We need to have runtime PM enabled on Qualcomm SoC to have power >>> properly managed, >>> b) We need to have lock-free map/unmap on such distributed systems, >>> c) If runtime PM is enabled, we need to call into runtime PM from any >>> code that does hardware accesses, otherwise the IOMMU API (and so DMA >>> API and then any V4L2 driver) becomes unusable. >>> >>> I can see one more way that could potentially let us have all the >>> three. How about enabling runtime PM only on selected implementations >>> (e.g. qcom,smmu) and then having all the runtime PM calls surrounded >>> with if (pm_runtime_enabled()), which is lockless? >> >> >> Yes, that's the kind of thing I was gravitating towards - my vague thought >> was adding some flag to the smmu_domain, but pm_runtime_enabled() does look >> conceptually a lot cleaner. > > Great, thanks. Looks like we're in agreement now. \o/ > > Vivek, does this sound reasonable to you? Yea, sound good to me. I will respin the patches. Thanks & Regards Vivek > > Best regards, > Tomasz -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation