Received: by 10.223.185.116 with SMTP id b49csp1925651wrg; Thu, 22 Feb 2018 05:31:38 -0800 (PST) X-Google-Smtp-Source: AH8x226yiNO0XrvvxYVwpwV7NOiBbmT9GVTpT+Q0FG8vq/MLJ+M/WhFUSUd4vHQOJ0ovDvfpp70v X-Received: by 10.101.98.201 with SMTP id m9mr5669157pgv.100.1519306298156; Thu, 22 Feb 2018 05:31:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519306298; cv=none; d=google.com; s=arc-20160816; b=hXNpUhkA84lsx4m90O+s5gDZBz7FJ06lo4V9MSnKfycY8jO9qREUQpIYxSCkI2RKyA l4SXXLnb5KYXX2FfDQh3FArHyLESS9kBQLWHIuzkez5tgg3opcvxrYjRrgkLbnRGQstw 4SQQ3B5ywHdFvyG1f4Ea+QkCv31nOE/Hll18JjkNB4WHpIvADm2P5uw2K4XBxhwqY8g1 ebjSleht/eMNbWCcmsv9/dI72iaiYrPm+xTtuFEgDE5xf2nIwaTrYKg87W2bDTyITY1r BzESdDzo1rYjnQ726w0eKkirpI+uddz0OjP/K6qNegTrasGJzuDRHTKfpuvWW75dlUjD Zppg== 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=nQ0pzz3DscSiLHgEor+6L44bgNqEqtnGsHdNflsCcws=; b=aj6CmEktYmUv4prB+KDuGFsHlYsnwKEvHfJjO1sG30Hq436kxYAiU9e8Ir68P/3rjc etvDjy5Md1OzOqmSAEvFUq5sXhvxD3lkMiMFTXF6lVs4J90ezQ5Hw6vq9E03O7FqR2bU 92dZ1KuD36VRu2w3afZJBixmMkG1tK/RY144hc4c1LBBJ/LRSpYSdLSuOhK5FP5bj6fW 6Lro+AkDKSfLdM5dsguHxVvyxzR8cJVP5SsXDd+W/7Kx3Zmy38CR0cgZHT+altoPQexr heE+mJpfZBDIayndijQGGo6kWVddDsrDDzxeRlhxESa28HKwFU5hZkPathiYZYkpUr7u 1Brw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P8TriEc7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o17si31055pgc.665.2018.02.22.05.31.23; Thu, 22 Feb 2018 05:31:38 -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=@gmail.com header.s=20161025 header.b=P8TriEc7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932493AbeBVNak (ORCPT + 99 others); Thu, 22 Feb 2018 08:30:40 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:40827 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753750AbeBVNah (ORCPT ); Thu, 22 Feb 2018 08:30:37 -0500 Received: by mail-it0-f67.google.com with SMTP id v186so6473565itc.5; Thu, 22 Feb 2018 05:30:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nQ0pzz3DscSiLHgEor+6L44bgNqEqtnGsHdNflsCcws=; b=P8TriEc7V5BovzY/ra4gkZu2dNojaOWPYti2uwMl9y6xk1bzUwSyK7MPcRWohOHSrw N0sI+AxgmwhcD9UKvS65nFxkrrYtu0HMIme0Y3JWt/EQvkhFB30kKPyVSaNWRJPWJTiS oVoIg2cVLzuTbtSe6f5ne9qqHxMwn2IabrAinLKYla/dhmyYjhmLeA0Dhlk+BMstlxMd /HXtWdxx3oakdSPnL8DPs+vVPviyXG1fFnWT6K54ixh1OEWRtpDP8BD6GRw7vAbQ2EMm fe1GvAvvn9NOJmunPkuDuiEtTn3NXBrk+OHpXRGmeFTgJwCwXKgwD7om49JjSNCeZ42m nkFg== 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=nQ0pzz3DscSiLHgEor+6L44bgNqEqtnGsHdNflsCcws=; b=bUE6EoLGkGdj4j5HLsvs7ERxMkYNz4y/PVXyCcWVMBr7Fy5WY+SEhmkwoGmzbj7pP3 57dytK+uiXUZLbCss8g9CXQNgDANhwC6HtV3/fnJ7ZLgTGkTNb2Adx3TAZC6VH5ge2gz 6MoEDq5dJdgiLzcJiHXUXcPXnHktkgZ+/3qMp464j5nj+5pQIJYBS35m7BQmCqdMVgS5 z9aPS5tgVBuU9sD55eBFuXJiQDahnHMuu2rkDKSIr7x5dq7YomwotIwnm6ru5uZwk0gn MiLMtnRbNdccTe8u9pEN1FCbizNKjkmcjGgdury6wT8Nllj9x04eJfWegvpqiZ27mvrj 8QdA== X-Gm-Message-State: APf1xPBm08OSR4BuKZ9c9E4vc8aSv/0IGFc+uMvsuRLJRjDT2ewovgoQ FwixACcxk8uBxytfOv5Jzp0YLTbl3a/l7plF7HE= X-Received: by 10.36.107.145 with SMTP id v139mr4354030itc.33.1519306236546; Thu, 22 Feb 2018 05:30:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.92.211 with HTTP; Thu, 22 Feb 2018 05:30:35 -0800 (PST) In-Reply-To: References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <7406f1ce-c2c9-a6bd-2886-5a34de45add6@arm.com> From: Rob Clark Date: Thu, 22 Feb 2018 08:30:35 -0500 Message-ID: Subject: Re: [Freedreno] [PATCH v7 6/6] drm/msm: iommu: Replace runtime calls with runtime suppliers To: Tomasz Figa Cc: Robin Murphy , Mark Rutland , devicetree@vger.kernel.org, Jordan Crouse , Linux PM , David Airlie , "Rafael J. Wysocki" , Joerg Roedel , Will Deacon , "list@263.net:IOMMU DRIVERS" , dri-devel , Linux Kernel Mailing List , Rob Herring , Vivek Gautam , Greg KH , freedreno , Stephen Boyd , linux-arm-msm 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 On Thu, Feb 22, 2018 at 3:13 AM, Tomasz Figa wrote: > On Fri, Feb 16, 2018 at 9:13 AM, 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? >> > > Sorry for pinging, but any opinion on this kind of approach? > It is ok by me, for whatever that is worth BR, -R