Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4473257rwb; Mon, 31 Jul 2023 07:25:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlEa9oWsqR/gdNLX+E2+w6+aLDftl9J9RmACD6cwbJmTPEJLsftWx8u5pndH7m6QpiwEOWUa X-Received: by 2002:a17:902:ec83:b0:1bb:cf4e:ccd with SMTP id x3-20020a170902ec8300b001bbcf4e0ccdmr12751090plg.28.1690813542633; Mon, 31 Jul 2023 07:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690813542; cv=none; d=google.com; s=arc-20160816; b=svDpE1g2/sj7+1s6zBJu+basiMOEJSa+6Yea34YYsfMag2WfOLYlSjEhfHxbOY+JU5 17n657DuiKfRoWTUAby+dSqEJ+OYqLmdtRWfHaUmd//Edcswrk2d0f75ThzkK6+osrr1 uZwtI2pc8TITGMyc0E5L6mYLUXyhyEWru9rMOnLoTOzVeilR4Ml7kij358RxzI2FCyuY RgWaogISFCZTKpmiSxHhd21ILwYAugZIEB/3VUs5oZPdCbQ9+JIKm85QQf5sbkxWj/3q zDnE+t0ZOjNDra1r/LEs1FZ8IO3Z0/2OVKHdhUXX2sNL1h3l2lWUfZsuDF8AkJgah3BX SYhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=zGpcJfkfjrP+UEv3+VloX4hJvyuNXfoQlRcNq7glT5Q=; fh=jp/QT6rM4jIadluUlVccuEMc2Zls6Pk7I2HOs7YhBIM=; b=VqdmA3M6lpnmsT4nAeok0DzIIUKs9/xGIwOlA+VWaTs5n8r3J8SY+TVLzBzNNZ6NWz sJtd7J9x+SOJq2u22qxlsolfrwvBrYQxuBhWbGhSG4g0KHsw+wRipeGvhSbqN9FQ9qOm EBi7fuBnUjmbTv9bOrZIE7LL3y5OOJd+WPWXqogfMFPKKSycUJR1UF/nHz2DfrxGQkaU Sc+ejmNfAYJLOkmDjyqtTnJABrdhp0LX9LSp3KElttE9Ltr6Lv4tCxMv4pgzAwjKjy1P flS/vPlVTvw//Lhk9Z7elNlx2HnLy10+v6tMIV5n+eSVDIb4d29wsHJhzOZo6f2+SWwH NsCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="jGdzaE/K"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a170903019000b001b9d2659694si7817082plg.270.2023.07.31.07.25.29; Mon, 31 Jul 2023 07:25:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="jGdzaE/K"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjGaMbc (ORCPT + 99 others); Mon, 31 Jul 2023 08:31:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbjGaMbb (ORCPT ); Mon, 31 Jul 2023 08:31:31 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC0F7B2 for ; Mon, 31 Jul 2023 05:31:30 -0700 (PDT) Received: from [192.168.2.174] (109-252-150-127.dynamic.spd-mgts.ru [109.252.150.127]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id 3665C6600357; Mon, 31 Jul 2023 13:31:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690806689; bh=uU9TE+QLz19uvUZurU8HLJAokwEE/NyJV1JP8aJE7Q8=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=jGdzaE/K4vcru342F4pVcqyo3uHT6ZQGWOB3RZlT908tYxz1BRt6sNaEeXxGAlr1Z MCXlxmxxKYemkSHuo1IOqatIempLL2M6NdfejoSsXUtLVn6dNd83an3p6XRYzgHO0y mNn3FyECXCG965wkM7m3iA9dZttOeoFwQEC88a4cTtBFX5iczxDx4iamWLDNDyNlHs Ha0YNH/SzGFbZ35p5L12qiSgPknErRsfaNnnX2GyoGN+0BX9gPmgGQ7EYcSx9Ds+3m /b2XpjewiTSLB5vxbFBcfiRnSAUVOt39v6YxePinpeMauzVswP1B0UrX2ovE1IHyK3 9ReNENytIfyOw== Message-ID: Date: Mon, 31 Jul 2023 15:31:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.1 Subject: Re: [PATCH v14 02/12] drm/shmem-helper: Add pages_pin_count field Content-Language: en-US From: Dmitry Osipenko To: Boris Brezillon Cc: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , =?UTF-8?Q?Christian_K=c3=b6nig?= , Qiang Yu , Steven Price , Emma Anholt , Melissa Wen , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org References: <20230722234746.205949-1-dmitry.osipenko@collabora.com> <20230722234746.205949-3-dmitry.osipenko@collabora.com> <20230725092709.51356f39@collabora.com> <20230725103234.0c8923f1@collabora.com> <4c5fa735-9bfd-f92a-8deb-888c7368f89e@collabora.com> In-Reply-To: <4c5fa735-9bfd-f92a-8deb-888c7368f89e@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/31/23 15:27, Dmitry Osipenko wrote: > On 7/25/23 11:32, Boris Brezillon wrote: >>> Can we make it an atomic_t, so we can avoid taking the lock when the >>> GEM has already been pinned. That's something I need to be able to grab >>> a pin-ref in a path where the GEM resv lock is already held[1]. We could >>> of course expose the locked version, >> My bad, that's actually not true. The problem is not that I call >> drm_gem_shmem_pin() with the resv lock already held, but that I call >> drm_gem_shmem_pin() in a dma-signaling path where I'm not allowed to >> take a resv lock. I know for sure pin_count > 0, because all GEM objects >> mapped to a VM have their memory pinned right now, and this should >> stand until we decide to add support for live-GEM eviction, at which >> point we'll probably have a way to detect when a GEM is evicted, and >> avoid calling drm_gem_shmem_pin() on it. >> >> TLDR; I can't trade the atomic_t for a drm_gem_shmem_pin_locked(), >> because that wouldn't solve my problem. The other solution would be to >> add an atomic_t at the driver-GEM level, and only call >> drm_gem_shmem_[un]pin() on 0 <-> 1 transitions, but I thought using an >> atomic at the GEM-shmem level, to avoid locking when we can, would be >> beneficial to the rest of the eco-system. Let me know if that's not an >> option, and I'll go back to the driver-specific atomic_t. > > Could you please explain why do you need to pin GEM in a signal handler? > This is not something drivers usually do or need to do. You likely also > shouldn't need to detect that GEM is evicted in yours driver. I'd expect > that Panthor shouldn't differ from Panfrost in regards to how GEM memory > management is done and Panfrost doesn't need to do anything special. > > Note that patch #14 makes locked pin/unpin functions public and turns > the unlocked variants into helpers, you'll be able to experiment with > these funcs in the Panthor driver. correction: that's patch #10 > In general, using atomic_t or kref should be a good thing to do, but > AFAICS it shouldn't bring benefits to the today's drm-shmem users. I'd > want to understand what you're trying to achieve in the Panthor driver. > -- Best regards, Dmitry