Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp825416pxj; Thu, 20 May 2021 23:24:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9crA1XAQF157Z5ApjUEpK0VwKJ5YFuCG0L+9zXfa+XfBMTZ9lQ072ZnKVG6tnzfa2UlqJ X-Received: by 2002:a50:abc1:: with SMTP id u59mr8242981edc.7.1621578297593; Thu, 20 May 2021 23:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621578297; cv=none; d=google.com; s=arc-20160816; b=YxUnMZfHrX3vLL+kzYETASwGfM2GfBazitRl0cKQGK73j50EhsslnqY9Vi0dbBaylW vgBLl1dHHAP3G+Tkgs0NNylhyKUoITSeIJkUybyVACjHGCJKofHQoS34jWkFSp/PcjmA KKylQBLJs24Lk/rzYG6X8GXEZRqm8BBALFFqqYy086mQg3IzEMeZJjlbBKwFYSKvs4ng cvvDOSWTjyGvLyjCTOVUgb+M+mL6gOz2elSeOLrtSFaxYQnqtqmyqzfU71QuqhyQ4GlG mHRecvu3mInqcEXe3AKyjVTRAsR8PsF107iWM1iOPMgZjYnhdV/c8JabqrC92fM0gEJi m8Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=D/fC8cTjvNjAco9GQ5lMElWjnvmZVnjTOXVPAX+OC80=; b=GQI/bCvKEMbl8nCzZda7zy7Gsi6hhMuu327UNizQ07/OeII0EMbxkN3OV9gxBY1yCm nGK3ojbH7cEmytpEC2MuETDQkgPFdNMzBQZ3xRqQgV1RO7BYhRu6L6u4xdPyRkcQ4b0w sjqTylDS3VwyPkN4JF/udWqeQzQ4qj9tynKVfAMwbHK2ffGrxY9WKCneKaXd1ntUEbpG uelZXDed4QQNAg6NPuaGoMgNuR2cVFBElh1KV3CvV/oMP5cCZn6I4FE6XKVrQ7dvkbRd xTryemRm59gd6rncK6cFY/D9ZHUXwDBTxVm2Yg4ym14xiDq0vAjSUg4Gs0zhdSEJmWjG YuSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=lRzdwUQi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si4378369edp.204.2021.05.20.23.24.34; Thu, 20 May 2021 23:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=lRzdwUQi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbhETQfe (ORCPT + 99 others); Thu, 20 May 2021 12:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231724AbhETQfc (ORCPT ); Thu, 20 May 2021 12:35:32 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AEFAC061574 for ; Thu, 20 May 2021 09:34:11 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id u4-20020a05600c00c4b02901774b80945cso5804253wmm.3 for ; Thu, 20 May 2021 09:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=D/fC8cTjvNjAco9GQ5lMElWjnvmZVnjTOXVPAX+OC80=; b=lRzdwUQiyIC72DgMTpYMkcuSlY2LeVVmwy5VuSyIpEFfSZQBnUFZ/DKzZfZ6wMKKCG NJMBGuj3d1KUSHYEZiOzTA7Tvy5FDEyCQuscm8+sx+9IyWekNZtWU7ZFv4O5r0pwXUtH 6fkJVOTCkOfp8POTQB+R9D5UTTjRbP+gB7sZs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=D/fC8cTjvNjAco9GQ5lMElWjnvmZVnjTOXVPAX+OC80=; b=PolqUYFS04U3SngOV9NSGGnpl61RH/sMj9tRXp4AhkrludkL7Bv3WvHE0G+8+Ukylr c1+i9C73gMm/xjKPGQuJRKCIOYYxsHc7U7cnpUrb7GB00poOk6Ja8uwtr9VGl8jG42cP l8xrkyRoV6oeTywNyjGjhWPkxmocqfl1A/PtYT0onY6UHVf95BiBt+t0aKIvda5OIN8s xCy6hZ/odCctBbbclBrtq8h0nqz8dYf21O0dOfZYFy8vB6yCqSHlG7KK5JG87Le2EiaG 60BmXTzKDLJylGKpFJYe9JiDd4PAzFMINh/Rr+IzTWKF8RsCYXc3CBIzw8pO4+S3o06J 3Iag== X-Gm-Message-State: AOAM531NRcsEzLt5B88DP/HApeNSY2tyn61BMWxlOr4cLhOk2W9kVNNQ Q03P8B+Uu5gLSFv6ec5MvPMraQ== X-Received: by 2002:a1c:5449:: with SMTP id p9mr5017481wmi.61.1621528449691; Thu, 20 May 2021 09:34:09 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id g206sm9800386wme.16.2021.05.20.09.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 09:34:09 -0700 (PDT) Date: Thu, 20 May 2021 18:34:07 +0200 From: Daniel Vetter To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Rob Clark , Christian =?iso-8859-1?Q?K=F6nig?= , Rob Clark , linux-arm-msm , open list , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , freedreno , "open list:DMA BUFFER SHARING FRAMEWORK" Subject: Re: [Linaro-mm-sig] [RFC 1/3] dma-fence: Add boost fence op Message-ID: Mail-Followup-To: Christian =?iso-8859-1?Q?K=F6nig?= , Rob Clark , Christian =?iso-8859-1?Q?K=F6nig?= , Rob Clark , linux-arm-msm , open list , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , freedreno , "open list:DMA BUFFER SHARING FRAMEWORK" References: <20210519183855.1523927-1-robdclark@gmail.com> <20210519183855.1523927-2-robdclark@gmail.com> <8dcdc8d5-176c-f0ad-0d54-6466e9e68a0a@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Operating-System: Linux phenom 5.10.32scarlett+ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 20, 2021 at 06:01:39PM +0200, Christian K?nig wrote: > Am 20.05.21 um 16:54 schrieb Rob Clark: > > On Thu, May 20, 2021 at 7:11 AM Christian K?nig > > wrote: > > > > > > > > > Am 20.05.21 um 16:07 schrieb Rob Clark: > > > > On Wed, May 19, 2021 at 11:47 PM Christian K?nig > > > > wrote: > > > > > Uff, that looks very hardware specific to me. > > > > Howso? I'm not sure I agree.. and even if it was not useful for some > > > > hw, it should be useful for enough drivers (and harm no drivers), so I > > > > still think it is a good idea > > > > > > > > The fallback plan is to go the i915 route and stop using atomic > > > > helpers and do the same thing inside the driver, but that doesn't help > > > > any of the cases where you have a separate kms and gpu driver. > > > Yeah, that's certainly not something we want. > > > > > > > > As far as I can see you can also implement completely inside the backend > > > > > by starting a timer on enable_signaling, don't you? > > > > Not really.. I mean, the fact that something waited on a fence could > > > > be a useful input signal to gpu freq governor, but it is entirely > > > > insufficient.. > > > > > > > > If the cpu is spending a lot of time waiting on a fence, cpufreq will > > > > clock down so you spend less time waiting. And no problem has been > > > > solved. You absolutely need the concept of a missed deadline, and a > > > > timer doesn't give you that. > > > Ok then I probably don't understand the use case here. > > > > > > What exactly do you try to solve? > > Basically situations where you are ping-ponging between GPU and CPU.. > > for example if you are double buffering instead of triple buffering, > > and doing vblank sync'd pageflips. The GPU, without any extra signal, > > could get stuck at 30fps and a low gpu freq, because it ends up idle > > while waiting for an extra vblank cycle for the next back-buffer to > > become available. Whereas if it boosted up to a higher freq and > > stopped missing a vblank deadline, it would be less idle due to > > getting the next back-buffer sooner (due to not missing a vblank > > deadline). > > Ok the is the why, but what about the how? > > How does it help to have this boost callback and not just start a time on > enable signaling and stop it when the signal arrives? Because the render side (or drm/scheduler, if msm would use that) has no idea for which vblank a rendering actually is for. So boosting right when you've missed your frame (not what Rob implements currently, but fixable) is the right semantics. The other issue is that for cpu waits, we want to differentiate from fence waits that userspace does intentially (e.g. wait ioctl) and waits that random other things are doing within the kernel to keep track of progress. For the former we know that userspace is stuck waiting for the gpu, and we probably want to boost. For the latter we most definitely do _not_ want to boost. Otoh I do agree with you that the current api is a bit awkward, so perhaps we do need a dma_fence_userspace_wait wrapper which boosts automatically after a bit. And similarly perhaps a drm_vblank_dma_fence_wait, where you give it a vblank target, and if the fence isn't signalled by then, we kick it real hard. But otherwise yes this is absolutely a thing that matters a ton. If you look at Matt Brost's scheduler rfc, there's also a line item in there about adding this kind of boosting to drm/scheduler. -Daniel > > Regards, > Christian. > > > > > BR, > > -R > > > > > Thanks, > > > Christian. > > > > > > > BR, > > > > -R > > > > > > > > > Christian. > > > > > > > > > > Am 19.05.21 um 20:38 schrieb Rob Clark: > > > > > > From: Rob Clark > > > > > > > > > > > > Add a way to hint to the fence signaler that a fence waiter has missed a > > > > > > deadline waiting on the fence. > > > > > > > > > > > > In some cases, missing a vblank can result in lower gpu utilization, > > > > > > when really we want to go in the opposite direction and boost gpu freq. > > > > > > The boost callback gives some feedback to the fence signaler that we > > > > > > are missing deadlines, so it can take this into account in it's freq/ > > > > > > utilization calculations. > > > > > > > > > > > > Signed-off-by: Rob Clark > > > > > > --- > > > > > > include/linux/dma-fence.h | 26 ++++++++++++++++++++++++++ > > > > > > 1 file changed, 26 insertions(+) > > > > > > > > > > > > diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h > > > > > > index 9f12efaaa93a..172702521acc 100644 > > > > > > --- a/include/linux/dma-fence.h > > > > > > +++ b/include/linux/dma-fence.h > > > > > > @@ -231,6 +231,17 @@ struct dma_fence_ops { > > > > > > signed long (*wait)(struct dma_fence *fence, > > > > > > bool intr, signed long timeout); > > > > > > > > > > > > + /** > > > > > > + * @boost: > > > > > > + * > > > > > > + * Optional callback, to indicate that a fence waiter missed a deadline. > > > > > > + * This can serve as a signal that (if possible) whatever signals the > > > > > > + * fence should boost it's clocks. > > > > > > + * > > > > > > + * This can be called in any context that can call dma_fence_wait(). > > > > > > + */ > > > > > > + void (*boost)(struct dma_fence *fence); > > > > > > + > > > > > > /** > > > > > > * @release: > > > > > > * > > > > > > @@ -586,6 +597,21 @@ static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr) > > > > > > return ret < 0 ? ret : 0; > > > > > > } > > > > > > > > > > > > +/** > > > > > > + * dma_fence_boost - hint from waiter that it missed a deadline > > > > > > + * > > > > > > + * @fence: the fence that caused the missed deadline > > > > > > + * > > > > > > + * This function gives a hint from a fence waiter that a deadline was > > > > > > + * missed, so that the fence signaler can factor this in to device > > > > > > + * power state decisions > > > > > > + */ > > > > > > +static inline void dma_fence_boost(struct dma_fence *fence) > > > > > > +{ > > > > > > + if (fence->ops->boost) > > > > > > + fence->ops->boost(fence); > > > > > > +} > > > > > > + > > > > > > struct dma_fence *dma_fence_get_stub(void); > > > > > > u64 dma_fence_context_alloc(unsigned num); > > > > > > > > _______________________________________________ > > Linaro-mm-sig mailing list > > Linaro-mm-sig@lists.linaro.org > > https://lists.linaro.org/mailman/listinfo/linaro-mm-sig > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch