From patchwork Fri Aug 3 11:37:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10554991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 225DA15E9 for ; Fri, 3 Aug 2018 11:37:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1084B2C0DE for ; Fri, 3 Aug 2018 11:37:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0539A2C2C8; Fri, 3 Aug 2018 11:37:40 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3A1E2C1E7 for ; Fri, 3 Aug 2018 11:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727464AbeHCNdd (ORCPT ); Fri, 3 Aug 2018 09:33:33 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:50430 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727323AbeHCNdd (ORCPT ); Fri, 3 Aug 2018 09:33:33 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 959AD1A46; Fri, 3 Aug 2018 13:37:34 +0200 (CEST) From: Kieran Bingham To: Laurent Pinchart , linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org Cc: Kieran Bingham , Kieran Bingham Subject: [PATCH v6 02/11] media: vsp1: use kernel __packed for structures Date: Fri, 3 Aug 2018 12:37:21 +0100 Message-Id: <3f7e17bc411842379495b3bd3e96a367582f8d65.1533295631.git-series.kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kieran Bingham The kernel provides a __packed definition to abstract away from the compiler specific attributes tag. Convert all packed structures in VSP1 to use it. The GCC documentation [0] describes this attribute as "the structure or union is placed to minimize the memory required". The Keil compiler documentation at [1] warns that the use of this attribute can cause a performance penalty in the event that the compiler can not deduce the allignment of each field. Careful examination of the object code generated both with and without this attribute shows that these structures are accessed identically and are not affected by any performance penalty. The structures are correctly aligned and padded to match the needs of the hardware already. This patch does not serve to make a decision as to the use of the attribute, but purely to clean up the code to use the kernel defined abstraction as per [2]. [0] https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-packed-type-attribute [1] http://www.keil.com/support/man/docs/armcc/armcc_chr1359124230195.htm [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/compiler-gcc.h?h=v4.16-rc5#n92 Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- This patch had some lengthy discussion about the use of the packed attribute. In the end, after discussing further with Laurent, we decided that as no performance impact occurs on the VSP1 driver (object code generated is identical), and that as this attribute clearly marks structures which are read by the VSP1, we can just keep it. This patch neither adds, nor removes the attribute - but purely adapts to using the linux macro as defined at [2] to ensure that compiler specifics are abstracted out. And in particular I feel that __packed is cleaner than __attribute__((__packed__)) v2: - Remove attributes entirely v6: - Re-added the attributes (back to v1 of this patch) drivers/media/platform/vsp1/vsp1_dl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_dl.c b/drivers/media/platform/vsp1/vsp1_dl.c index 10a24bde2299..e4aae334f047 100644 --- a/drivers/media/platform/vsp1/vsp1_dl.c +++ b/drivers/media/platform/vsp1/vsp1_dl.c @@ -25,19 +25,19 @@ struct vsp1_dl_header_list { u32 num_bytes; u32 addr; -} __attribute__((__packed__)); +} __packed; struct vsp1_dl_header { u32 num_lists; struct vsp1_dl_header_list lists[8]; u32 next_header; u32 flags; -} __attribute__((__packed__)); +} __packed; struct vsp1_dl_entry { u32 addr; u32 data; -} __attribute__((__packed__)); +} __packed; /** * struct vsp1_dl_body - Display list body