Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4289891ybf; Wed, 4 Mar 2020 00:51:23 -0800 (PST) X-Google-Smtp-Source: ADFU+vtFjGvsn8r1KFiqVDkC/3I3+CkGtLqCUAmxl5LejZBCSYGnDvKZYxxr3oOYHfBaTnmuC154 X-Received: by 2002:a05:6830:120c:: with SMTP id r12mr1452116otp.333.1583311883775; Wed, 04 Mar 2020 00:51:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583311883; cv=none; d=google.com; s=arc-20160816; b=R+hyNAM5Yq6VGtYHIIsoFmsntkdlfgjcXqfhw28p8F8ucHzoLD/VarsfRNqbTqOjVW hFBYxl217UNlmG4OcGd56kxGHAjiHoJmzumIq05EEkr5N3T9a10XCG8dmxYFuoYmmY2x kNHRx97nkhe8jBVvyyEkls9UQKhOZH7p8nejVrESwDoUtWIm+tWQ+mLe5X/FECHL7B+C rVuf5rZVOkgbzJM3dUwcA6x7ALvpJ0RTOewHkgwJgjlWjO2ril1Gxyyh9b1iikP1bWH3 LaQDO2OoW9mYceVVUUKfcAFO8gBGddAlEoHNFKwz0qUlbhS2Zyret7VEPNatL2cvde2P mt3g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=0JcGB+sYExQaFDZtjuC7bhrD3uXfF+I4qmWNu5FYtd4=; b=fNlw6fGxEq16TdKrSKiZpIt4aBqzGO6pb5bto5UtKtz0XEYrB4DXqxGj6y0h11r1X6 /nf3WunWSbe4kTAT0VireXeSnAquzaz/Dl/vWJ3TpIcB7Up66S6ypR94h42HGxdJVF/l TfCljDBQx5/zcPWEbCqGGhd1mfoTvbbzYQICli5QEMH08DSUaJWn1wl9R6aWvyEU5Qgi WJhsqiZhEP5RhD/jClLxWvqtAhZOUkk0LTMe5r348nIFUftSOVK5qlYDuP6DPuGQdNb4 Xh/HYokemImvTt8XS7cpA61701MMukfxW6N2HPW6rlUQuHbaQ/JqQOJOAO7cpcUsJy+e V5XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WCIUYoHd; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si778715oii.54.2020.03.04.00.51.11; Wed, 04 Mar 2020 00:51:23 -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=@ti.com header.s=ti-com-17Q1 header.b=WCIUYoHd; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729061AbgCDIt7 (ORCPT + 99 others); Wed, 4 Mar 2020 03:49:59 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:46652 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725271AbgCDIt7 (ORCPT ); Wed, 4 Mar 2020 03:49:59 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0248nw7H078347; Wed, 4 Mar 2020 02:49:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1583311798; bh=0JcGB+sYExQaFDZtjuC7bhrD3uXfF+I4qmWNu5FYtd4=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=WCIUYoHdET3ZvnYO4hTmE0npbgepCGNOICZagrx+WL27oSvGeuT2yfSFeXC6XXcdZ PLfqJJ8+FHRiSz4ZVxRFHh6e0dzDWCHwpjKL7Ivk1OIMfD9CFD6aFcFloA7edUUIgn E3czcYeAvtI6XwEOTOq3MJfCSVR1MlY4VEzbcrIY= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0248nwtX093196 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Mar 2020 02:49:58 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 4 Mar 2020 02:49:57 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 4 Mar 2020 02:49:57 -0600 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0248nu2i052181; Wed, 4 Mar 2020 02:49:56 -0600 Subject: Re: [Patch 1/1] media: ti-vpe: cal: fix disable_irqs to only the intended target To: Benoit Parrot , Hans Verkuil CC: , , , stable References: <20200302135652.9365-1-bparrot@ti.com> From: Tomi Valkeinen Message-ID: <678cb62a-4fdf-3b57-2fe5-699c6bf02b2f@ti.com> Date: Wed, 4 Mar 2020 10:49:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200302135652.9365-1-bparrot@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/03/2020 15:56, Benoit Parrot wrote: > disable_irqs() was mistakenly disabling all interrupts when called. > This cause all port stream to stop even if only stopping one of them. > > Cc: stable > Signed-off-by: Benoit Parrot > --- > drivers/media/platform/ti-vpe/cal.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c > index 6e009e479be3..6d4cbb8782ed 100644 > --- a/drivers/media/platform/ti-vpe/cal.c > +++ b/drivers/media/platform/ti-vpe/cal.c > @@ -722,16 +722,16 @@ static void enable_irqs(struct cal_ctx *ctx) > > static void disable_irqs(struct cal_ctx *ctx) > { > + u32 val; > + > /* Disable IRQ_WDMA_END 0/1 */ > - reg_write_field(ctx->dev, > - CAL_HL_IRQENABLE_CLR(2), > - CAL_HL_IRQ_CLEAR, > - CAL_HL_IRQ_MASK(ctx->csi2_port)); > + val = 0; > + set_field(&val, CAL_HL_IRQ_CLEAR, CAL_HL_IRQ_MASK(ctx->csi2_port)); > + reg_write(ctx->dev, CAL_HL_IRQENABLE_CLR(2), val); > /* Disable IRQ_WDMA_START 0/1 */ > - reg_write_field(ctx->dev, > - CAL_HL_IRQENABLE_CLR(3), > - CAL_HL_IRQ_CLEAR, > - CAL_HL_IRQ_MASK(ctx->csi2_port)); > + val = 0; > + set_field(&val, CAL_HL_IRQ_CLEAR, CAL_HL_IRQ_MASK(ctx->csi2_port)); > + reg_write(ctx->dev, CAL_HL_IRQENABLE_CLR(3), val); > /* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ > reg_write(ctx->dev, CAL_CSI2_VC_IRQENABLE(1), 0); > } > I think the above works. But the enable_irqs is broken too, even if it doesn't cause any issues. Both IRQ_SET and IRQ_CLR are not supposed to be "modified" by a read-mod-write operation, but just written to. The macros used also make the code very difficult to read. Something like this fixes both irq enable and disable, and makes it readable: diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index c8b1290c9e2b..660653031a0b 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -707,15 +707,9 @@ static void cal_quickdump_regs(struct cal_dev *dev) static void enable_irqs(struct cal_ctx *ctx) { /* Enable IRQ_WDMA_END 0/1 */ - reg_write_field(ctx->dev, - CAL_HL_IRQENABLE_SET(2), - CAL_HL_IRQ_ENABLE, - CAL_HL_IRQ_MASK(ctx->csi2_port)); + reg_write(ctx->dev, CAL_HL_IRQENABLE_SET(2), 1 << (ctx->csi2_port - 1)); /* Enable IRQ_WDMA_START 0/1 */ - reg_write_field(ctx->dev, - CAL_HL_IRQENABLE_SET(3), - CAL_HL_IRQ_ENABLE, - CAL_HL_IRQ_MASK(ctx->csi2_port)); + reg_write(ctx->dev, CAL_HL_IRQENABLE_SET(3), 1 << (ctx->csi2_port - 1)); /* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write(ctx->dev, CAL_CSI2_VC_IRQENABLE(1), 0xFF000000); } @@ -723,15 +717,9 @@ static void enable_irqs(struct cal_ctx *ctx) static void disable_irqs(struct cal_ctx *ctx) { /* Disable IRQ_WDMA_END 0/1 */ - reg_write_field(ctx->dev, - CAL_HL_IRQENABLE_CLR(2), - CAL_HL_IRQ_CLEAR, - CAL_HL_IRQ_MASK(ctx->csi2_port)); + reg_write(ctx->dev, CAL_HL_IRQENABLE_CLR(2), 1 << (ctx->csi2_port - 1)); /* Disable IRQ_WDMA_START 0/1 */ - reg_write_field(ctx->dev, - CAL_HL_IRQENABLE_CLR(3), - CAL_HL_IRQ_CLEAR, - CAL_HL_IRQ_MASK(ctx->csi2_port)); + reg_write(ctx->dev, CAL_HL_IRQENABLE_CLR(3), 1 << (ctx->csi2_port - 1)); /* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write(ctx->dev, CAL_CSI2_VC_IRQENABLE(1), 0); } Tomi -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki