Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp268023rdb; Thu, 8 Feb 2024 05:38:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHJI2+rCIUh5qNyB/yPv1FG5rIynyMTdQQajs0T6FdfU7D0N9o0ImewI+InFIszYUkMQOP X-Received: by 2002:a05:6214:3905:b0:68c:8218:30a2 with SMTP id nh5-20020a056214390500b0068c821830a2mr3448790qvb.0.1707399506448; Thu, 08 Feb 2024 05:38:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707399506; cv=pass; d=google.com; s=arc-20160816; b=ytiieVunmlJpKKgjGWZt2a3G7WBZw0iD/5NqerAKSZ6xSW4X+hneKGYprpoi/iDBco GRujybclcqZf6hvpqofL7PchE+uTjBHmGdTYEZ6/7susiM+WWvbpsE8LAZq7HCS8Q0ct 4eCymqrl+VmbTww9yCbf/qZ2foB55DB59o2PtAJFP8d4pRN7gsm7dCXr1tYz9gmOT1HI cZ9/O5OCHNG5n5Px9D+R7QVGEQOv660/BNl9BvcyXkpDI4KKrOF5aa5e3jIhFhlFiXxg zNGI9ChDcHP6gY4I9j5F4EQ/yNBMdirWTTV+T/DJfmNU/VtE4k5Xb0In0Oz2IoPauTHr rA2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=C1zWtWzT/FSArhgR/3Bls1Ooksd0P8H+EtPbfnf1oeI=; fh=O6pGEx1alO9pddSAU7bw7BirdDJ00fq8YF9HRc/ncyQ=; b=LWVCzrrP4B6sT50Sl2CUPosTMz3b0C3ctiN0XhxFbdAZl7mgg2rVn3m2RlVmaf1fHS jaUz2CvbPnYKRz5wc3KhwsITO9ajoBxWHZ0pTKZhgjAk2tvqg4+kywKmkUPRzQkVtdpV VQj80x8XJXbiJSeLSB2203rgEIvS2qVYlCiQuHTOIwM/PVUIEJjofcgbzfW980wqYkSH CVPAtcMywR6KzXI8JrBpJIYbVqk+6XYeG9IHGRWGCDWe1IxDORPyStCm59+cOIwgsbjX JlY6drsBvv/1V1rsGq979KhzAQ86GoJcfWghuZ8r/1LmTgpLUkcfrwZ0zu2SY3EYDOtY QupQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ro5S3DMY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-58161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUVAIDfXIISk50SUIiQNMGV0mQhlnibVpqEFtnCbuSOma03yyqfmXRyBZPIB2u5hTXs1HXppKE22qJnxQmWPoG2XikDyxWIy9ftrswK+Q== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i7-20020a05620a248700b00783f40e703fsi11602qkn.450.2024.02.08.05.38.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 05:38:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ro5S3DMY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-58161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2DF5F1C23F99 for ; Thu, 8 Feb 2024 13:38:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0DDE76C75; Thu, 8 Feb 2024 13:38:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ro5S3DMY" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F116776418; Thu, 8 Feb 2024 13:38:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707399489; cv=none; b=QsggaMKfDdGoT6H+Cn8ERwqHK3UQ7lgOil7ILm2zEMWvH0nm/IEjv2r3jd5edBDh11qUHmbttkAIpfmp8DN9p6bhaj3/oGkL51vLX1BnrmvNgZcHFJCEVSEkFO10L97kPUaPb3vB4jUbnr7JU0+z89/MC+TiTydAdY7yj1IA3Kk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707399489; c=relaxed/simple; bh=jw39fEdEP2aNbkYoy9T3GNQq4OS2fFirdRfXrG9yQG4=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=kmZAF7jPLguWafGyus9Dd5OrPO11Pns06b9AhJOSfsRniNcDX53LB0u6I1Zu8Sbk0fWMNZCkFS91MJ68ju7XK45l3NKz3XkDVyb0HsfNiTCKishMncl5i3Nv3kFhJtK6ELlrzLmWMQROYVmwACfWNKHatx5qor6kR0zIEldsPiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ro5S3DMY; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707399488; x=1738935488; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=jw39fEdEP2aNbkYoy9T3GNQq4OS2fFirdRfXrG9yQG4=; b=Ro5S3DMYSb/NgjuenzbZKRWXpQJma8940oV4TxX0gnYj2KrX1K/0Kp70 l1ZxYhNAygrIJ2wOYhibLR5bzE3hnFICjFyZFDSrHYIM4YTRh6Uggkm81 vQ86Gcgc49UR+I0KbsfRrFdT9u72TxQTkxGXUV2cVBw4LANA8m1+7eVbq 71dJ7WotiFeRL6uQzk2VTw2c8cGzOZRd8RT9gzRS39LXBHDxokblWWacq Dphhl1EnPBbWgy+Up8LvQRU4JLuLG4brnH5Mi0+f3GDSgtG1AfAK3CxlW NRWLCypiVYvM0Ua3Cddxc1tO1jjxxPtAFyi7lkPA1sr0xM4Wg9EKmumW4 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="26660912" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="26660912" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 05:38:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1889294" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.246.52.95]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 05:38:05 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Thu, 8 Feb 2024 15:38:01 +0200 (EET) To: "David E. Box" cc: Netdev , sathyanarayanan.kuppuswamy@linux.intel.com, LKML , platform-driver-x86@vger.kernel.org Subject: Re: [PATCH 2/8] platform/x86/intel/sdsi: Combine read and write mailbox flows In-Reply-To: <20240201010747.471141-3-david.e.box@linux.intel.com> Message-ID: References: <20240201010747.471141-1-david.e.box@linux.intel.com> <20240201010747.471141-3-david.e.box@linux.intel.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 On Wed, 31 Jan 2024, David E. Box wrote: > The current mailbox commands are either read-only or write-only and the > flow is different for each. New commands will need to send and receive > data. In preparation for these commands, create a common polling function > to handle sending data and receiving in the same transaction. > > Signed-off-by: David E. Box > --- > drivers/platform/x86/intel/sdsi.c | 79 +++++++++++++++++-------------- > 1 file changed, 44 insertions(+), 35 deletions(-) > > diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c > index a70c071de6e2..05a35f2f85b6 100644 > --- a/drivers/platform/x86/intel/sdsi.c > +++ b/drivers/platform/x86/intel/sdsi.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -156,8 +157,8 @@ static int sdsi_status_to_errno(u32 status) > } > } > > -static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *info, > - size_t *data_size) > +static int sdsi_mbox_poll(struct sdsi_priv *priv, struct sdsi_mbox_info *info, > + size_t *data_size) > { > struct device *dev = priv->dev; > u32 total, loop, eom, status, message_size; > @@ -166,18 +167,10 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf > > lockdep_assert_held(&priv->mb_lock); > > - /* Format and send the read command */ > - control = FIELD_PREP(CTRL_EOM, 1) | > - FIELD_PREP(CTRL_SOM, 1) | > - FIELD_PREP(CTRL_RUN_BUSY, 1) | > - FIELD_PREP(CTRL_PACKET_SIZE, info->size); > - writeq(control, priv->control_addr); > - > /* For reads, data sizes that are larger than the mailbox size are read in packets. */ > total = 0; > loop = 0; > do { > - void *buf = info->buffer + (SDSI_SIZE_MAILBOX * loop); > u32 packet_size; > > /* Poll on ready bit */ > @@ -195,6 +188,11 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf > if (ret) > break; > > + if (!packet_size) { > + sdsi_complete_transaction(priv); > + break; > + } > + > /* Only the last packet can be less than the mailbox size. */ > if (!eom && packet_size != SDSI_SIZE_MAILBOX) { > dev_err(dev, "Invalid packet size\n"); > @@ -208,9 +206,13 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf > break; > } > > - sdsi_memcpy64_fromio(buf, priv->mbox_addr, round_up(packet_size, SDSI_SIZE_CMD)); > + if (packet_size && info->buffer) { Why you check for packet_size here if you break earlier for !packet_size? > + void *buf = info->buffer + array_size(SDSI_SIZE_MAILBOX, loop); > > - total += packet_size; > + sdsi_memcpy64_fromio(buf, priv->mbox_addr, > + round_up(packet_size, SDSI_SIZE_CMD)); > + total += packet_size; > + } > > sdsi_complete_transaction(priv); > } while (!eom && ++loop < MBOX_MAX_PACKETS); > @@ -230,16 +232,33 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf > dev_warn(dev, "Read count %u differs from expected count %u\n", > total, message_size); > > - *data_size = total; > + if (data_size) > + *data_size = total; > > return 0; > } -- i.