Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2389598rdd; Fri, 12 Jan 2024 08:03:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPLxqSOvr0q2zlav4twgnlGksHJAX111oWVMMiqjt77zYk6tSuL4a+2hodMhQmTkuHzTD4 X-Received: by 2002:a17:906:344e:b0:a29:7fa9:b8b7 with SMTP id d14-20020a170906344e00b00a297fa9b8b7mr677958ejb.121.1705075424340; Fri, 12 Jan 2024 08:03:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705075424; cv=none; d=google.com; s=arc-20160816; b=BtiLVs2u3PGJYBmJzdZOvKxN/r7kfRARv34ZVdYYLG64aTqTRfDjwrsjX2qSNS0UJr g9Cwo0ApynugrlUev6wok8ZBCJ45geu5KnEaYx4H1p1+Sd6MJaQv3tTdFLXG/uHa/paj 1VfEqzDzWZRmhQkCOtUT1UVAjDfKqq5YbC5tMJOaK3zcUhwiTWHi6r4MWpc/lbM49CFe ZYZQnoBF/HJMmU8gbza8jUBCvan9Qh991Lozfe+O6HxUL1ElLCHKcRgMMPjPa53z4os7 muQ7YSMGW4Oy7QqpRsqE9IzFd7o+OkjeICBQCi18k+Z5sXPsVI8HIY/qyutyg+emdyPX 3auQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:subject:cc:to:from:date:dkim-signature; bh=Sura8BN22zg2t3UmUSPmhW9PvZc+BhIUfUMl1ulMd8s=; fh=Sl/Df66lPjsLgxNRPzdYuaFKWvNfDFhMCM6+SXYkmiU=; b=BfPsgTz6YkRKCkorA9xRLyW7DBLyYPrp1xu38bV01UqTPQY+OKxJmWaclG+o4fsC17 YwR1nx44lqiqi6ysZswpn7g91KuT3BHzObHiT+dSwzdg3hO5tQ1JK0P7K9TtOR+WXWv0 u2btatHg05FcqPdO23mQBz4PGt8l/YkdL7wMhLNcShm/lFyjU9AEmwsTVLjBpO/fDHk6 oMVEzco0vIfGfX+Yd5qbF0t1beUbfEzBZxu/xPSBz45x8QbZsz8ZNsBLgR4ysCWugTET v0Tf+owtXQtmfvauai0ZjBAk9e8iiDppO003N6ju8058Dp9ZCvwLeVkqyweBS1GEMWPr etuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@redhat.com header.s=mimecast20190719 header.b=fNIxFy0M; spf=pass (google.com: domain of linux-kernel+bounces-24838-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24838-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n21-20020a170906b31500b00a2693d8ec4esi1527391ejz.858.2024.01.12.08.03.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 08:03:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24838-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@redhat.com header.s=mimecast20190719 header.b=fNIxFy0M; spf=pass (google.com: domain of linux-kernel+bounces-24838-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24838-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id A04341F25619 for ; Fri, 12 Jan 2024 16:03:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EB4473163; Fri, 12 Jan 2024 16:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fNIxFy0M" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 896341D53F for ; Fri, 12 Jan 2024 16:03:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705075410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=eM/q6+ASudnWqkA1GcXB1FCKeCcpDQUk18zBNzi9GWQ=; b=fNIxFy0MwAQwlQM4g38cFwoBBgENnRSpUJuUTGVpN2icgkAd8kakKNrFUo3LnJYZxsT7PQ Pd3Ei1T9Q8ulJMOmngUIyPrnVUEFKNJ5Hdcn3BQR5CfAey20uyyjR4YbgbeP3UaKIaJwTn zUgxxDciwSFLn+Td6Y8la7HRSnF7w9A= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-424-uh3MCDPtP5-iPJetD9ZVNQ-1; Fri, 12 Jan 2024 11:03:29 -0500 X-MC-Unique: uh3MCDPtP5-iPJetD9ZVNQ-1 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-1d3e569ba83so52585325ad.0 for ; Fri, 12 Jan 2024 08:03:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705075408; x=1705680208; h=mime-version:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eM/q6+ASudnWqkA1GcXB1FCKeCcpDQUk18zBNzi9GWQ=; b=BHdLiSCdjiRdt86imhBzsip5+KqDMI1B8vi7DEfqer3AyQqFKofB4f1B+Gwfu0wTmy hDfLOT1wDAhvHwf6k6Qp4CgX1rVGLDURAjCtx5GvtRJOQncRTV9Gqpmx9MDaDgdM03mY p8ViaffGMQlhz2w9R6y5CnbPUwt8nYa3SeXxTG8/I9pw1OqnimO/pZ/sDFSPuklUH0Fy J77+w7TXuore4k8UYBy0iUGrrJ9XAUvD6N7+1anNxkEorG/sBUOMmH76baLVTmru3sIH 11xff9z+QaD7yJ73pjNRDaVmwuHB4xwUlZWKYnpOrC0IRWglh7t2botOnyjQzi66yQtW UVPg== X-Gm-Message-State: AOJu0YyIQQEMFZNh5r0UMkmzZnb5HeDpZ5j8SyoxTXNvyWUB6uImvcKb BO86QJwco69XxYorp9w4sOLiJMGcMbwMiGOyHtKNLhu1HgQj84GjSmY49n1Ht0lSKW1ZYANVrcK VWmGLt63K5KM1p88Eo1nn1FCc7httUE8a X-Received: by 2002:a17:902:e54b:b0:1d3:7368:663 with SMTP id n11-20020a170902e54b00b001d373680663mr1899473plf.7.1705075407984; Fri, 12 Jan 2024 08:03:27 -0800 (PST) X-Received: by 2002:a17:902:e54b:b0:1d3:7368:663 with SMTP id n11-20020a170902e54b00b001d373680663mr1899454plf.7.1705075407622; Fri, 12 Jan 2024 08:03:27 -0800 (PST) Received: from rh (p200300c93f0273004f0fe90936098834.dip0.t-ipconnect.de. [2003:c9:3f02:7300:4f0f:e909:3609:8834]) by smtp.gmail.com with ESMTPSA id g11-20020a170902c98b00b001d4c97a2adcsm3319022plc.108.2024.01.12.08.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 08:03:27 -0800 (PST) Date: Fri, 12 Jan 2024 17:03:17 +0100 (CET) From: Sebastian Ott To: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org cc: David Airlie , Gerd Hoffmann , Daniel Vetter Subject: [PATCH] drm/virtio: set segment size for virtio_gpu device Message-ID: <29a2b89d-7bf0-9dcb-5208-cd8e7d26e2f2@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Hej, debug dma code is not happy with virtio gpu (arm64 VM): [ 305.881733] ------------[ cut here ]------------ [ 305.883117] DMA-API: virtio-pci 0000:07:00.0: mapping sg segment longer than device claims to support [len=262144] [max=65536] [ 305.885976] WARNING: CPU: 8 PID: 2002 at kernel/dma/debug.c:1177 check_sg_segment+0x2d0/0x420 [ 305.888038] Modules linked in: crct10dif_ce(+) polyval_ce polyval_generic ghash_ce virtio_gpu(+) virtio_net net_failover virtio_blk(+) virtio_dma_buf virtio_console failover virtio_mmio scsi_dh_r dac scsi_dh_emc scsi_dh_alua dm_multipath qemu_fw_cfg [ 305.893496] CPU: 8 PID: 2002 Comm: (udev-worker) Not tainted 6.7.0 #1 [ 305.895070] Hardware name: QEMU KVM Virtual Machine, BIOS edk2-20230524-3.fc37 05/24/2023 [ 305.897112] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 305.897129] pc : check_sg_segment+0x2d0/0x420 [ 305.897139] lr : check_sg_segment+0x2d0/0x420 [ 305.897145] sp : ffff80008ffc69d0 [ 305.897149] x29: ffff80008ffc69d0 x28: dfff800000000000 x27: ffffb0232879e578 [ 305.897167] x26: ffffffff00000000 x25: ffffb0232778c060 x24: ffff19ee9b2060c0 [ 305.897181] x23: 00000000ffffffff x22: ffffb0232ab9ce10 x21: ffff19eece5c64ac [ 305.906942] x20: 0000000000010000 x19: ffff19eece5c64a0 x18: ffff19eec36fc304 [ 305.908633] x17: 6e61687420726567 x16: 6e6f6c20746e656d x15: 6765732067732067 [ 305.910352] x14: 00000000f1f1f1f1 x13: 0000000000000001 x12: ffff700011ff8cc3 [ 305.912044] x11: 1ffff00011ff8cc2 x10: ffff700011ff8cc2 x9 : ffffb02324a70e54 [ 305.913751] x8 : 00008fffee00733e x7 : ffff80008ffc6617 x6 : 0000000000000001 [ 305.915451] x5 : ffff80008ffc6610 x4 : 1fffe33e70564622 x3 : dfff800000000000 [ 305.917158] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff19f382b23100 [ 305.918864] Call trace: [ 305.919474] check_sg_segment+0x2d0/0x420 [ 305.920443] debug_dma_map_sg+0x2a0/0x428 [ 305.921402] __dma_map_sg_attrs+0xf4/0x1a8 [ 305.922388] dma_map_sgtable+0x7c/0x100 [ 305.923318] drm_gem_shmem_get_pages_sgt+0x15c/0x328 [ 305.924500] virtio_gpu_object_shmem_init.constprop.0.isra.0+0x50/0x628 [virtio_gpu] [ 305.926390] virtio_gpu_object_create+0x198/0x478 [virtio_gpu] [ 305.927802] virtio_gpu_mode_dumb_create+0x2a0/0x4c8 [virtio_gpu] [ 305.929272] drm_mode_create_dumb+0x1c0/0x280 [ 305.930327] drm_client_framebuffer_create+0x140/0x328 [ 305.931555] drm_fbdev_generic_helper_fb_probe+0x1bc/0x5c0 [ 305.932871] __drm_fb_helper_initial_config_and_unlock+0x1e0/0x630 [ 305.934372] drm_fb_helper_initial_config+0x50/0x68 [ 305.935540] drm_fbdev_generic_client_hotplug+0x148/0x200 [ 305.936819] drm_client_register+0x130/0x200 [ 305.937856] drm_fbdev_generic_setup+0xe8/0x320 [ 305.938932] virtio_gpu_probe+0x13c/0x2d0 [virtio_gpu] [ 305.940190] virtio_dev_probe+0x38c/0x600 [ 305.941153] really_probe+0x334/0x9c8 [ 305.942047] __driver_probe_device+0x164/0x3d8 [ 305.943102] driver_probe_device+0x64/0x180 [ 305.944094] __driver_attach+0x1d4/0x488 [ 305.945045] bus_for_each_dev+0x104/0x198 [ 305.946008] driver_attach+0x44/0x68 [ 305.946892] bus_add_driver+0x23c/0x4a8 [ 305.947838] driver_register+0xf8/0x3d0 [ 305.948770] register_virtio_driver+0x74/0xc8 [ 305.949836] virtio_gpu_driver_init+0x20/0xff8 [virtio_gpu] [ 305.951237] do_one_initcall+0x17c/0x8c0 [ 305.952182] do_init_module+0x1dc/0x630 [ 305.953106] load_module+0x10c0/0x1638 [ 305.954012] init_module_from_file+0xe0/0x140 [ 305.955058] idempotent_init_module+0x2c0/0x590 [ 305.956174] __arm64_sys_finit_module+0xb4/0x140 [ 305.957282] invoke_syscall+0xd8/0x258 [ 305.958187] el0_svc_common.constprop.0+0x16c/0x240 [ 305.959526] do_el0_svc+0x48/0x68 [ 305.960456] el0_svc+0x58/0x118 [ 305.961310] el0t_64_sync_handler+0x120/0x130 [ 305.962510] el0t_64_sync+0x194/0x198 [ 305.963509] irq event stamp: 37944 [ 305.964412] hardirqs last enabled at (37943): [] console_unlock+0x1a4/0x1c8 [ 305.966602] hardirqs last disabled at (37944): [] el1_dbg+0x24/0xa0 [ 305.968535] softirqs last enabled at (37930): [] __do_softirq+0x8e4/0xe1c [ 305.970781] softirqs last disabled at (37925): [] ____do_softirq+0x18/0x30 [ 305.972937] ---[ end trace 0000000000000000 ]--- The 64K max_segment size of the device seems to be inherited by PCIs default. The sg list is crated via this drm helper: struct sg_table *drm_prime_pages_to_sg(struct drm_device *dev, struct page **pages, unsigned int nr_pages) { .. if (dev) max_segment = dma_max_mapping_size(dev->dev); if (max_segment == 0) max_segment = UINT_MAX; err = sg_alloc_table_from_pages_segment(sg, pages, nr_pages, 0, nr_pages << PAGE_SHIFT, max_segment, GFP_KERNEL); .. } I'm a bit puzzled why this uses dma_max_mapping_size() and not dma_get_max_seg_size(). But since this is used by a lot of drivers I'm not really keen to touch this code that works like this for ages. So let's just make debug dma code aware of the actual segment size that's used by the device: --->8 drm/virtio: set segment size for virtio_gpu device Set the segment size of the virtio_gpu device to the value used by the drm helpers when allocating sg lists to fix the following complaint from DMA_API debug code: DMA-API: virtio-pci 0000:07:00.0: mapping sg segment longer than device claims to support [len=262144] [max=65536] Signed-off-by: Sebastian Ott --- drivers/gpu/drm/virtio/virtgpu_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index 4334c7608408..74b2cb3295af 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -94,6 +94,7 @@ static int virtio_gpu_probe(struct virtio_device *vdev) goto err_free; } + dma_set_max_seg_size(dev->dev, dma_max_mapping_size(dev->dev) ? : UINT_MAX); ret = virtio_gpu_init(vdev, dev); if (ret) goto err_free; -- 2.43.0