Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3696766ybv; Mon, 10 Feb 2020 04:54:16 -0800 (PST) X-Google-Smtp-Source: APXvYqzD5dNj9+y7uVBwImNfc27Y6SNsqFe0/y5jrUVJeHZe7E2xJfVD78/2n/SGTCwAPe5IthTL X-Received: by 2002:aca:cdd5:: with SMTP id d204mr724593oig.134.1581339256095; Mon, 10 Feb 2020 04:54:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339256; cv=none; d=google.com; s=arc-20160816; b=BGLmY+3O1EGNzUoDwUfddh9J9Rwhn/7833zz+J3aDXFJ6FJLOUMAByvpEOTK1R5/e2 olTVhLUuE22oDOSP2Inlqi05zHR1esPcedhBJHLmFlfGoXOA6Pd78tE0H6mbXOAPzZvc 2AFBz4ade2f48In9If5Q1ZUkfnoNH0h5BNc+LCULNmAAIIIWyiApuGdhBBG1/B9HsDMG I8cPC8Ksrz3QmxWTjis3Ka2YxtC9lqfzJAs0BrdfqxphyFqhFDF0LGJ59e7ATlTy+D3T oS0f+S1+dyeubyriMPiQPgRkRHQq7CpfURvdlbn7RMakr9qkHHkaFtPRXqTUln7X22yT G7Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UIHjsRQpNInIaFJ/p0CZ7+v4dxMbCvghKgbStDajOiI=; b=Uxu+rdFcGjDBOx02VfxN+AChgG2Zr9SSHIYC865xc+nP9BcQPEiWhVicQZLuDuwuC8 eAj7t4ykrnB8Q7UziQPKSkJj+RL+dvnEKEU8kp2KqWUThBIqZRNdc/CpLnRyMYHEbaep sGD9nYztA9ps1CC8qIFZrehvBmD/fz7Vrq3AEQqlY3Ak8yhtQp+JdhtnEM4PU++aQMWc a0MhGYwPlFjJg+o/CEqt+MSB8msDDB3RitSJTHBnPhJr2D9sgM3POza8sJebTOM7iFt5 sBIrdcDdPFEhaqnoDJpNuiLV9rv/8ve/eU01BVQAAJzeess02XwSoP1FRBKe99j0OLFt j2Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wEH/8hoG"; 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 d22si133238oti.316.2020.02.10.04.54.04; Mon, 10 Feb 2020 04:54:16 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="wEH/8hoG"; 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 S1728144AbgBJMxd (ORCPT + 99 others); Mon, 10 Feb 2020 07:53:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:45952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730169AbgBJMmK (ORCPT ); Mon, 10 Feb 2020 07:42:10 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 838BD2051A; Mon, 10 Feb 2020 12:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338529; bh=vf9KklpbgLZ4lTL2iM6rhbETdK/InDMro2YjI76wTv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wEH/8hoGqNmIrFenXv/QZOym8x1eN9m3e5aqQh5MNGnS7OV2ujL/aRLzz7NP5lQd+ I098LFG+CXGL6nozw/3x/Z7a0OrRDgd2RYov8S1gZT8bx3NVeEhZ5Jk8eQ6LbgngYp tqrAoEPtY+iMlfTQcAZkg/h8yp4qfnhuelJ6ukX0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Po Liu , Vinicius Costa Gomes , Vladimir Oltean , "David S. Miller" Subject: [PATCH 5.5 335/367] taprio: Fix enabling offload with wrong number of traffic classes Date: Mon, 10 Feb 2020 04:34:08 -0800 Message-Id: <20200210122453.686803731@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vinicius Costa Gomes [ Upstream commit 5652e63df3303c2a702bac25fbf710b9cb64dfba ] If the driver implementing taprio offloading depends on the value of the network device number of traffic classes (dev->num_tc) for whatever reason, it was going to receive the value zero. The value was only set after the offloading function is called. So, moving setting the number of traffic classes to before the offloading function is called fixes this issue. This is safe because this only happens when taprio is instantiated (we don't allow this configuration to be changed without first removing taprio). Fixes: 9c66d1564676 ("taprio: Add support for hardware offloading") Reported-by: Po Liu Signed-off-by: Vinicius Costa Gomes Acked-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_taprio.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1444,6 +1444,19 @@ static int taprio_change(struct Qdisc *s taprio_set_picos_per_byte(dev, q); + if (mqprio) { + netdev_set_num_tc(dev, mqprio->num_tc); + for (i = 0; i < mqprio->num_tc; i++) + netdev_set_tc_queue(dev, i, + mqprio->count[i], + mqprio->offset[i]); + + /* Always use supplied priority mappings */ + for (i = 0; i <= TC_BITMASK; i++) + netdev_set_prio_tc_map(dev, i, + mqprio->prio_tc_map[i]); + } + if (FULL_OFFLOAD_IS_ENABLED(taprio_flags)) err = taprio_enable_offload(dev, mqprio, q, new_admin, extack); else @@ -1471,19 +1484,6 @@ static int taprio_change(struct Qdisc *s q->advance_timer.function = advance_sched; } - if (mqprio) { - netdev_set_num_tc(dev, mqprio->num_tc); - for (i = 0; i < mqprio->num_tc; i++) - netdev_set_tc_queue(dev, i, - mqprio->count[i], - mqprio->offset[i]); - - /* Always use supplied priority mappings */ - for (i = 0; i <= TC_BITMASK; i++) - netdev_set_prio_tc_map(dev, i, - mqprio->prio_tc_map[i]); - } - if (FULL_OFFLOAD_IS_ENABLED(taprio_flags)) { q->dequeue = taprio_dequeue_offload; q->peek = taprio_peek_offload;