From patchwork Fri May 8 08:13:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 6369641 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DFFDABEEE1 for ; Sat, 9 May 2015 14:56:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 134CE2026F for ; Sat, 9 May 2015 14:56:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 332EB20351 for ; Sat, 9 May 2015 14:56:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0105772173; Sat, 9 May 2015 07:56:05 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DFF86E015 for ; Fri, 8 May 2015 01:14:23 -0700 (PDT) Received: by pdbqd1 with SMTP id qd1so70897174pdb.2 for ; Fri, 08 May 2015 01:14:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=ZvoYyf+JwIMM/vhTaZD9KDt5kTX99TTcoTNUnYiR1Yk=; b=KYnL6xuBqikr8AMcYTzBuO1yBrKjTmHEvfDXwkAQ02tMrB+8REv4pu9/E8mcrWQQyL xfCplfhfovSOqvy7deaMZsyJqopd3dpOVVMPRwZRHPtAzeZpvQCBrcWJIYfs4gGUErSN s2Ffy411nDWH9D2+4U3eislU7ctptoA3Dvpdg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZvoYyf+JwIMM/vhTaZD9KDt5kTX99TTcoTNUnYiR1Yk=; b=RVBzwzmkf/npeimIRdVyA1PI8HYi2chpINz93/119Bt/S8drlq9nRLqoFKKKQShdXa FlAQZyEGShkExcoRAGZfbB9+gOQ5kJedKYQqNlMnLI0PNCBaPaek7W+n+3DspR2mDQw4 jtKlGVPq0nUMpi3SF9W822fFPziYXUNyLBleTKTA1evXbAytcQYL+zmt5gZZt52Dy2Iw 2k++aS5W/IHuxar7iVkHLSb7a5oO3DI/UGzFCmJQ98FzwdNZWick2wIioZn3Hc6XjyjK qLc0q1egYeSeZQXe7MyXQjtBAur1u2cQfHVVNDATpo8WTXCwfU8gZYQGoYYBDXTo2Xym bUQw== X-Gm-Message-State: ALoCoQmq7H7fh4YtZE9F/OPiqPxc9gNCl65fOP4cn+eG2hOqYTbgKA58Qll2rtZSWPiM7rmJKXYy X-Received: by 10.68.65.110 with SMTP id w14mr4557653pbs.93.1431072836648; Fri, 08 May 2015 01:13:56 -0700 (PDT) Received: from basement.tok.corp.google.com ([172.23.69.229]) by mx.google.com with ESMTPSA id og11sm4333190pdb.91.2015.05.08.01.13.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 May 2015 01:13:55 -0700 (PDT) From: Tomasz Figa To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/prime: Allow internal imports without import_sg_table Date: Fri, 8 May 2015 17:13:45 +0900 Message-Id: <1431072825-12475-1-git-send-email-tfiga@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c X-Mailman-Approved-At: Sat, 09 May 2015 07:55:49 -0700 Cc: Daniel Vetter , Tomasz Figa , =?UTF-8?q?St=C3=A9phane=20Marchesin?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently drm_gem_prime_import() checks if gem_prime_import_sg_table() is implemented in DRM driver ops. However it is not necessary for internal imports (i.e. dma_buf->ops == &drm_gem_prime_dmabuf_ops and obj->dev == dev), which only increment reference count on respective GEM objects. This patch makes the helper check this condition only in case of external imports fo rwhich importing sg table is indeed needed. Signed-off-by: Tomasz Figa --- drivers/gpu/drm/drm_prime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 7fec191..162dd29 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -502,9 +502,6 @@ struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, struct drm_gem_object *obj; int ret; - if (!dev->driver->gem_prime_import_sg_table) - return ERR_PTR(-EINVAL); - if (dma_buf->ops == &drm_gem_prime_dmabuf_ops) { obj = dma_buf->priv; if (obj->dev == dev) { @@ -517,6 +514,9 @@ struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, } } + if (!dev->driver->gem_prime_import_sg_table) + return ERR_PTR(-EINVAL); + attach = dma_buf_attach(dma_buf, dev->dev); if (IS_ERR(attach)) return ERR_CAST(attach);