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 009B8C3600B for ; Thu, 27 Mar 2025 11:39:36 +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=SiDyYekmZNMSivdab4Zrek7jwPATeBFWbRgjeMVU2kg=; b=P1DGvwDTZaw7tkmsHYx6Vb5B56 nBmLd8ke7b/Mc3QNfiUTpVMMcZa4EY52QRC0PZVdwwnuZq/bJVbJpV5RWx52hmSpuQnLb5JZVjfj3 ELMgUq7nwSI+GMGonCZV61FO18gRo4zYOZbPD5IZgRGMgszHIMajCAdZX9RpmqHwbD0TJJ3UQ7oPF 9D2Ah7AUsTbT+BeRg4/v7z/nJJ+03i5chOBea2hDR01qqaYNBHm7FPIjPQTuOMqJrO7EVZL2aizya 8/hQIutlxPmm6F3Y/z9wFaMrm1JiyE62rX6zBrY5YrqTJNUzqkM0buzX2t0vOtpg+fTEJVFZKO94T LwoWtskA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1txlaB-0000000AqQn-0Y62; Thu, 27 Mar 2025 11:39:35 +0000 Received: from 003.mia.mailroute.net ([199.89.3.6]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1txlYQ-0000000Aq79-0U2Q; Thu, 27 Mar 2025 11:37:47 +0000 Received: from localhost (localhost [127.0.0.1]) by 003.mia.mailroute.net (Postfix) with ESMTP id 4ZNhTp2gcgzm0GTW; Thu, 27 Mar 2025 11:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:content-language:references:subject:subject :user-agent:mime-version:date:date:message-id:received:received; s=mr01; t=1743075451; x=1745667452; bh=SiDyYekmZNMSivdab4Zrek7j wPATeBFWbRgjeMVU2kg=; b=HIN67TwmZCtgN/QnU4Iglp3zfThOppqJZmwn9gxR tjyKuoN7ymVRADOc+jgcxtdb+k9S5Gz6jWy3NQG/2kVJe6Dspu0XBZqFKfuV0E6O 4rfMfs5zueHztCNMi6RWR/Ru18OgpnqfcyFE1ScSyij2OTMsOw1SIbFi7vo3hqim RdHjQ5CNWn282Zxly66VXILMTjSS2Z2tL4LNrRk0PBaX+P9XT61vutbANkWuZNF9 lsMs4WlWUcYZLagbwJzjFp8bfx2ZA1dbiGSXpbM8Gki9nuIcGRUJyqO+0V8vu0a/ xQRQD6+jhWx/Vz4ZGizHcYY+MdLA7eTP1iwlEbm/h73IaA== X-Virus-Scanned: by MailRoute Received: from 003.mia.mailroute.net ([127.0.0.1]) by localhost (003.mia [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id WXirvB8zVYkM; Thu, 27 Mar 2025 11:37:31 +0000 (UTC) Received: from [10.47.187.167] (unknown [91.223.100.87]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 003.mia.mailroute.net (Postfix) with ESMTPSA id 4ZNhTD50Rxzlmm8q; Thu, 27 Mar 2025 11:37:03 +0000 (UTC) Message-ID: <3d7b543c-1165-42e0-8471-25b04c7572ac@acm.org> Date: Thu, 27 Mar 2025 07:36:56 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/1] scsi: ufs: core: add device level exception support To: "Bao D. Nguyen" , Arthur Simchaev , "quic_cang@quicinc.com" , "quic_nitirawa@quicinc.com" , "avri.altman@wdc.com" , "peter.wang@mediatek.com" , "manivannan.sadhasivam@linaro.org" , "minwoo.im@samsung.com" , "adrian.hunter@intel.com" , "martin.petersen@oracle.com" Cc: "linux-scsi@vger.kernel.org" , Alim Akhtar , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Bean Huo , Keoseong Park , Ziqi Chen , Al Viro , Gwendal Grignou , Eric Biggers , open list , "moderated list:ARM/Mediatek SoC support:Keyword:mediatek" , "moderated list:ARM/Mediatek SoC support:Keyword:mediatek" References: <4370b3a3b5a5675bb3e75aaa48a273674c159339.1742526978.git.quic_nguyenb@quicinc.com> <0a68d437-5d6a-42aa-ae4e-6f5d89cfcaf3@acm.org> Content-Language: en-US From: Bart Van Assche In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250327_043746_220376_A07134E0 X-CRM114-Status: GOOD ( 16.22 ) 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 On 3/26/25 7:47 PM, Bao D. Nguyen wrote: > On 3/26/2025 3:49 AM, Bart Van Assche wrote: >> On 3/25/25 6:15 PM, Bao D. Nguyen wrote: >>> The existing "struct utp_upiu_query_v4_0" probably has a bug in it.=20 >>> It does not use the=C2=A0 __attribute__((__packed__)) attribute. The=20 >>> compiler is free to add padding in this structure, resulting in the=20 >>> read attribute value being incorrect. I plan to provide a separate=20 >>> patch to fix this issue. >> >> Adding __attribute__((__packed__)) or __packed to data structures that >> don't need it is not an improvement but is a change that makes >> processing slower on architectures that do not support unaligned >> accesses. Instead of adding __packed to data structures in their >> entirety, only add it to those members that need it and check the >> structure size as follows: >> >> static_assert(sizeof(...) =3D=3D ...); >> > Thank you for the info on this, Bart. > IMO, this response upiu data should be __packed because the data coming= =20 > from the hardware follows a strict format as defined by the spec. If we= =20 > support __pack each individual field which data may be read by the=20 > driver (the attribute read commands) and check the validity of their=20 > sizes, it may add some complexity? Hi Bao, As explained in my previous email, adding __packed to data structures in their entirety is a bad practice. Please don't do this. Regarding your question: I have not yet seen any data structure that represents an on-the-wire data format where every single data member has to be annotated with __packed. Only data members that are not aligned to a natural boundary need this annotation. Examples are available in this header file: include/scsi/srp.h. Thanks, Bart.