Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1559453ybb; Thu, 26 Mar 2020 03:08:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtx2K93Rtg3uFc+J4ufxuIg764IPiNFTLAR4smlpjQc+EyxllG1jyh4qaZQtfBvde5hvyHa X-Received: by 2002:a9d:709a:: with SMTP id l26mr5528330otj.159.1585217305115; Thu, 26 Mar 2020 03:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585217305; cv=none; d=google.com; s=arc-20160816; b=1IaVYfFvt9bDqTwReSw7eW/46XzcT67+0/wDE/nntqOE5qH1lOc+6wJ/AdILQujAim IOKaUo1mdsuBRGBT7nB3nxR5x9PGYwPw2mfA5UsM56l3NwGbPjcieJ6F5AyvClUEadrs qS4iZZ0vsSa5QUA/VZ5B6K5QUBzixaFaCxkxXE1daI1WD/KR1nulEt6WMJg3ujF9QJLT HUayPcQkNibT3+ST8UHPYQ+wAW73p9ifvVrtdn93JhiqryJ9AFrdR3+a0+tvV+YfuiUG QU1Lv08NoLWXbXl1pM3g7zRWDJ/EO657sfI5V6nF1BTR9HK4CIBSunVCBmRUJzphgY9u BuQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=bei0eDE6Te1CXBKA0tag/CKIsPwsL/TsmZLSKzYAR2U=; b=Hc2xZ3ayKk1jORNRaB3y2QrqtP9U4nnlXH+dmr4uZAs53eoxq4vsWZt6wdpRd40YPq f2VxWtFMgRm7lrn8gMifiuTJpEGovsrfsNdH9Yl/zmXtVOURFFombxNg++rDgGsjcHvV /5xsSFhwlfA4koijHzUtR+4RqvHwU0Lw0dJanNGsQr1X3tMz4TjIx7UPyA52a6oXbZZd mCBX8I3Zl7V7IwP4liBy3uG6FcQKXv70jkH+redAUp4r4LV9hIhSLM+s3C9stDlJ5LLm lrk68KO0Q6e8cLG1nkzLKL4R1qDgEeQdWmW1/OeTkIwnRtx1JwryUl0QGJcUuqq9CXMF OXHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v15si901063oth.307.2020.03.26.03.08.10; Thu, 26 Mar 2020 03:08:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727661AbgCZKHs (ORCPT + 99 others); Thu, 26 Mar 2020 06:07:48 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:54265 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgCZKHr (ORCPT ); Thu, 26 Mar 2020 06:07:47 -0400 Received: from mail-qt1-f182.google.com ([209.85.160.182]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPSA (Nemesis) id 1MV5rK-1iqLoa0Eg2-00S7X9 for ; Thu, 26 Mar 2020 11:07:46 +0100 Received: by mail-qt1-f182.google.com with SMTP id z12so4726466qtq.5 for ; Thu, 26 Mar 2020 03:07:45 -0700 (PDT) X-Gm-Message-State: ANhLgQ0aKnnvqaSsXYRdJgrcMp/oIuXoaFacfkb53mUqRYSPvIc/QB0T Pn4hX4Bl8CiSeozFLM0vIh0pqBfAIzJLg5PaB3c= X-Received: by 2002:aed:20e3:: with SMTP id 90mr7165503qtb.142.1585217264913; Thu, 26 Mar 2020 03:07:44 -0700 (PDT) MIME-Version: 1.0 References: <1576170032-3124-1-git-send-email-youri.querry_1@nxp.com> <1576170032-3124-3-git-send-email-youri.querry_1@nxp.com> In-Reply-To: <1576170032-3124-3-git-send-email-youri.querry_1@nxp.com> From: Arnd Bergmann Date: Thu, 26 Mar 2020 11:07:28 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] soc: fsl: dpio: QMAN performance improvement. Function pointer indirection. To: Youri Querry Cc: Roy Pledge , Leo Li , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , Ioana Ciornei , Alexandru Marginean Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:Zdku2WQfnX1DF8YXPQf1oMjKpWd4boAe7E2LVR2p4xWf7VV2m5b blLN7IUcUmb+iWznukDGkcx3AtrLJ5bD4/q5XH55UWmXSb7oUyc1YGjQm6TKnbHWLl00PtI Zku8fQ2Rgl14zUe1gvmCm4kDLfNwUA6xCZJ6xH3eqe5H743VxsyVdel9hh1PY4uiDAdxnXv wpUF6PZHeD9ZQWZIFZ5Cw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:E4pX05TN0Cc=:muMnijKCpN5ohmdcVcML0w 6qAX/PZWYlwdR5bskOiDfqpQDEFPkts5rhfvoCFv9oePVSJ03HLFi1jRDLgK5V5Y5ZM2bKMpy pvOJAW/NybCZIASzPz22a/VeQXUL0b0jvmp6mrgedcVHh3q8OGbHHYi7US7PbDUiRGoSEihUl daGsNwKridAkEQDQQdYTjwYA6zbgnBXexuDzQhr+taZ4Gba2N4xsM470nUM7HBoa69Gfd9XEr JNyJKGydojldwIGSkDwkSk3WIaJYqT3lEkJYsXH6QR1FeAdAT7iJ2D/ods16MfLEZDbX7vPgS NoCW4p/8r02K5UlhRDTky/vUPqXQuYHkpDR8wkXzu70En8fiD3OgOTz4XL+eJ0gHh9KhI6cdW E52mBp6YdtVAOlVZVGebxnvNT41ETL0drBXBnBwUfasAOJ8P+ixCPKf4V15sI+54GkMTnNmDm Ot3t3W34TbJMR7A7gM+84SnosJk9V3WwBMPbQqyrbiyHcLV94dD9COOkItO14/GK9WfuXIanI Ew/BSfUfQD1sk3Dt8eUaOgKg6HPt26I7Q32yyOXSUsjiPMYSFmiU1i9bXLtTzPg9wlt+BIh2W KT/HQ269Osl+CJStWEdziIkqm7oKxZO3CvgMJMAsNvujBYYM9xBKhTvlfThKKiuHjMQqiK2xv 33LyfcSqrQ6OsZg816Of0LRi1Orzizyi7cc9gAC8Poezu0nSL3gWgd9HDVfqLo0kPwhfYwMuI 98FfmdATXIinMBI/x0Y+VczC/Su5PJuKcRERS0231B5C0TXO+zhJ7szpbiicgE0kD+f0a+1du msMryCZ1YEKrrMtX7RkPNRZ4+qOgY8HGL9O82LDauHpP4iWNS0= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 12, 2019 at 6:02 PM Youri Querry wrote: > > We are making the access decision in the initialization and > setting the function pointers accordingly. > > Signed-off-by: Youri Querry > --- > drivers/soc/fsl/dpio/qbman-portal.c | 451 +++++++++++++++++++++++++++++++----- > drivers/soc/fsl/dpio/qbman-portal.h | 129 ++++++++++- > 2 files changed, 507 insertions(+), 73 deletions(-) While merging pull requests, I came across some style issues with this driver. I'm pulling it anyway, but please have another look and fix these for the next release, or send a follow-up patch for the coming merge window. > > diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c > index 5a37ac8..0ffe018 100644 > --- a/drivers/soc/fsl/dpio/qbman-portal.c > +++ b/drivers/soc/fsl/dpio/qbman-portal.c > @@ -83,6 +83,82 @@ enum qbman_sdqcr_fc { > qbman_sdqcr_fc_up_to_3 = 1 > }; > > +/* Internal Function declaration */ > +static int qbman_swp_enqueue_direct(struct qbman_swp *s, > + const struct qbman_eq_desc *d, > + const struct dpaa2_fd *fd); > +static int qbman_swp_enqueue_mem_back(struct qbman_swp *s, > + const struct qbman_eq_desc *d, > + const struct dpaa2_fd *fd); > +static int qbman_swp_enqueue_multiple_direct(struct qbman_swp *s, > + const struct qbman_eq_desc *d, > + const struct dpaa2_fd *fd, > + uint32_t *flags, > + int num_frames); > +static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s, > + const struct qbman_eq_desc *d, > + const struct dpaa2_fd *fd, > + uint32_t *flags, > + int num_frames); Please try to avoid all static forward declarations. The coding style for the kernel generally mandates that you define the functions in the order they are used in, and have no such declarations, unless there is a recursion that requires it. If you do have recursion, then please add a comment that explains how you limit it to avoid overrunning the kernel stack. > +const struct dpaa2_dq *qbman_swp_dqrr_next_direct(struct qbman_swp *s); > +const struct dpaa2_dq *qbman_swp_dqrr_next_mem_back(struct qbman_swp *s); Forward declarations for non-static functions in C code are much worse, you should never need these. If a function is shared between files, then put the declaration into a header file that is included by both, to ensure the prototypes match, and if it's only used here, then make it 'static'. > +/* Function pointers */ > +int (*qbman_swp_enqueue_ptr)(struct qbman_swp *s, > + const struct qbman_eq_desc *d, > + const struct dpaa2_fd *fd) > + = qbman_swp_enqueue_direct; > + > +int (*qbman_swp_enqueue_multiple_ptr)(struct qbman_swp *s, > + const struct qbman_eq_desc *d, > + const struct dpaa2_fd *fd, > + uint32_t *flags, > + int num_frames) > + = qbman_swp_enqueue_multiple_direct; This looks like you just have an indirect function pointer with a single possible implementation. This is less of a problem, but until you have a way to safely override these at runtime, it may be better to simplify this by using direct function calls. Arnd