From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EB6E1FA844 for ; Fri, 3 Jan 2025 13:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735909327; cv=none; b=NgWY/aeJoY+StktGnS/aStCVvywIMtpd8YKSRB07t3u5IUKtSDfncwDYvQXgFfP2l0pXX+MSDmRmH7/ZyQ2Xr57+btYKXSueVtEL2kKQs1i0xOoSQQW9umaHLsndvpYqeXVd+xSkwRUHtKo7FT8ZX1awvs7ToG60RA3nS+ZWzJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735909327; c=relaxed/simple; bh=n2+4f2ARt1fLyK9oTYyqZeVMpFgSIlboWWq54+BiR48=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q5AnfwVkBHKeMJb8frtb+q0Q98cQzVO5bRndLicACarsL6iA7Yc/94amHgjoH6WdHFOCG3qAf4r0hTYDdQbkRuGkruPpPJt9x9dy5CubjYnyzndEorCklfUhq0/4anOyL78WLZKXROF6fJ9+KOF6RGo7cgxp8Jy2LJn8Nl4AfTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=minyard.net; spf=none smtp.mailfrom=minyard.net; dkim=pass (2048-bit key) header.d=minyard-net.20230601.gappssmtp.com header.i=@minyard-net.20230601.gappssmtp.com header.b=qzc68uCX; arc=none smtp.client-ip=209.85.210.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=minyard.net Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=minyard.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=minyard-net.20230601.gappssmtp.com header.i=@minyard-net.20230601.gappssmtp.com header.b="qzc68uCX" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-71e163493efso7763083a34.3 for ; Fri, 03 Jan 2025 05:02:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minyard-net.20230601.gappssmtp.com; s=20230601; t=1735909324; x=1736514124; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=kwslepnGSbcUTKLuxRUjLV9/n9Tgqc36suysjk6sk7w=; b=qzc68uCXXf4qcAYuCCLr9dGfPuyyxXMZvvZ3DAWALinnaRQfp9rGEi+GwXNJIN1RaD lKSaUt57GG4TyX30G+c0Dysoe1VQYmLz4fPCxY5AHeI8usXnf52n3eSyyVRj/tFZ5Qam ereosYOTK35H5ot6UDibB4apAa75/HjU9mZcBUXwS3Te6n5/U5A+xvUAPCJAPu5hEi3U j8SgLAdWMaQe4J973CtpyV+PNysSaeVkWLh2mWyfx+B+Co1zyvJNrM0K1NGaZm47jK8R LuqJy7tGVHE9/2f0dRTpJ2pK05lunDQyk+Xk/3tn+iHulCY85swkJMFH65nD+CffLNlC +SHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735909324; x=1736514124; h=in-reply-to:content-disposition:mime-version:references:reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kwslepnGSbcUTKLuxRUjLV9/n9Tgqc36suysjk6sk7w=; b=CWuFap1fB+iqyrxCmAlhSFsrpXuNk1hchOEDX9+P4vsV9mn2mKUTLyLELciIXVaS0X diowGQ0OrtpXcurEZwBAtmSZRZ25P+ADySWzO/8uCSe9KuLXoWfG2lXQ4yKSeQlZ18Mm Ng+/xZsVuOoDj+2aUSR+hOJtYK4brtM7rAyzTWBZfVytirbUK87V/hqQRjfsvig/QKkr mhzXh9yXickMq1AnYRsTQ2sRqDAEUy/oOESDZLS6cRuV8jeRU/d5gKtWYAFtFVk+cqd4 i+IcsLVQGndStIpT3k/zlKNoi4WIECixUXHR7B5VqUFaHyLg8/uVaev+19M5Ct7akcSL NHDA== X-Forwarded-Encrypted: i=1; AJvYcCWrwtkeaKUGMlnjv7L3sKmVITYzAj8lzJToVS9xIWr2qG6CFfpiEt6G4DhDvNKfCzhqwlmwGERB/0tblhU=@vger.kernel.org X-Gm-Message-State: AOJu0YxeyD+42KehL2ddOI66yxTiA+GJdizDbVLqnlpuB5W4y5SsTDas o1lgCCAx6PqnvTNAo/NCa9jGQmARj1OtYl/KbHzxobDU6UzANRWMVrjeOgoSjuM= X-Gm-Gg: ASbGncvRps0TCIGjYSetxonW2H91fglyDG5HFZpk9gCIu0Ak14rmqF6Lwt2g9R3sGNk Vs/e1xTg85lfWLMuXIyqia5ZB0Lj+y8p7MXOwTyhnPnnc4rUwhqMUunY5ACQjmxajLq9LYDshlt +mjZ+tNnWZkVCV/xswg/UW3/rriNowc3iiAiTOpjPGa4ZWZJCvYsWAC12NrVKFeEE3+c8gXbdgH GSj2BHd4IOeoRd7Pm9mBYmPXq+62iaeu6dK2KRBSX+rjavMV0U5xr9gMEwc X-Google-Smtp-Source: AGHT+IFqSJg1bPoYXPE1KKsn0KYetjUPM+I0u/NVnIIThCGd6JpnoHvogaJhfdTx5yTrKznPRCuY5g== X-Received: by 2002:a05:6830:903:b0:717:f666:9559 with SMTP id 46e09a7af769-720ff6c837fmr25104369a34.9.1735909324195; Fri, 03 Jan 2025 05:02:04 -0800 (PST) Received: from mail.minyard.net ([2001:470:b8f6:1b:81ab:b2d6:d879:cada]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97dca80sm7991059a34.37.2025.01.03.05.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 05:02:02 -0800 (PST) Date: Fri, 3 Jan 2025 07:01:57 -0600 From: Corey Minyard To: Quan Nguyen Cc: Cosmo Chou , openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, cosmo.chou@quantatw.com, potin.lai@quantatw.com, minyard@acm.org Subject: Re: [PATCH] ipmi: ssif_bmc: Move smbus_cmd assignment after cleanup Message-ID: Reply-To: corey@minyard.net References: <20250101165431.2113407-1-chou.cosmo@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jan 03, 2025 at 10:44:46AM +0700, Quan Nguyen wrote: > > > On 01/01/2025 23:54, Cosmo Chou wrote: > > Move smbus_cmd assignment to the end of process_smbus_cmd() to ensure > > the new command is not lost when complete_response() is triggered. > > > > Thanks Cosmo for the catch. > > And, IMHO, the root cause is the memset() on part buffer called in > complete_response() is not quite correct. In the current implementation, the > complete_response() should only be called when the READ is completed, ie: > only on I2C_SLAVE_STOP of READ transaction, otherwise all the info of > current on-going request will be mistakenly cleared as in this case. > > This patch is good and I wonder if we can make this a bit further as below? Yes, this is probably more future proof. Can you send me a formal patch, with a "Found-by:" for Cosmo? I'll replace Cosmo's patch. Thanks, -corey > > diff --git a/drivers/char/ipmi/ssif_bmc.c b/drivers/char/ipmi/ssif_bmc.c > index a14fafc583d4..310f17dd9511 100644 > --- a/drivers/char/ipmi/ssif_bmc.c > +++ b/drivers/char/ipmi/ssif_bmc.c > @@ -292,7 +292,6 @@ static void complete_response(struct ssif_bmc_ctx > *ssif_bmc) > ssif_bmc->nbytes_processed = 0; > ssif_bmc->remain_len = 0; > ssif_bmc->busy = false; > - memset(&ssif_bmc->part_buf, 0, sizeof(struct ssif_part_buffer)); > wake_up_all(&ssif_bmc->wait_queue); > } > > @@ -744,9 +743,11 @@ static void on_stop_event(struct ssif_bmc_ctx > *ssif_bmc, u8 *val) > ssif_bmc->aborting = true; > } > } else if (ssif_bmc->state == SSIF_RES_SENDING) { > - if (ssif_bmc->is_singlepart_read || ssif_bmc->block_num == > 0xFF) > + if (ssif_bmc->is_singlepart_read || ssif_bmc->block_num == > 0xFF) { > + memset(&ssif_bmc->part_buf, 0, sizeof(struct > ssif_part_buffer)); > /* Invalidate response buffer to denote it is sent > */ > complete_response(ssif_bmc); > + } > ssif_bmc->state = SSIF_READY; > } > > Thanks and Happy New Year. > - Quan