Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp603116lqp; Wed, 12 Jun 2024 10:28:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaI0CRGcEaMsW9XxBXwNnPT/SpWoBh5T8FN8ltDCdp4vs5cM43a6zYdyyqcDcqvhw6iAweU5jZXJWf2np5rcdA5T/WcKGdIL0rGLTsmA== X-Google-Smtp-Source: AGHT+IGSWeu4MKWy4sPDBk0odPOghzrYRA31xGo7JEGyf2WwwtcoQExH1cMWGL4ScAMpxFcQWsNn X-Received: by 2002:a05:6214:4497:b0:6b0:6ad8:ebd8 with SMTP id 6a1803df08f44-6b1910c1cadmr28617276d6.7.1718213319462; Wed, 12 Jun 2024 10:28:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718213319; cv=pass; d=google.com; s=arc-20160816; b=JctdAt/d+d9l8U9ECAvgmkyBpIZy6vOq6U6rDiktHUp1a5B4mYghx1yHDb18bTgVzv SR8MQifb6W/n6Sf9tfB+CaLrD//b4TmSmpRuF+G7P2XTwhe2sy4e1NRwrtTn5F83uwWf ERuOuJc9zEg5M696wQjdyEl1oTv5cQD2LwqnZOOdeSu9eAIGGJgIIUHdpupf63wPzQCZ SK1kTVNdcDZ7qNWvWBKiDO2VFlHZ5HBJo4Hl87NcsGEI3UU9zL6tZUiw2oqVRPvFsXm9 T3MwpS+dOr2/qv4mnmBrOlzCzIQn15snkgiU6kSERPg3GDzBp2aKXItITfRgPIXKVuRp zgBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Vga4bYp9jxqSv9eCBMzwANuaNkrPnKBob/TvPmGImHU=; fh=Q2mErxQOVPpzpaKWP3GsPY01581B78vE4k1gZagex7k=; b=QwhcACfz70ouTme5M50MyGVKWHPK/IxEVEYviEa0288KDSy6l0aXCxsmolsf+mg/5Y 8Wjd5WVdBY+MpEs0YAXhgeoYTXuOylU9dzS8zc6Ar668IVvcQC6L/Ug1umfOSkClkVg9 +Q+K8jLsyioyOhpsg0+rG89i58RxewI3ABy51TvuzzbA4zgvK3d3F36u9q959odZ8NbH awkquOiqmKgJFtnWHis9MZyElGZzEExv4SqqF0h2v2M7I4YvtbssJHuVoS1h0zwR92b6 G5W7iKAY5J+dzVIPDOevlghNHPQcgRqClXqSvhpVqQAYYFrhWoQbc9bIo3pqY4Jou6uW Pd+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=LRd3yhTA; arc=pass (i=1 dkim=pass dkdomain=ffwll.ch); spf=pass (google.com: domain of linux-kernel+bounces-211732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211732-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b04f63c7e0si119906886d6.21.2024.06.12.10.28.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 10:28:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=LRd3yhTA; arc=pass (i=1 dkim=pass dkdomain=ffwll.ch); spf=pass (google.com: domain of linux-kernel+bounces-211732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211732-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 867171C24978 for ; Wed, 12 Jun 2024 15:02:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D27617F387; Wed, 12 Jun 2024 15:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="LRd3yhTA" Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A47E1DDF6 for ; Wed, 12 Jun 2024 15:00:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204451; cv=none; b=UEB3Adsg8KDZ7GPiWQqedjYXRHLV+rBPXX0FC/7TcoarUAT5hVMLgJTIzCvu92cCuNTJk69iuZIBjbN6OWXulZ9ZlDe/egS+YwbQ6y6nq0Qp/8oW+BT6E6TrTCpCxVDfy6jiEQ2/QB12/wfvyl67xPnn9I/o6ILnn+yas3iZIMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204451; c=relaxed/simple; bh=Tn8E0RJxVE72zdWYPLEmPNrIueTtsug4CMVf4uXYplM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JMbOIWhkO+sjRUfAV4y3pIAyiOJLtt4NSEaDzHcnxKeiH2uWlImFMGjzoYG9jlQmilRDJG+TQ9Ognb5sgW64zwknUxNOVMyub25zujrxuhmRgc3pEBGCHjA17b4trbJq2g1WkTywTr2tB6+dejpKHMFDZsMy8GLJ7SepHj6LUcU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch; spf=none smtp.mailfrom=ffwll.ch; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b=LRd3yhTA; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-35f0b9a1dd7so684939f8f.0 for ; Wed, 12 Jun 2024 08:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1718204448; x=1718809248; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:from:to:cc:subject:date:message-id:reply-to; bh=Vga4bYp9jxqSv9eCBMzwANuaNkrPnKBob/TvPmGImHU=; b=LRd3yhTAvWlO5g1OqGrjXf99GDXXQHdAeKDIu9jsNC21UjZyZY5RPg0/ju+cp5BE0c U/kylHsIVRXTTtueFVR8/e2PLuown7fdYl36THduqooJFe/OYBx3BVCf8r2/TTNn2EE2 t7hucqY9ui+2UyGekTmqXHz5HJz1JT5oeykBU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718204448; x=1718809248; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Vga4bYp9jxqSv9eCBMzwANuaNkrPnKBob/TvPmGImHU=; b=r5CB1k/2q6WWZj5qfQZyhX5mNJp2GQVQNfmJtMqlhhnMu7uYa0o307G15ZyAIhPqPt M4dG0zLPzHBapDRvoQV4otTKRcWhYn9AqqY/M0rPi8Ja6g3E9Dal+fsSDcuG2xru7QMt ZDUFWvKtBI4Bk/33JME1WzJXP5MNAWxqdyKhssawfjdYQqPJHHiRVCFH288Mu7xUfRtP imb6Ji+xJmO1TY2/ndt6uRmvFdTKZKspwnPIp6my4g9Lf1pa8H35DBXjsZNxq+kkgxvH +VMM98aazk590D2bkCL/FuwOAIVs4cl1qvMBDBgOdN3QP44KCrZfyNSi1Hyi5uKApb7B C9kA== X-Forwarded-Encrypted: i=1; AJvYcCVgDrfDnbhc0wNfqePjVkJC/CXZRt/2/fZVgtLyH3RJBBwKKdWjRHfSkEGKL89b1K4rOpkJBSJoA2VXPoI=@vger.kernel.org X-Gm-Message-State: AOJu0YxrDSxp7SZ7HQ/V2TxsZqVe17R/q/rHrSSf0qjJWTFhvgFsLLiF gIGea0SPCqCF52aIvJBIiBKXsmTqtjFK4ZGPYamO4yr2lTk1bYXs1xwBIxXeEGc= X-Received: by 2002:a5d:59a1:0:b0:35f:2f97:e890 with SMTP id ffacd0b85a97d-35fd4b30419mr1419392f8f.0.1718204447552; Wed, 12 Jun 2024 08:00:47 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f25aa8fb6sm7982282f8f.92.2024.06.12.08.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 08:00:47 -0700 (PDT) Date: Wed, 12 Jun 2024 17:00:45 +0200 From: Daniel Vetter To: Thomas Zimmermann Cc: Javier Martinez Canillas , "Peng Fan (OSS)" , Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , Peng Fan , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/fbdev-dma: fix getting smem_start Message-ID: Mail-Followup-To: Thomas Zimmermann , Javier Martinez Canillas , "Peng Fan (OSS)" , Maarten Lankhorst , Maxime Ripard , David Airlie , Peng Fan , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20240604080328.4024838-1-peng.fan@oss.nxp.com> <8f4a6d80-dd3e-422f-88af-d26f50c973ff@suse.de> <87cyomsiqt.fsf@minerva.mail-host-address-is-not-set> <14a7c534-af3f-43b8-a24c-501a9af97936@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <14a7c534-af3f-43b8-a24c-501a9af97936@suse.de> X-Operating-System: Linux phenom 6.8.9-amd64 On Wed, Jun 12, 2024 at 10:37:14AM +0200, Thomas Zimmermann wrote: > Hi Javier > > Am 12.06.24 um 09:49 schrieb Javier Martinez Canillas: > > Thomas Zimmermann writes: > > > > Hello Thomas, > > > > > Hi > > > > > > Am 10.06.24 um 10:47 schrieb Thomas Zimmermann: > > > > Hi > > > > > > > > Am 04.06.24 um 10:03 schrieb Peng Fan (OSS): > > > > > From: Peng Fan > > > > > > > > > > If 'info->screen_buffer' locates in vmalloc address space, virt_to_page > > > > > will not be able to get correct results. With CONFIG_DEBUG_VM and > > > > > CONFIG_DEBUG_VIRTUAL enabled on ARM64, there is dump below: > > > > Which graphics driver triggers this bug? > > > > > > > > > [??? 3.536043] ------------[ cut here ]------------ > > > > > [??? 3.540716] virt_to_phys used for non-linear address: > > > > > 000000007fc4f540 (0xffff800086001000) > > > > > [??? 3.552628] WARNING: CPU: 4 PID: 61 at arch/arm64/mm/physaddr.c:12 > > > > > __virt_to_phys+0x68/0x98 > > > > > [??? 3.565455] Modules linked in: > > > > > [??? 3.568525] CPU: 4 PID: 61 Comm: kworker/u12:5 Not tainted > > > > > 6.6.23-06226-g4986cc3e1b75-dirty #250 > > > > > [??? 3.577310] Hardware name: NXP i.MX95 19X19 board (DT) > > > > > [??? 3.582452] Workqueue: events_unbound deferred_probe_work_func > > > > > [??? 3.588291] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS > > > > > BTYPE=--) > > > > > [??? 3.595233] pc : __virt_to_phys+0x68/0x98 > > > > > [??? 3.599246] lr : __virt_to_phys+0x68/0x98 > > > > > [??? 3.603276] sp : ffff800083603990 > > > > > [??? 3.677939] Call trace: > > > > > [??? 3.680393]? __virt_to_phys+0x68/0x98 > > > > > [??? 3.684067]? drm_fbdev_dma_helper_fb_probe+0x138/0x238 > > > > > [??? 3.689214] __drm_fb_helper_initial_config_and_unlock+0x2b0/0x4c0 > > > > > [??? 3.695385]? drm_fb_helper_initial_config+0x4c/0x68 > > > > > [??? 3.700264]? drm_fbdev_dma_client_hotplug+0x8c/0xe0 > > > > > [??? 3.705161]? drm_client_register+0x60/0xb0 > > > > > [??? 3.709269]? drm_fbdev_dma_setup+0x94/0x148 > > > > > > > > > > So add a check 'is_vmalloc_addr'. > > > > > > > > > > Fixes: b79fe9abd58b ("drm/fbdev-dma: Implement fbdev emulation for > > > > > GEM DMA helpers") > > > > > Signed-off-by: Peng Fan > > > > Reviewed-by: Thomas Zimmermann > > > I'm taking back my r-b. The memory is expected to by be physically > > > contiguous and vmalloc() won't guarantee that. > > > > > Agreed. > > These smem_ fields are clearly designed for PCI BARs of traditional graphics > cards. So can we even assume contiguous memory for DMA? That was my > assumption, but with IOMMUs it might not be the case. Fbdev-dma only sets > smem_start to support a single old userspace driver. Maybe we should further > restrict usage of this field by making it opt-in for each driver. Best > regards Thomas We could make it all conditional on CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM, and remove the FBINFO_HIDE_SMEM_START flag. The reason I've done the flag is that with the old fb_mmap code we had to always fill out smem_start to make mmap work. But now that the various drm fbdev helpers have all their own mmap implementation, we could make this a lot cleaner. If I haven't missed anything, that is. -Sima -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch