Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp871504rdd; Wed, 10 Jan 2024 01:57:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuQRJRAJ9XaSIg7bpZTSiziFgl4KAVMPalNSHCPgNXo+4pFe81fElCUXMo6d4uXst616X+ X-Received: by 2002:a17:902:680d:b0:1d5:7a46:91f9 with SMTP id h13-20020a170902680d00b001d57a4691f9mr111253plk.136.1704880678279; Wed, 10 Jan 2024 01:57:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704880678; cv=pass; d=google.com; s=arc-20160816; b=Amf8Yr8iuSb/4zIEHe6XjsN45Q6plt95IX3xTu0if4sZcY2k4fErV206xiN/g37QM9 5X8zTKcGutlgJlq8NI+mQtmcobeIhDymMx/uv3aqYkoEEN4Q64osHQjbuw6SLJcIWnYl BIHkw/h4qPRrbj+j0oHPyLFYDkAxJKwedSk7neyOvqwVAb3Cxv0YwY4gudd+I5ihXJfK OhqNIxpe+nlwmfjoA5ET6pYHJr4/tkQO/662o4+CYo71vH+HeyGxK0jvG8kKXvWB1+QM OWxhga4C8jd+k2OBZmgo6F4lqvjmYudUBU1h5xAz2/SfLbcO07ihDG68jLFeg1ovLYvL /j+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xXMnVkdAg8WfloOGPFMB6DzaP0QH3hdEz7mtCAjvdY4=; fh=74Lq8K8lWzDqSxG6ZW+t5w9VUwYANGhTJV85qw1fTgY=; b=Kt3bMgOdrWftiwXvhySbNHevAU50pqGi4UaxnCerrM1Acdj/EQhWeVBJ/Q1UXQkFdr hrazMsV/yKCXOkkel4xmZMsph9WiRcFkYgHUJFbPq+5l5oK2KqFZi44Z1Tcz6GqivpjQ 582JuB6ciwrw3XBuowjrCzEQ6dOtM8grAD73sfvZY1T5VaGfGtJ/MrAY5Nymx6IjGI7y mpyCC3rdy+5iBH0xF1WDEgzG7ZIxTJVj6qzCkO4sXDyKFJWBeGitry5DPYltSPpAsH70 AridjXJnySiplZq6oZPJNnJ1DGF9dtCGJXn1/Uo0iP+0eeSoh3m43fRmAnA3cn356ZSW nWfA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=uEg2izlF; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel+bounces-21930-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y14-20020a1709027c8e00b001d3c00acddbsi3131006pll.652.2024.01.10.01.57.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 01:57:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21930-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=uEg2izlF; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel+bounces-21930-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E693E285D3F for ; Wed, 10 Jan 2024 09:57:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D0883F8E0; Wed, 10 Jan 2024 09:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uEg2izlF" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2049.outbound.protection.outlook.com [40.107.237.49]) (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 D59E63F8C7 for ; Wed, 10 Jan 2024 09:57:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZtQ0q+HWZGVTJaiGC9gtlWz5o1U4FPY+Wy9gXAyDCtGWfc9AB4TBh013KXntOlKf7AHuYEgD27I2dxcphgp5FBmZR8US3h1+FT8B3aTxaybJVcgeA0QNOrDgHOtV4LF7Inxn8yiHNPlkgX4bTTZiqus5F19+PoenrnC7JAvsAw5+MXnMRT2QxrAdUuOxDPM+k1VoeeSkcbVKhHHoRCOT6X9j9A9PjS1YtR52rtfRQvB65gkvGsaZRD+iQrL8iVwS44MKJ2sY9miWVdPyqwjf6JhU++fKKojP4o351M1jLYtgAinSiov8gNPNYwGmzVjiD8e+TwwO5/JSCpITPZg2+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xXMnVkdAg8WfloOGPFMB6DzaP0QH3hdEz7mtCAjvdY4=; b=P4iCt+aIxhG33XgVkQaBxc7k/ROw+hyNMJHDdisHv5g7Fv5loc2z+ce/0SOpUrfkXiFBEAgkdy2Kk2nGcIdKCeItrPrOa80xAZAC7zOeq2dcNBmDCV7Vq6nxA6iff4FqF/d6tpN61bxr7DlQZvgDyNpSda1GdgE5RfcLSS+b8W96qaWAWNl+bE1E5/R1boKSgN+A8Ah9Nm9Yi8pQHVbc4o9uLcM/5KpKo1svIFd748poeJxdLGi7WPpzfTawqZc8PfJI1MgZZfLyspPWBfoPwr22t2hKnKOSsLDZyZR7oSkDP6T8ogxc/PaaDcddDDJ6UXzo9rbmKHsZUiqzs/4Y2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=chromium.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xXMnVkdAg8WfloOGPFMB6DzaP0QH3hdEz7mtCAjvdY4=; b=uEg2izlF7gy/rWa911JuR9Rbmnfm1PLlWfq0XmTzlBhRzpYe2NMkc9GNm6W52b+DfDt++ErUXC1q7Le4qc3R2kMbtCluYSt+KMAUHfVktIYac7tYliVd/Q7VGle2H3mm9aUvuXklWB5y1wR7G+FACn3SkochNtlrvOqwKPQYNOs= Received: from SJ0PR03CA0175.namprd03.prod.outlook.com (2603:10b6:a03:338::30) by DM6PR12MB4960.namprd12.prod.outlook.com (2603:10b6:5:1bc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Wed, 10 Jan 2024 09:57:28 +0000 Received: from MWH0EPF000971E2.namprd02.prod.outlook.com (2603:10b6:a03:338:cafe::75) by SJ0PR03CA0175.outlook.office365.com (2603:10b6:a03:338::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.18 via Frontend Transport; Wed, 10 Jan 2024 09:57:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000971E2.mail.protection.outlook.com (10.167.243.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Wed, 10 Jan 2024 09:57:27 +0000 Received: from jenkins-julia.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 10 Jan 2024 03:57:22 -0600 From: Julia Zhang To: Gurchetan Singh , Chia-I Wu , David Airlie , Gerd Hoffmann , , , , CC: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Daniel Vetter , David Airlie , Erik Faye-Lund , =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= , Pierre-Eric Pelloux-Prayer , Honglei Huang , Chen Jiqian , Huang Rui , Julia Zhang Subject: [PATCH 1/1] drm/virtio: Implement device_attach Date: Wed, 10 Jan 2024 17:56:28 +0800 Message-ID: <20240110095627.227454-2-julia.zhang@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110095627.227454-1-julia.zhang@amd.com> References: <20240110095627.227454-1-julia.zhang@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E2:EE_|DM6PR12MB4960:EE_ X-MS-Office365-Filtering-Correlation-Id: af03c550-8888-41a2-c12c-08dc11c28d76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YssyQKpVwJpAwj2yvE1Ex6tcd69/iELwXcTclJC0sQCk6F8vwVecAv9WWunkBq1OgwBddCdiqw1J8y3Qx8VtLy7encAtuhrXdloxiRulOrlKxBtwGsl39Xj1HmhnG4FSaCPeusop0kYSU0kGdAWtKo5CCrHLkzeDIznkeaXkNWt7VFtRObEdOQMdabP6E/72OtUd/wy7EHEixH3p1cA/9yNxLS0p+MxVfJmOqI4FZNJkxlftQSx1x/DlvzSsD4sOYgjPFvOOg2GqTohBFUzcKq0Jjnovv66yRspk/lVeaovnBj+rBl5ZIiVhkGSNstH4PNM9R/5BJuUm2JUVmr24vLEsDFdOh1fR7JQxkQGmUw5T40k4AOyliawAlyUlvVe+JRcgrEnTSvQPmAicil3gDNp0THCsd/j3iaiSajdw4RyPK/lbnoncN2JDHi1v5TBUTCbKTqWYFTLqgF40/zuqHAzZWcQQZ+U7MHYMX5rGbh549HDDj2Zk4LLXCcCaA6PCuXhQQNYtbtXKo48in7HtSkUpbngxK4iq4tr9NDI/UCPNw9Gr9vZZ3Ph/odM2X5TjsLQthUzeTbA1hcAS0+k3cvkwZeXdPp9kDiLuhQjxhca6uUYaXZw0ET7Oi3U2b9kyUUulmLVRaQBysqLn/VKncP+Nr/rK/XL7sQ5FOiC13XjBvErsgFxj0wX7MfP9vi6in0o8bIYiMaNQ5xAVUW+dsoForjgexaD/NN470YIArBtT9uSdwRlXDVbd9at9AY8jMCS1e4SbJxGugDNwIziksA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(451199024)(64100799003)(1800799012)(82310400011)(186009)(46966006)(36840700001)(40470700004)(47076005)(356005)(5660300002)(7416002)(2906002)(81166007)(41300700001)(36756003)(86362001)(82740400003)(40480700001)(36860700001)(40460700003)(8936002)(8676002)(4326008)(478600001)(7696005)(83380400001)(70206006)(110136005)(316002)(54906003)(70586007)(16526019)(336012)(426003)(1076003)(26005)(44832011)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2024 09:57:27.3059 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af03c550-8888-41a2-c12c-08dc11c28d76 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4960 drm_gem_map_attach() requires drm_gem_object_funcs.get_sg_table to be implemented, or else return ENOSYS. Virtio has no get_sg_table implemented for vram object. To fix this, add a new device_attach to call drm_gem_map_attach() for shmem object and return 0 for vram object instead of calling drm_gem_map_attach for both of these two kinds of object. Signed-off-by: Julia Zhang --- drivers/gpu/drm/virtio/virtgpu_prime.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c index 44425f20d91a..f0b0ff6f3813 100644 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c @@ -71,6 +71,18 @@ static void virtgpu_gem_unmap_dma_buf(struct dma_buf_attachment *attach, drm_gem_unmap_dma_buf(attach, sgt, dir); } +static int virtgpu_gem_device_attach(struct dma_buf *dma_buf, + struct dma_buf_attachment *attach) +{ + struct drm_gem_object *obj = attach->dmabuf->priv; + struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); + + if (virtio_gpu_is_vram(bo)) + return 0; + + return drm_gem_map_attach(dma_buf, attach); +} + static const struct virtio_dma_buf_ops virtgpu_dmabuf_ops = { .ops = { .cache_sgt_mapping = true, @@ -83,7 +95,7 @@ static const struct virtio_dma_buf_ops virtgpu_dmabuf_ops = { .vmap = drm_gem_dmabuf_vmap, .vunmap = drm_gem_dmabuf_vunmap, }, - .device_attach = drm_gem_map_attach, + .device_attach = virtgpu_gem_device_attach, .get_uuid = virtgpu_virtio_get_uuid, }; -- 2.34.1