Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp49371pja; Fri, 22 Nov 2019 03:18:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxF5SDWRvQ4g/aE8VzTPVsJurnJ9QpMRsANK9unES0KYkLxm7bI8UENUXNXGpuwmXPWfDdX X-Received: by 2002:a17:906:891:: with SMTP id n17mr19618795eje.230.1574421486323; Fri, 22 Nov 2019 03:18:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574421486; cv=none; d=google.com; s=arc-20160816; b=MjgGi+DJMFI5PARL9FBHOR11faMqEoCqZANbzHufj9QdyFk8XNmTHpITA641VDonme DEgNELhGVx20HwrKx4F6yorGkES0pqi1XeyfO7FcdSiHxBRYuWJTewXaaVGfC/XpID9R /wZfiNxyhA8zctgulijjtL/kmUx51dn0L4tdpnxPJ5hwIoOvYSOSZosYkFjItGLA03wq qEZ6APVTIRvjzsoRpY70XxKR7tKaf1Qz0zcA7UM0VbCZjZpRAkLsKASFE4dn0G8z9Vcu QliJc7HMTnZ8z5Bl3BwHbhhLGBILv6syXlD45/N0BqngP9dSL7S+IZRKkaUUFuvKJi28 E2fA== 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:to:subject; bh=O9nlRXrqPldC5jBtNEaaxg6O9D8AQifLpcX2UQeDSFg=; b=REWSbNK/k6JdlmVBXoFg+mBHxyBmbYDqSS+jKJM3D0zBOZPywpXvbg7PmCJTpYuY5j pmM7iNxZIu92ad6KrItCW0OmD6lYsZQhjOM6B5pwd0MpHR+O5f4HM1LvXBAFDm8x2fBj y+KK8fbC2PF0jQZltrUn9TIWkE7QRJqDy00hTQZR1Sj3RpdlsAumTbKUhrAJHPbX1La9 4d+pZxmHYklmDafof9Y8NTfc+6SfJ/IXaXmKQENbmzrqnNn/z/nwupwLzxrfrSrAjgtQ UlTpsFKIywft+xiDqLioWQVndvZqDmwNNbHxCH7mARHVJ+CX7EUZLAFldoa4+Hk0pYQx 2KoQ== 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 b27si3897752eje.95.2019.11.22.03.17.42; Fri, 22 Nov 2019 03:18:06 -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; 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 S1730227AbfKVLOb (ORCPT + 99 others); Fri, 22 Nov 2019 06:14:31 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43820 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729812AbfKVKxd (ORCPT ); Fri, 22 Nov 2019 05:53:33 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8E4B590A9B10BA22F71E; Fri, 22 Nov 2019 18:53:30 +0800 (CST) Received: from [127.0.0.1] (10.173.221.225) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Fri, 22 Nov 2019 18:53:27 +0800 Subject: Re: [PATCH] powerpc/pseries: remove variable 'status' set but not used To: Tyrel Datwyler , Michael Ellerman , , , , References: <1573873650-62511-1-git-send-email-chenwandun@huawei.com> <87blt8csyx.fsf@mpe.ellerman.id.au> From: Chen Wandun Message-ID: Date: Fri, 22 Nov 2019 18:53:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.221.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org OK, I will make a modification and repost the patch. Thanks Chen Wandun On 2019/11/21 5:34, Tyrel Datwyler wrote: > On 11/18/19 9:53 PM, Michael Ellerman wrote: >> Chen Wandun writes: >>> Fixes gcc '-Wunused-but-set-variable' warning: >>> >>> arch/powerpc/platforms/pseries/ras.c: In function ras_epow_interrupt: >>> arch/powerpc/platforms/pseries/ras.c:319:6: warning: variable status set but not used [-Wunused-but-set-variable] >> >> Thanks for the patch. >> >> But it almost certainly is wrong to not check the status. > > Agreed, I started drafting a NACK response, but got sidetracked. > >> >> It's calling firmware and just assuming that the call succeeded. It then >> goes on to use the result that should have been written by firmware, but >> is now potentially random junk. >> >> So I'd much rather a patch to change it to check the status. > > +1 > >> >>> diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c >>> index 1d7f973..4a61d0f 100644 >>> --- a/arch/powerpc/platforms/pseries/ras.c >>> +++ b/arch/powerpc/platforms/pseries/ras.c >>> @@ -316,12 +316,11 @@ static irqreturn_t ras_hotplug_interrupt(int irq, void *dev_id) >>> /* Handle environmental and power warning (EPOW) interrupts. */ >>> static irqreturn_t ras_epow_interrupt(int irq, void *dev_id) >>> { >>> - int status; >>> int state; >>> int critical; >>> >>> - status = rtas_get_sensor_fast(EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX, >>> - &state); >>> + rtas_get_sensor_fast(EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX, >>> + &state); >> >> This is calling a helper which already does some translation of the >> return value, any value < 0 indicates an error. > > There are three possible architected failures here: Hardware, Non-existant > sensor, and an DR isolation error which namely would be reported in the status > as -EIO, -EINVAL, and -EFAULT. Further, the EPOW sensor is required, and is not > a DR entity so we can never get an -EINVAL or -EFAULT (baring broken firmware). > This leaves -EIO (HARDWARE_ERROR) and as I mention further down this will > generate its own error log in response. So, I don't think we need to do any > reporting here, and just return. > >> >>> @@ -330,12 +329,12 @@ static irqreturn_t ras_epow_interrupt(int irq, void *dev_id) >>> >>> spin_lock(&ras_log_buf_lock); >>> >>> - status = rtas_call(ras_check_exception_token, 6, 1, NULL, >>> - RTAS_VECTOR_EXTERNAL_INTERRUPT, >>> - virq_to_hw(irq), >>> - RTAS_EPOW_WARNING, >>> - critical, __pa(&ras_log_buf), >>> - rtas_get_error_log_max()); >>> + rtas_call(ras_check_exception_token, 6, 1, NULL, >>> + RTAS_VECTOR_EXTERNAL_INTERRUPT, >>> + virq_to_hw(irq), >>> + RTAS_EPOW_WARNING, >>> + critical, __pa(&ras_log_buf), >>> + rtas_get_error_log_max()); >> >> This is directly calling firmware. >> >> As documented in LoPAPR, a negative status indicates an error, 0 >> indicates a new error log was found (ie. the function should continue), >> or 1 there was no error log (ie. nothing to do). > > It is highly unlikely that we will find no new error log since we are processing > an interrupt that supposedly fired to tell us there is a new one. However, the > ras_log_buf is never zeroed so in the unlikely case there is no new error log we > will parse stale data from the previous log. Better safe than sorry and just return. > > In the case of an error the only error code we supposedly can get here is -1 > (HARDWARE_ERROR), and the RTAS handling will generate an error log in response > to that. So, I don't think we need to report anything here. I would suggest for > the (status != 0) case that you just return. > > -Tyrel > >> >> cheers >> >>> log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, 0); >>> >>> -- >>> 2.7.4 > > > . >