From mboxrd@z Thu Jan 1 00:00:00 1970 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 E2DBFC4345F for ; Mon, 22 Apr 2024 20:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kONDACbP9ddQmqNGkSauCApIyrtLAQsCHGqi6AuKVkA=; b=r0reiiGfO3CRfZvUK56vTp2oFH XGiKxZyup07dd6eX0qL/A12HYVpZq/M74rADr2W3rHhqPy+yJS96jNHb49kL3JxVKMdx6fe/uAjtc KJP6sWooy3nErji0GfS68thD7bQS3620e1ALdm67xxD3Cwpf6owUGliOAjTCfRjIBH6qd25O+qyRH fuKzDZsdfrSaxdKOWP16p4l/fH/VLNU19hw0V3OYtkYRutI/LmxBbyjSN5fxC7c0PtI8cyw3eP13n 7t6phyXlapgQzN1MUk0NblXPKXDa9szeCOx63fbAJdxpmi18q5NCsj1mMHXTSxuPAClhD5O9Zr9oA WDK1ZxaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rz0VD-0000000F0gy-07rT; Mon, 22 Apr 2024 20:43:03 +0000 Received: from mgamail.intel.com ([192.198.163.18]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rz0V8-0000000F0gO-3TSu; Mon, 22 Apr 2024 20:43:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713818579; x=1745354579; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=21plNlwF84LiSmR/a7cPmVx+DowVztKcBCbH9tBCfs0=; b=DM0upeJM4ArYqXnu0lL1vAr6rl8Y9yzmRdBlX49SjsZR+oV5bCQ8EUE5 pTP512HYMWLofQirASdR9fzgZv1CPs2op5sks1Z/4kFI/ZOg6rAJlTzBK LBZ6fl6xPMsHde5oVmEQXTKyS8j91JXzsQmrgUj3P+SukTvsCUGPNT3aF I3yDcxpf+TdpxQLmH6aAHofmAEqU9wXazCp54GnJvk7kRj3pF/vX4omG+ 0q/jaVqnmZx+tqBjdJ0L+zzYAu0RNLjFWjzHiJYi/JCFAXAEhl4MaBJ0e yJdGlUH3D7C5cr3m+Ne/YZuR5WzOIeoVt7VzEUFv6wr9DPaWr4kwBvzs5 A==; X-CSE-ConnectionGUID: aHTxIuTEQAu1pQEMj8/hHg== X-CSE-MsgGUID: Zh7OWh5MRICSQPyLupS4Ow== X-IronPort-AV: E=McAfee;i="6600,9927,11052"; a="9234761" X-IronPort-AV: E=Sophos;i="6.07,221,1708416000"; d="scan'208";a="9234761" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 13:42:04 -0700 X-CSE-ConnectionGUID: nHk9q7c0QZK4QyNVPsdbgQ== X-CSE-MsgGUID: g0m2gNKLQIu8zJeDlFQ+BQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,221,1708416000"; d="scan'208";a="24747792" Received: from leozhang-mobl.amr.corp.intel.com (HELO [10.212.37.174]) ([10.212.37.174]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 13:42:00 -0700 Message-ID: <3acfbe3c-8b83-4c40-83c2-437f963fd25a@linux.intel.com> Date: Mon, 22 Apr 2024 15:42:00 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 00/14] ASoC: Constify local snd_sof_dsp_ops To: Krzysztof Kozlowski , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Matthias Brugger , AngeloGioacchino Del Regno Cc: sound-open-firmware@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20240414-n-const-ops-var-v1-0-8f53ee5d981c@kernel.org> <89f8f0be-2534-46c8-9058-cabea4f68568@linux.intel.com> <9d1eda85-32a0-4e53-86ca-ce3137439bd7@kernel.org> <138ac465-1576-4e86-a05d-63f8acc6fb70@kernel.org> Content-Language: en-US From: Pierre-Louis Bossart In-Reply-To: <138ac465-1576-4e86-a05d-63f8acc6fb70@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_134259_209731_F1DB8239 X-CRM114-Status: GOOD ( 12.67 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org > There are multiple reasons and benefits for const, like compiler > optimization, code readability (meaning) up to security improvements, > e.g. by some GCC plugins or marking rodata as really non-writeable, so > closing some ways of exploits. There are many opportunities here, even > if they are not yet enabled. Possibly, but the SOF core does not know if the structure it uses is rodata or not. Using the 'const' identifier would be misleading. >> that's a different interpretation to the 'software' view you're >> describing. "this structure will not modified by this function" is not >> the same thing as "this structure CANNOT be modified". > > Yes, but can we please discuss specific patchset then? Patches which > change pointers to const have one "interpretation". Patches which modify > static or global data have another. Just look at sound/soc/sof/intel/mtl.c... The core will sometimes use a constant structure and sometimes not, depending on the PCI ID reported by hardware. This was intentional to override common defaults and make the differences limited in scope between hardware generations. int sof_mtl_ops_init(struct snd_sof_dev *sdev) { struct sof_ipc4_fw_data *ipc4_data; /* common defaults */ memcpy(&sof_mtl_ops, &sof_hda_common_ops, sizeof(struct snd_sof_dsp_ops)); <<<< THE BASELINE IS CONSTANT <<< THE REST ISN'T. /* shutdown */ sof_mtl_ops.shutdown = hda_dsp_shutdown; /* doorbell */ sof_mtl_ops.irq_thread = mtl_ipc_irq_thread; /* ipc */ sof_mtl_ops.send_msg = mtl_ipc_send_msg; sof_mtl_ops.get_mailbox_offset = mtl_dsp_ipc_get_mailbox_offset; sof_mtl_ops.get_window_offset = mtl_dsp_ipc_get_window_offset; /* debug */ sof_mtl_ops.debug_map = mtl_dsp_debugfs; sof_mtl_ops.debug_map_count = ARRAY_SIZE(mtl_dsp_debugfs); sof_mtl_ops.dbg_dump = mtl_dsp_dump; sof_mtl_ops.ipc_dump = mtl_ipc_dump;