Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965531AbcKJRkc (ORCPT ); Thu, 10 Nov 2016 12:40:32 -0500 Received: from mail-db5eur01on0070.outbound.protection.outlook.com ([104.47.2.70]:52096 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965117AbcKJRk3 (ORCPT ); Thu, 10 Nov 2016 12:40:29 -0500 From: Stuart Yoder To: Ruxandra Ioana Radulescu , "gregkh@linuxfoundation.org" CC: German Rivera , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" , "agraf@suse.de" , "arnd@arndb.de" , Leo Li , Roy Pledge , Haiying Wang Subject: RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 Thread-Topic: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 Thread-Index: AQHSK6SU/JJyAb48sEOHR53H+I1ID6DHaGwwgAsET1CAACqIYA== Date: Thu, 10 Nov 2016 17:25:38 +0000 Message-ID: References: <1477058509-12547-1-git-send-email-stuart.yoder@nxp.com> <1477058509-12547-7-git-send-email-stuart.yoder@nxp.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=stuart.yoder@nxp.com; x-originating-ip: [192.88.168.49] x-microsoft-exchange-diagnostics: 1;VI1PR0401MB1759;7:VPZ0pyuM6QJR3Y9giWvOSRFiG6wWP0imnLCK642LKUefc3NAeuCqng/twN9LO9wYq9YoxIgs7HvWkOaI+jRHeyJ8+PmW2wrhQSJRJDEiO8ikuC6DgHJIlXq7EaEOBjPwnVzPcUCR92fWfzwFFOZTpdyEZXfpeDSLcRpyzVscGiKl7rv4xqNLNCIz+hOPSf1DYoPM2zfBuUNLlf+X5MLuLuRnweggbW37EU3aKXSpak0SNWaLVvfxSu4f4PKDgNspIa7mziEaHNFy3tLmgelvt72V+DH7nVE/ysurUna/NZsye+fYcFqmh4dTPHIRO/UMj7Vp6Ardk/DM16vtLkzppOKARtlzXrpNJCpVZIfHZj0= x-ms-office365-filtering-correlation-id: 2312d6ed-db56-4052-e9f1-08d4098e96dc x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0401MB1759; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197)(275809806118684); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6045074)(6060229)(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6046074)(6061226);SRVR:VI1PR0401MB1759;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0401MB1759; x-forefront-prvs: 01221E3973 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(189002)(51914003)(199003)(377454003)(13464003)(54356999)(66066001)(2900100001)(50986999)(77096005)(76176999)(86362001)(122556002)(101416001)(189998001)(68736007)(305945005)(33656002)(7736002)(7846002)(7696004)(2950100002)(3660700001)(8936002)(76576001)(81156014)(3900700001)(2906002)(2501003)(8676002)(6116002)(4326007)(92566002)(102836003)(586003)(3846002)(3280700002)(9686002)(74316002)(5660300001)(87936001)(229853002)(106116001)(93886004)(97736004)(105586002)(106356001)(5001770100001)(81166006);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB1759;H:VI1PR0401MB2638.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Nov 2016 17:25:38.4976 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB1759 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uAAHebxO025323 Content-Length: 5847 Lines: 178 > -----Original Message----- > From: Ruxandra Ioana Radulescu > Sent: Thursday, November 10, 2016 9:04 AM > To: Stuart Yoder ; gregkh@linuxfoundation.org > Cc: German Rivera ; devel@driverdev.osuosl.org; linux-kernel@vger.kernel.org; > agraf@suse.de; arnd@arndb.de; Leo Li ; Roy Pledge ; Haiying Wang > ; Stuart Yoder > Subject: RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > > > -----Original Message----- > > From: Stuart Yoder [mailto:stuart.yoder@nxp.com] > > Sent: Friday, October 21, 2016 9:02 AM > > To: gregkh@linuxfoundation.org > > Cc: German Rivera ; devel@driverdev.osuosl.org; > > linux-kernel@vger.kernel.org; agraf@suse.de; arnd@arndb.de; Leo Li > > ; Roy Pledge ; Roy Pledge > > ; Haiying Wang ; Stuart > > Yoder > > Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > > > From: Roy Pledge > > > > Add QBman APIs for frame queue and buffer pool operations. > > > > Signed-off-by: Roy Pledge > > Signed-off-by: Haiying Wang > > Signed-off-by: Stuart Yoder > > --- > > drivers/bus/fsl-mc/dpio/Makefile | 2 +- > > drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009 > > ++++++++++++++++++++++++++++++++ > > drivers/bus/fsl-mc/dpio/qbman-portal.h | 464 +++++++++++++++ > > 3 files changed, 1474 insertions(+), 1 deletion(-) > > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c > > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h > > > > diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl- > > mc/dpio/Makefile > > index 128befc..6588498 100644 > > --- a/drivers/bus/fsl-mc/dpio/Makefile > > +++ b/drivers/bus/fsl-mc/dpio/Makefile > > @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror > > > > obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o > > > > -fsl-mc-dpio-objs := dpio.o > > +fsl-mc-dpio-objs := dpio.o qbman-portal.o > > diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c b/drivers/bus/fsl- > > mc/dpio/qbman-portal.c > > new file mode 100644 > > index 0000000..1eb3dd9 > > --- /dev/null > > +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c > > @@ -0,0 +1,1009 @@ > > [...] > > > +/** > > + * qbman_swp_release() - Issue a buffer release command > > + * @s: the software portal object > > + * @d: the release descriptor > > + * @buffers: a pointer pointing to the buffer address to be released > > + * @num_buffers: number of buffers to be released, must be less than 8 > > + * > > + * Return 0 for success, -EBUSY if the release command ring is not ready. > > + */ > > +int qbman_swp_release(struct qbman_swp *s, const struct > > qbman_release_desc *d, > > + const u64 *buffers, unsigned int num_buffers) > > +{ > > + int i; > > + struct qbman_release_desc *p; > > + u32 rar; > > + > > + if (!num_buffers || (num_buffers > 7)) > > + return -EINVAL; > > + > > + rar = qbman_read_register(s, QBMAN_CINH_SWP_RAR); > > + if (!RAR_SUCCESS(rar)) > > + return -EBUSY; > > + > > + /* Start the release command */ > > + p = qbman_get_cmd(s, QBMAN_CENA_SWP_RCR(RAR_IDX(rar))); > > + /* Copy the caller's buffer pointers to the command */ > > + for (i = 0; i < num_buffers; i++) > > + p->buf[i] = cpu_to_le64(buffers[i]); > > + > > Hi Stuart, > We also need to set BPID field in the buffer release command, something like: > + p->bpid = d->bpid; > Without this all buffers will be released to buffer pool id 0, which is incorrect. Will fix on next respin. > > + /* > > + * Set the verb byte, have to substitute in the valid-bit and the > > number > > + * of buffers. > > + */ > > + dma_wmb(); > > + p->verb = d->verb | RAR_VB(rar) | num_buffers; > > + > > + return 0; > > +} > > + > > +struct qbman_acquire_desc { > > + u8 verb; > > + u8 reserved; > > + u16 bpid; > > + u8 num; > > + u8 reserved2[59]; > > +}; > > + > > +struct qbman_acquire_rslt { > > + u8 verb; > > + u8 rslt; > > + u16 reserved; > > + u8 num; > > + u8 reserved2[3]; > > + u64 buf[7]; > > +}; > > + > > +/** > > + * qbman_swp_acquire() - Issue a buffer acquire command > > + * @s: the software portal object > > + * @bpid: the buffer pool index > > + * @buffers: a pointer pointing to the acquired buffer addresses > > + * @num_buffers: number of buffers to be acquired, must be less than 8 > > + * > > + * Return 0 for success, or negative error code if the acquire command > > + * fails. > > + */ > > +int qbman_swp_acquire(struct qbman_swp *s, u16 bpid, u64 *buffers, > > + unsigned int num_buffers) > > +{ > > + struct qbman_acquire_desc *p; > > + struct qbman_acquire_rslt *r; > > + int i; > > + > > + if (!num_buffers || (num_buffers > 7)) > > + return -EINVAL; > > + > > + /* Start the management command */ > > + p = qbman_swp_mc_start(s); > > qbman_swp_mc_start() returns a pointer to where the QBMan > management command must be written, but doesn't clear any > previous values found there. > We should memset the area to zero before using it. > Same comment applies to other places where this function is used. Ok, will fix. > > + > > + if (!p) > > + return -EBUSY; > > + > > + /* Encode the caller-provided attributes */ > > + p->bpid = cpu_to_le16(bpid); > > + p->num = num_buffers; > > + > > + /* Complete the management command */ > > + r = qbman_swp_mc_complete(s, p, p->verb | > > QBMAN_MC_ACQUIRE); > > qbman_swp_mc_complete() may return NULL, if for instance the hardware > is unresponsive. We need to check this before dereferencing r. > Same for other instances of usage throughout the code. Ok, will fix. Thanks for the review. Stuart