From patchwork Tue Jul 18 09:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13318393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4F7EC001B0 for ; Wed, 19 Jul 2023 06:55:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hMnA6dG+bf3NA1N7SHHkxVyApsAg1wWJJMRzkyUvwyM=; b=2kysoHdw146zFS +E03/qAPDZDQPrHp0Vhl6LPHvvgpXGZ1rzRs1BZoDj0gnL54rzvRCJPPVxvGDOKM0zu/n9nei3Yw7 284YKjSuos2/4DdTouGDJw55kFWwCYr/SIu5MNiG0MagBa+3YaGx4BTeKy/SbF0lBemX/etgYYvKu siCsCJU08YKQ4EXpsU9ekuef5Jc7g6bda241w5RjjVJDh4aJlQS/+HzrW0C+ZQyuLA075nTlL0gWR 5boskfhXDSztdttYvfWEkRIFRK49ZBS5bYchB3Bzrbq/OJxOH9ygIQcWNFCZRdTsW5FmkoKNpVuFJ LSqyyfX5AS6g+8/pDJCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM15C-005xnn-1K; Wed, 19 Jul 2023 06:54:46 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM159-005xkT-1X for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Jul 2023 06:54:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=20G3mcqhQwbuDatCJ1tAgjhv5x52jZDh+tZLmUBxvg8=; b=QMzQhetEk0G8KHeUoMdNCeXrU2 2l/Wx3qShPEEUQD6P131fpKEJGFLR3796C5gJoGU2bAIiuiytLQkct/U+QpcmSp8aR/GdJASHWiNc M/WM6Vel3C25KSqw64jdMq9awOC66ImTwZ/fNEZu7YvRAD06Ww/jZjsXkQFrN85Il15XfRBixfATI IMaLxkS+YRa083pgn1dPoEmeboVMYCrUIrGrLaWnooLov8CVQOEOcL8DDmyzbz4W2evou1YSxOh19 i0pvwOU2TG1y+RJKpu4BU5DucpSEmW/RAGgIkIbsSl0e7KZXnrDBdlPd7dhKUA/KUqwm8h2dCVwyB LDVUzrXg==; Received: from mail-vi1eur05on20614.outbound.protection.outlook.com ([2a01:111:f400:7d00::614] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLhbe-00BOlC-2J for linux-arm-kernel@lists.infradead.org; Tue, 18 Jul 2023 10:07:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B7rzXGHOoSg8J55eYkXRQyKKmYMHxKz+1CI/xzd0MFkQKy/VnEg9opRlVTHGxmoOuNgWM/YrzjtO7KzrcoUZU6D6L38DFyqB8qlgt26l2E7Vipvtlc4u+8vtSIyoqR26aSB98nfsUeVFldg0riBY3OIlewiLxqrakCUYow6xlmlVDWIoYDB+wZukIDUJzGCAjf8GHoZUGshVCth7dY07nRG43ey0UXNCpCn2rUsnhRtEis3yaeMqfg7R6BWXxS/XydWLunSy9fEuKHWcUar4/TnE+Xfe95NUvoxMzIE95n/WmVPeYbW7KxDbrGwx58VueGiN3R6F4LXGTpLM7SxjvA== 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=20G3mcqhQwbuDatCJ1tAgjhv5x52jZDh+tZLmUBxvg8=; b=D8N7TDRc6lpw+Iueycf5ymzgMlakhbWCFnGjdu85Xa/qhE/ZN2RB3xntLypMohkQes+zyBZvhDgUeXtmXd1xyS/ApRlpRlMsYflMcPeXDjKjdUkbP4a1Kzx1/1dRmQtmhf7G3WAzOqHSkMRxH+lLZBr05ARb2AxcX6eBMCityY7EPb6ZW1/nk1IyzfzxRa0UUrTw9NhQ9+hW/A2tyQvA/8Ofafmf6Mw8vUPVb6abUTv3Qg3OAPCiezrYRA2SXTtkbd5eXpLfDZAZRk2ZfPSGiSMmw3xt6yL//TMCSh4AsxtzFswTVNwRAv8yzVOp6kDasLi4MzzYzNnqK6bKbEGwUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=20G3mcqhQwbuDatCJ1tAgjhv5x52jZDh+tZLmUBxvg8=; b=SLYK/RG0N0+FwhR06ur0H9vcdhVCTj2jjQYwAS2XvngLJAn8J4trXqDmgUfcId9zsU0KUGQyl/gp6mQBAe93g2HbDxY70iygse+7huCGfoBLeljnXhSYMFot3JdC1zbhhULq5xEM4sSZYCtgmXYyX6qYUKWcjFnKCGQMN5u9GPE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AS4PR04MB9243.eurprd04.prod.outlook.com (2603:10a6:20b:4e2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Tue, 18 Jul 2023 09:51:05 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::613b:e94b:4ccd:f55a]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::613b:e94b:4ccd:f55a%5]) with mapi id 15.20.6588.031; Tue, 18 Jul 2023 09:51:04 +0000 From: Ming Qian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/5] media: amphion: ensure the bitops don't cross boundaries Date: Tue, 18 Jul 2023 17:50:13 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2PR04CA0009.apcprd04.prod.outlook.com (2603:1096:4:197::8) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|AS4PR04MB9243:EE_ X-MS-Office365-Filtering-Correlation-Id: 015a50e9-ba4e-4059-a296-08db87748034 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QC/lYW0mRy9Fb5j13gF30Vtvq3hQiWxPy1+Qg7Z0L5U99cAEJJmvDY20wQdrlon+RvPhiuuw7UUHd2YFum5HYtjVCOcYXYMF/1XMQvvZk76r/09MA5EbUOnyivJUzx66D9Dpvlmx7gzhWXlgoxXGfYJ9aDavkkeJqBpcL5aYrCFM9n2DY6Wmhz7r+zHCO6mPjvkvbM5xk6n6KmCKPIh1au7nSNfjBYcCAaRr0i8rQgOMGTJQxr+84RYX6s+6bxr5kHCzvVFslEfP2CBzf2ZlOowqiaktWPWN5+jLrwisC1zPnO66ol2rhw+M9CjiGLdJZY/4A3+/fTkXbzTQUxpARXrOQuf6pPMMU0nntTKqYifdU0Xs7tuRZhnDYEAqfHSwlgGyWafsiCC0ZknIuh5AtkMtxOWIdwaIl/t7SW5pokp04SS/EuAQQA1KUEpFfbiiLnJLW7ADWXE6KCEXxi/TVJREw30+IVmVFlNgyDeVQD2poYmHBgvCFfmB6sGC42u9lCEQD08evUb8QaAEbRLXPQxnjW7zJ/YjOjsvdKWWwOwOEPsAmQNcp1OsQjv9GCWqRHvBxmtyyzOUvGVHXECwKc6O2LmHujNiiLohS0MLN872lLkUhPYEMzXiZ0ZaZ0bX X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB6341.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199021)(26005)(186003)(6506007)(36756003)(83380400001)(86362001)(38100700002)(38350700002)(2616005)(4326008)(66476007)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(7416002)(41300700001)(44832011)(2906002)(6486002)(6666004)(6512007)(52116002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam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cCYOYJfq8N2g8xhkJB92NwkAi88cyQFEirXhqb8enZ+Tq9isS8Z5mfbwqtbra41Ntoe3HeHDuAVsGiMoalXbJEb71sHb+0M78FLKYvqo3HE+5rf71XDC8u9+/hAg1dxj4qg0JTwl2uX7XoOfnllUm3VCVDe3GuKPTAF+a6oulV4m6NVltCg4NB+rF0RUM6EGnwbwRy+J67gDPVfvBU4auueL9iIn3JkQLD4Jrvak0vweIzKiB3ABpVqgfz1J3a0W5K/L0cRCRNYrpredeDr2qgKgmFXKnhYZmAOI77XFJTbEayrLi+zyF/R9JXr/9nSaelKYzf1Qeh6ptsWOAGnO+o/n8kvC9sveJJpJZlrEGSqmil7QQsJU5wkDXX/1JJp7psHTPRDsEvsvsFmHcKhkhTyrXA7VM+uziiGpdOgEXlPpydCFuEYoJ6S0A8uwjwced9WKK013f/sAakGUVvkwXJL+fWJnIoLTD+LKaxzswZjMaNzeBzM/w7lhpCYuHUJBEVIrZi+tBG0oKpqAg2Fp5leSkoL7WGJCHO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 015a50e9-ba4e-4059-a296-08db87748034 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2023 09:51:04.9083 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 16WIEUkQmofalwWZ+KlMUUXrfltmzo9z19AvRSoKkubKYxmzZnTe2LuoqnEJlFoAgq1lt/+A5tA+WJvW3YpTUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9243 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230718_110659_113371_097BE632 X-CRM114-Status: UNSURE ( 9.13 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org the supported_instance_count determine the instance index range, it shouldn't exceed the bits number of instance_mask, otherwise the bitops of instance_mask may cross boundaries Fixes: 9f599f351e86 ("media: amphion: add vpu core driver") Reviewed-by: Nicolas Dufresne Signed-off-by: Ming Qian --- drivers/media/platform/amphion/vpu_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/amphion/vpu_core.c b/drivers/media/platform/amphion/vpu_core.c index 43d85a54268b..6f054700d5db 100644 --- a/drivers/media/platform/amphion/vpu_core.c +++ b/drivers/media/platform/amphion/vpu_core.c @@ -88,6 +88,8 @@ static int vpu_core_boot_done(struct vpu_core *core) core->supported_instance_count = min(core->supported_instance_count, count); } + if (core->supported_instance_count >= BITS_PER_TYPE(core->instance_mask)) + core->supported_instance_count = BITS_PER_TYPE(core->instance_mask); core->fw_version = fw_version; vpu_core_set_state(core, VPU_CORE_ACTIVE);