Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5786821ybe; Tue, 10 Sep 2019 08:48:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOuNe7qWNLzK4orzi8cI3qwhVQ9r5Iy2rH4j2E1hG4GTT/3FV7FNWUKpBWe4SK8QLq3zWJ X-Received: by 2002:a50:f04e:: with SMTP id u14mr31485682edl.247.1568130486949; Tue, 10 Sep 2019 08:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568130486; cv=none; d=google.com; s=arc-20160816; b=kXcN5i/jmezACPz9hjVU4Y9lXPpvJVDPlI9W8v4QSuE1zsLAbI7TbfR2MzEBJd9bTM Yq8NljpCflDBfwIyhPVgwIVYgILt3DqB9QsPFYzRdT51rk0pbJLlGsJaga9vBHn/fo/B mY2k2LeQL9JyeLbisg5pXBlR+E8J2hmNcfXxjcvtQ5Yw37SBawpRYztry8IuPfwmhIkn E6jRLOONt6DnMxxuGqh+71Xkx82eJFsBD7aJsCQbc6/coJgrzLrMOnYZMECRYWlQPu7M UeHhUYYqNn1Dbc1AE+1shgGY88FGYs3Vwnd/PhdjA+ZCKk+rjfrDDnKofqfcTX0QN6vl pQlg== 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 :in-reply-to:references:mime-version:dkim-signature; bh=ab44L4UsH9lWBk/ePs+t6LQUuKmRHFW0SwCWgf68+rc=; b=1KGsvTUBVXAxP837u40ML7KdqSgevKRVG4NE7FacZdvswkFk2Ujc1L81p5BoUgq1Tz VjkON1XBMupGRMkU/3Yvaxhnay/0BMbqR41Csw/GZE+0oOacyHC+QUDoF0oyd0UkRdZg euX42JlZxR6SzeRZyYrbIWr4hsl24GF8Hhkoy/65/Nn0v+NvL2IRERv+AO8B4ROzZTzS CNFUPiZliEETl2wj9BnZg85hXCzq7/q15C9DhVV2iioLG6ZfS3asqRUCMFPYocMo6Aky wD54STkP/H2LYPkhqqHBW0TD1CR2Hz4rR17ybCWK9aUwFzGOB06wVz5bk0BmZfO45JJa LSiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FUDx1Vss; 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 l15si9084369ejd.127.2019.09.10.08.47.42; Tue, 10 Sep 2019 08:48:06 -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=pass header.i=@gmail.com header.s=20161025 header.b=FUDx1Vss; 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 S2436578AbfIJPpl (ORCPT + 99 others); Tue, 10 Sep 2019 11:45:41 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:41223 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbfIJPpk (ORCPT ); Tue, 10 Sep 2019 11:45:40 -0400 Received: by mail-ed1-f67.google.com with SMTP id z9so17554148edq.8; Tue, 10 Sep 2019 08:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ab44L4UsH9lWBk/ePs+t6LQUuKmRHFW0SwCWgf68+rc=; b=FUDx1VssMY5+grYTJ9mTO+OtexdcbSTMSsn3//VPNV0zPdSp95pA3zNOdpx4boIzLL +8wfwTnUnSWaD0DyKayLxvtLd1DNtf9KpsXdscr1lunnkyj9RgO10ZaIY4qDgscT06xv gsu7UNxm0Xryuv9rrw5a4GpIEVPRKWhPVPWKzBpbTQx6lkHw+mIFYb+srXGudTMQJCt5 gonRN5rE57R/vyk+7sS8MiPSdeYzF3ZPo7wNMrmBj3lVkr6zixiEP6LKYNeZGu9gq5mv nhhDZVq5ROoxeNpfmQu0BO+jdHGVOWyuw0NkkZqryUCoeygfaKH+6X5QUf5q5jC92gdh i8nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ab44L4UsH9lWBk/ePs+t6LQUuKmRHFW0SwCWgf68+rc=; b=Es2qF/PBt86WViNHx5n1wadDtRjmQoaA+GpjzHtD0+mZGww26rr0GqG6hVJLPgpNGY igaZU0Z3wdB+SqSQ+/ESQb/8FoN9shxzLkKTthuTGCosuMJr04PbGINwu12HnMJHUI4W YkDXFwLz/whOmCtVIe23FU0wnWCYhHSnSHFJRgYq60SZTclvyel632ufHsdg8Iswz1Cw tejkec4dNsbjSFt5TlYar5gfoJQ1hsyPUaps6qlVJz4F/RjnfdnAZAwX7nUqx0kO+RpN CTFrjAutoFQhPb9CiF7GcJkIdLl6eWvPYa0zmOr9s/XXoDlQPFWYOUsvqmdr9klOGLvE ZyYg== X-Gm-Message-State: APjAAAVTvQKHFbwU2miQMHe4YwJlOj1xL0mvMkBZYcxZ/abR6CES7J3e 0LNxNEHvVvEMXuqL5HWzwCD8d0rAlhBb7pD+HOibdQfY X-Received: by 2002:a17:906:2451:: with SMTP id a17mr16927007ejb.164.1568130338310; Tue, 10 Sep 2019 08:45:38 -0700 (PDT) MIME-Version: 1.0 References: <20190907175013.24246-1-robdclark@gmail.com> <418d8426-f299-1269-2b2e-f86677cf22c2@arm.com> In-Reply-To: <418d8426-f299-1269-2b2e-f86677cf22c2@arm.com> From: Rob Clark Date: Tue, 10 Sep 2019 08:45:27 -0700 Message-ID: Subject: Re: [PATCH] iommu/arm-smmu: fix "hang" when games exit To: Robin Murphy Cc: "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , linux-arm-msm , freedreno , Rob Clark , Will Deacon , Joerg Roedel , "moderated list:ARM SMMU DRIVERS" , open list , Jordan Crouse 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 Tue, Sep 10, 2019 at 8:01 AM Robin Murphy wrote: > > On 07/09/2019 18:50, Rob Clark wrote: > > From: Rob Clark > > > > When games, browser, or anything using a lot of GPU buffers exits, there > > can be many hundreds or thousands of buffers to unmap and free. If the > > GPU is otherwise suspended, this can cause arm-smmu to resume/suspend > > for each buffer, resulting 5-10 seconds worth of reprogramming the > > context bank (arm_smmu_write_context_bank()/arm_smmu_write_s2cr()/etc). > > To the user it would appear that the system is locked up. > > > > A simple solution is to use pm_runtime_put_autosuspend() instead, so we > > don't immediately suspend the SMMU device. > > > > Signed-off-by: Rob Clark > > --- > > Note: I've tied the autosuspend enable/delay to the consumer device, > > based on the reasoning that if the consumer device benefits from using > > an autosuspend delay, then it's corresponding SMMU probably does too. > > Maybe that is overkill and we should just unconditionally enable > > autosuspend. > > I'm not sure there's really any reason to expect that a supplier's usage > model when doing things for itself bears any relation to that of its > consumer(s), so I'd certainly lean towards the "unconditional" argument > myself. Sounds good, I'll respin w/ unconditional autosuspend > Of course ideally we'd skip resuming altogether in the map/unmap paths > (since resume implies a full TLB reset anyway), but IIRC that approach > started to get messy in the context of the initial RPM patchset. I'm > planning to fiddle around a bit more to clean up the implementation of > the new iommu_flush_ops stuff, so I've made a note to myself to revisit > RPM to see if there's a sufficiently clean way to do better. In the > meantime, though, I don't have any real objection to using some > reasonable autosuspend delay on the principle that if we've been woken > up to map/unmap one page, there's a high likelihood that more will > follow in short order (and in the configuration slow-paths it won't have > much impact either way). It does sort of remind me about something I was chatting with Jordan the other day.. about how we could possibly skip the TLB inv for unmaps from non-current pagetables once we have per-context pagetables. The challenge is, since the GPU's command parser is the one switching pagetables, we don't have any race-free way to know which pagetables are current. But we do know which contexts have work queued up for the GPU, so we can know either that a given context definitely isn't current, or that it might be current. And in the "definitely not current" case we could skip TLB inv. BR, -R > > Robin. > > > drivers/iommu/arm-smmu.c | 11 ++++++++++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > > index c2733b447d9c..73a0dd53c8a3 100644 > > --- a/drivers/iommu/arm-smmu.c > > +++ b/drivers/iommu/arm-smmu.c > > @@ -289,7 +289,7 @@ static inline int arm_smmu_rpm_get(struct arm_smmu_device *smmu) > > static inline void arm_smmu_rpm_put(struct arm_smmu_device *smmu) > > { > > if (pm_runtime_enabled(smmu->dev)) > > - pm_runtime_put(smmu->dev); > > + pm_runtime_put_autosuspend(smmu->dev); > > } > > > > static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom) > > @@ -1445,6 +1445,15 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) > > /* Looks ok, so add the device to the domain */ > > ret = arm_smmu_domain_add_master(smmu_domain, fwspec); > > > > +#ifdef CONFIG_PM > > + /* TODO maybe device_link_add() should do this for us? */ > > + if (dev->power.use_autosuspend) { > > + pm_runtime_set_autosuspend_delay(smmu->dev, > > + dev->power.autosuspend_delay); > > + pm_runtime_use_autosuspend(smmu->dev); > > + } > > +#endif > > + > > rpm_put: > > arm_smmu_rpm_put(smmu); > > return ret; > >