From patchwork Sat Jul 22 09:53:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gmeiner X-Patchwork-Id: 9858047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AD0B600F5 for ; Sat, 22 Jul 2017 09:55:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74C99285ED for ; Sat, 22 Jul 2017 09:55:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69A2F285F5; Sat, 22 Jul 2017 09:55:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF30D285ED for ; Sat, 22 Jul 2017 09:55:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE8D06E1C4; Sat, 22 Jul 2017 09:55:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 472476E040; Sat, 22 Jul 2017 09:55:15 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id m4so9384064wmi.4; Sat, 22 Jul 2017 02:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7EkhUIklKtTHMQRCw38YvCe/7Ux01xDr9Cx0KGdJymM=; b=HsaVM5KAcvbg/Q7fKfCcO6S2G5Mj/3cBvzEUhaGh82/UXhY7g6tTDFqVkRo1fPVo7G wPDAKQHuZi+guJy7aIPMC7SOnFpMVsVOCfDdz4usA+5e7gnynFBrl0C4qEdZiq0xamIi lcoJeDUFO9UGO+NvGAyKD09kBjtINEBc07yR++/mRSAHuvJWsXmGitgcC1Ru/m8vfJGw Pxkt/OYxgnSrqiA9i9L8ziHyTDtT3eXHAizgSffM6vYwQFBAWW5OvC/wbUDcMMZm2TPt uEc65HrIs2u6yGKvkPjyAMFNRIUkESn0Sho6mu55s6nz37Dv0aNvtnfvtiBe4ypbdCO7 OPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7EkhUIklKtTHMQRCw38YvCe/7Ux01xDr9Cx0KGdJymM=; b=qmhk4YActZByH50FDYGaSn6m0rBf3LHWKUjEQVHY+IPNiqkqd7jN1wsTZDqLbz6xZz 6yvp3Rv/8fdSLkQthcGpOVlmhEKwMpgZfYqevPwkm/hX3yUUaZ8wuWKaik9qIb4jgz+v IMse15rq8OFJNrCmFg75xNvHFy+EhpQ54PfcVyhIlyWgDcBd/qiVv02cqDn57kRRSLuo PdBDmaOPVcW4whVTet3QQ3u4jK1eQPI/6KP0WMc7E0sNuVVgDpYIsLcPi8fzBiTj/S5w WymdCAOKg423G7YVjt15j3RAdgBmQQn7OjoJ//Fy9B832Gx7RS8j/REX34GDC49mNl4Q f3+g== X-Gm-Message-State: AIVw112XPa8XUyD1dfvzMyb5CPobLABTNQ9IeJpW0CZNza+SFEH+ykpk +Mv+4TXNWDPbNU0+ X-Received: by 10.28.107.69 with SMTP id g66mr1063438wmc.110.1500717313729; Sat, 22 Jul 2017 02:55:13 -0700 (PDT) Received: from cp720.fritz.box (91-114-193-248.adsl.highway.telekom.at. [91.114.193.248]) by smtp.gmail.com with ESMTPSA id z192sm2544673wmz.44.2017.07.22.02.55.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jul 2017 02:55:12 -0700 (PDT) From: Christian Gmeiner To: dri-devel@lists.freedesktop.org Subject: [PATCH V2 07/23] drm/etnaviv: add performance monitor request validation Date: Sat, 22 Jul 2017 11:53:07 +0200 Message-Id: <20170722095323.9964-8-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170722095323.9964-1-christian.gmeiner@gmail.com> References: <20170722095323.9964-1-christian.gmeiner@gmail.com> Cc: linux+etnaviv@armlinux.org.uk, etnaviv@lists.freedesktop.org, cphealy@gmail.com 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-Virus-Scanned: ClamAV using ClamSMTP Check if the selected domain and signal combination exists. Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach --- drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | 15 +++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_perfmon.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c index 5bc015194791..3ecedeed87bd 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c @@ -83,3 +83,18 @@ int etnaviv_pm_query_sig(struct etnaviv_gpu *gpu, return 0; } + +int etnaviv_pm_req_validate(const struct drm_etnaviv_gem_submit_pmr *r) +{ + const struct etnaviv_pm_domain *dom; + + if (r->domain >= ARRAY_SIZE(doms)) + return -EINVAL; + + dom = &doms[r->domain]; + + if (r->signal > dom->nr_signals) + return -EINVAL; + + return 0; +} diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h index 4b2b518cfd16..f20b69c942fc 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h @@ -40,4 +40,6 @@ int etnaviv_pm_query_dom(struct etnaviv_gpu *gpu, int etnaviv_pm_query_sig(struct etnaviv_gpu *gpu, struct drm_etnaviv_pm_signal *signal); +int etnaviv_pm_req_validate(const struct drm_etnaviv_gem_submit_pmr *r); + #endif /* __ETNAVIV_PERFMON_H__ */