From patchwork Fri Jun 28 13:15:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 13716130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3EF9C41513 for ; Fri, 28 Jun 2024 13:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=pF6qyRzw+V6njkwCTZiylR/wM1L1cTjKycIHMF9+NX0=; b=tzQC04+zOsBqQC KIKNN9di+DYdZdA/mpMd6RFBQ/VuiQB/I6SwqDZ0B+ZrrKHzZ06pSXDoqVje2PiqGzPguctA/28iM NKSXjEYSsbU7Hskkp66oplQoI4AeXseaak2r2U4YHu/lGPpi323cKL0HCk6qlwUmOprWwlO7JXcAj Z8b8jcnm1Qd4yIYiPqw9OY0a1bKenSMb6anJN+/qkAV2UQPV5jUOCVuwZ7RFDcYLzhAxtDhXnTVEP aRpHMPEf+Okhk8ghFldK77zVyPtp0PF05XS5he5a4ZExQUh+26Mw9eHyygYeC2Juhj8TavNtvXy7I RcLcMr5zExe7EIexs9HQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBTG-0000000DnS1-2VtX; Fri, 28 Jun 2024 13:16:58 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBTB-0000000DnPK-474o for linux-i3c@lists.infradead.org; Fri, 28 Jun 2024 13:16:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719580614; x=1751116614; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=irzIus5OI2eTQAhpmhykVb27sR0xfzW3UdLILIUlgx0=; b=fv9Nl+MAPx4pkJ0kf2uSngXLIfe/Yq1gMIaCKF47EZAC6jHGBosiA0Gq PDF868lRWZ5aLYnRxAEh1f4hCUZ9tu2RX1u/Gj5vrH8iXUd4wQktVwrpR 17jMOIcC+vyCx7G4NO7AwMbHaRnMT69jxyA9t/1tEibxLtyMwAD0OoktM vrKJRMIOYsCkFQoCgof9CQVctyKwwGELSRjcJNLJPUTO3TvaVEXo3C9pk QJKQRZhPwhvjkYyf+PzzSShd5weUzNGv29uwTlyXHXzE9IeHFbJ1L6RVW 4pZJfCRe67ip4kKbXncJe1NK5ZZGT25YJGqChm0nvMj21sh41nuJ5z1st Q==; X-CSE-ConnectionGUID: wULrZcMBRdWQUty4g8h5mg== X-CSE-MsgGUID: 3nnCU2zWSJmC8qM0qwL+Dw== X-IronPort-AV: E=McAfee;i="6700,10204,11116"; a="34300181" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="34300181" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 06:16:49 -0700 X-CSE-ConnectionGUID: qbYYc+9+QamUcRt+/37yyw== X-CSE-MsgGUID: fHFvrv9fTPGAbzSFdAHoMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="49213803" Received: from ehlflashnuc2.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.57]) by fmviesa005.fm.intel.com with ESMTP; 28 Jun 2024 06:16:48 -0700 From: Jarkko Nikula To: linux-i3c@lists.infradead.org Cc: Alexandre Belloni , Jarkko Nikula Subject: [PATCH 1/4] i3c: mipi-i3c-hci: Switch to lower_32_bits()/upper_32_bits() helpers Date: Fri, 28 Jun 2024 16:15:56 +0300 Message-ID: <20240628131559.502822-1-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_061654_082075_BCBD1D44 X-CRM114-Status: GOOD ( 10.20 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Rather than having own lo32()/hi32() helpers for dealing with 32-bit and 64-bit build targets switch to generic lower_32_bits()/upper_32_bits() helpers. Signed-off-by: Jarkko Nikula --- drivers/i3c/master/mipi-i3c-hci/dma.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c index 4e01a95cc4d0..6c5964e727b3 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dma.c +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c @@ -147,21 +147,6 @@ struct hci_dma_dev_ibi_data { unsigned int max_len; }; -static inline u32 lo32(dma_addr_t physaddr) -{ - return physaddr; -} - -static inline u32 hi32(dma_addr_t physaddr) -{ - /* trickery to avoid compiler warnings on 32-bit build targets */ - if (sizeof(dma_addr_t) > 4) { - u64 hi = physaddr; - return hi >> 32; - } - return 0; -} - static void hci_dma_cleanup(struct i3c_hci *hci) { struct hci_rings_data *rings = hci->io_data; @@ -265,10 +250,10 @@ static int hci_dma_init(struct i3c_hci *hci) if (!rh->xfer || !rh->resp || !rh->src_xfers) goto err_out; - rh_reg_write(CMD_RING_BASE_LO, lo32(rh->xfer_dma)); - rh_reg_write(CMD_RING_BASE_HI, hi32(rh->xfer_dma)); - rh_reg_write(RESP_RING_BASE_LO, lo32(rh->resp_dma)); - rh_reg_write(RESP_RING_BASE_HI, hi32(rh->resp_dma)); + rh_reg_write(CMD_RING_BASE_LO, lower_32_bits(rh->xfer_dma)); + rh_reg_write(CMD_RING_BASE_HI, upper_32_bits(rh->xfer_dma)); + rh_reg_write(RESP_RING_BASE_LO, lower_32_bits(rh->resp_dma)); + rh_reg_write(RESP_RING_BASE_HI, upper_32_bits(rh->resp_dma)); regval = FIELD_PREP(CR_RING_SIZE, rh->xfer_entries); rh_reg_write(CR_SETUP, regval); @@ -404,8 +389,8 @@ static int hci_dma_queue_xfer(struct i3c_hci *hci, hci_dma_unmap_xfer(hci, xfer_list, i); return -ENOMEM; } - *ring_data++ = lo32(xfer->data_dma); - *ring_data++ = hi32(xfer->data_dma); + *ring_data++ = lower_32_bits(xfer->data_dma); + *ring_data++ = upper_32_bits(xfer->data_dma); } else { *ring_data++ = 0; *ring_data++ = 0; From patchwork Fri Jun 28 13:15:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 13716131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1552C3064D for ; Fri, 28 Jun 2024 13:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5ee+w9vIPN09vZJfEiq4GZTlZeojhaby3DYPp8JeN/4=; b=StUEY53MSRiZDn eUtIcLcO+tDBUS2rIxGgwiZKQfrqAspEui/lR/FJ6gYGxYQyiFaedmagJhh/vatayvZo6GntmY3jF d+bT+dYVNdtWKcpcZEX9fJqbXIowlS9hp/sURjNufWjUnpcJrAGZdNVCK6z3jjStGQt1OaNCZe61c 4OT6FbkcMP169mw8wlQmHahA3vuksb94+Dj4ex3ONOwAnU6WvYhNUeuQEHUVuGOA3Zn+4vHYcm5st XBkLYYQcWwO4wA4WbkUKJsWoEL7zSbyEhYlcf5YJcrHpRLLV26Yogv1H7XxRWE0iai5SPW2Pa/cNF hQFrxh9u/IKbMNFs0PsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBTG-0000000DnRp-1EwX; Fri, 28 Jun 2024 13:16:58 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBTC-0000000DnPX-04D8 for linux-i3c@lists.infradead.org; Fri, 28 Jun 2024 13:16:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719580614; x=1751116614; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JGeu7VXXdsbIAF/roxcLS+MKjkW09l3gYPODT6BnB7E=; b=bNVtbLi8G4hYklpmQFus5nH3er4w1kMfV37j5d8/BOEUqh8BTIq2n/8E DeiobDxsVfLNDjYdx0duUzwP6XIRyZJCevV9jlYIK6ExRGx19M9ybpJ2K +kuBxdyNShTMxtElxrxSaOMQa0bhkM9eTgk6pbnKHdVkFZA+59eM570Rg 2XlaazNJA47oldpyA01bxQ/PPxW1sESl9YaxUfuxoaMu6Md4mGZi3zHbY p5LbkEUEU5fQBoDmCCn0wJWluKEC48ZGIqioaKcbn+dPTdTqBGJ7Mpk08 v+atYITSxLcyUAO7Uqc68H34La+4fnI9tcZEBPfLm3r+dkXmT2GyDcILh Q==; X-CSE-ConnectionGUID: iZmNQ0GZR3KF6+ANhDFYKw== X-CSE-MsgGUID: rpigACmnQMSEnO1rY2tvnQ== X-IronPort-AV: E=McAfee;i="6700,10204,11116"; a="34300183" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="34300183" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 06:16:50 -0700 X-CSE-ConnectionGUID: C0kDplXTSYO5mPT59ZD75g== X-CSE-MsgGUID: FyGRJNAeTMC1Oz/gh0xJNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="49213804" Received: from ehlflashnuc2.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.57]) by fmviesa005.fm.intel.com with ESMTP; 28 Jun 2024 06:16:49 -0700 From: Jarkko Nikula To: linux-i3c@lists.infradead.org Cc: Alexandre Belloni , Jarkko Nikula Subject: [PATCH 2/4] i3c: mipi-i3c-hci: Set IBI Status and Data Ring base addresses Date: Fri, 28 Jun 2024 16:15:57 +0300 Message-ID: <20240628131559.502822-2-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628131559.502822-1-jarkko.nikula@linux.intel.com> References: <20240628131559.502822-1-jarkko.nikula@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_061654_117055_7F0C2DCE X-CRM114-Status: UNSURE ( 6.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org IBI Status and Data Ring base address registers are not set so HW obviously cannot update those rings after In-Band Interrupt. Set them to already allocated and mapped ring addresses. Signed-off-by: Jarkko Nikula --- drivers/i3c/master/mipi-i3c-hci/dma.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c index 6c5964e727b3..7a56ae4a5ddf 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dma.c +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c @@ -300,6 +300,11 @@ static int hci_dma_init(struct i3c_hci *hci) goto err_out; } + rh_reg_write(IBI_STATUS_RING_BASE_LO, lower_32_bits(rh->ibi_status_dma)); + rh_reg_write(IBI_STATUS_RING_BASE_HI, upper_32_bits(rh->ibi_status_dma)); + rh_reg_write(IBI_DATA_RING_BASE_LO, lower_32_bits(rh->ibi_data_dma)); + rh_reg_write(IBI_DATA_RING_BASE_HI, upper_32_bits(rh->ibi_data_dma)); + regval = FIELD_PREP(IBI_STATUS_RING_SIZE, rh->ibi_status_entries) | FIELD_PREP(IBI_DATA_CHUNK_SIZE, From patchwork Fri Jun 28 13:15:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 13716133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49C80C30658 for ; Fri, 28 Jun 2024 13:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SzGrX4wpIrftdHamH4Z16SeZcuUH/A199m87ADoWaPI=; b=q18D+0a7uTK0Kr K7xJ/0mWtBM/1pATue5AMHPNUNxZXwXWqUCRVzbZqmb5BWsvXMPNwohyseDzAnB20Ru3Yjuxl6xE5 TgMz7P8lesrvrrQqwLm7YgENeijkmfQC07ND5rcLvR6RVRK4vWHx3MSXLf6TKWf+qhsWmwomKNYVn QLHWqHFp99IcOpnMtKRopKrwfy5+TLu0WvAX5E+Fek0bcHbc4DmlcB5qxFfq9VxSXwYKhBLpT2Fwj 2wigD3g0IKIcPe3t5eDNMYCADtkXyhT0IvvdQOTHGE+eu2ZRIOdbaeyMgdAoDW+YSc5hOxRw+v10K amMzs876hjPPxD51JzdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBTG-0000000DnSG-3sur; Fri, 28 Jun 2024 13:16:58 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBTD-0000000DnPK-3EKV for linux-i3c@lists.infradead.org; Fri, 28 Jun 2024 13:16:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719580616; x=1751116616; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DU/Yrr4XaHlbDsC0krOE7vOrnN7UkzY/edYfGr8JE9o=; b=JZxElEOr+el8CpBtYHSxnx8sNtVBzvpBmDlVSZQ4R7HZc/hSDm6Hr6Gq bYckH/RjAMEFn0ON/4fxdsB4hb5dftWqgEOlOpWqqWUT675mIXsFaa4j1 PMK8uCHbS7efADumXpmCjYbnOWe4R8W4gfIczwl90a2AyJ7D/tkKdyvbe VpQaWFQp9mAk+iwPLjyRvcpIDJZ0w4NIm5FOwrVZgzuzace3Ayss6rb8p aqFMLzc6JPuHlj7K0aIyWiDNIwuazNPZ2o17xiCb2OsWjvg/tvp8XyVwU UwStjYAEijHDw25LlwuhalZ7NYETHLMk2G+RTZDzI8Lt4xRYB0xzHr8k8 Q==; X-CSE-ConnectionGUID: MbGXA0cyTUGp8ffsqK/diw== X-CSE-MsgGUID: x+OJANxCSQ2ViEDiXqIXUA== X-IronPort-AV: E=McAfee;i="6700,10204,11116"; a="34300190" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="34300190" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 06:16:52 -0700 X-CSE-ConnectionGUID: xFDQf724QISp3+ZsBU+oBQ== X-CSE-MsgGUID: Tv/QNpf0Suq4mNqYWXd4lw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="49213806" Received: from ehlflashnuc2.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.57]) by fmviesa005.fm.intel.com with ESMTP; 28 Jun 2024 06:16:51 -0700 From: Jarkko Nikula To: linux-i3c@lists.infradead.org Cc: Alexandre Belloni , Jarkko Nikula Subject: [PATCH 3/4] i3c: mipi-i3c-hci: Error out instead on BUG_ON() in IBI DMA setup Date: Fri, 28 Jun 2024 16:15:58 +0300 Message-ID: <20240628131559.502822-3-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628131559.502822-1-jarkko.nikula@linux.intel.com> References: <20240628131559.502822-1-jarkko.nikula@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_061655_965789_E6B24754 X-CRM114-Status: UNSURE ( 9.98 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Definitely condition dma_get_cache_alignment * defined value > 256 during driver initialization is not reason to BUG_ON(). Turn that to graceful error out with -EINVAL. Signed-off-by: Jarkko Nikula --- drivers/i3c/master/mipi-i3c-hci/dma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c index 7a56ae4a5ddf..9bdfe40bc1e1 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dma.c +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c @@ -279,7 +279,10 @@ static int hci_dma_init(struct i3c_hci *hci) rh->ibi_chunk_sz = dma_get_cache_alignment(); rh->ibi_chunk_sz *= IBI_CHUNK_CACHELINES; - BUG_ON(rh->ibi_chunk_sz > 256); + if (rh->ibi_chunk_sz > 256) { + ret = -EINVAL; + goto err_out; + } ibi_status_ring_sz = rh->ibi_status_sz * rh->ibi_status_entries; ibi_data_ring_sz = rh->ibi_chunk_sz * rh->ibi_chunks_total; From patchwork Fri Jun 28 13:15:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 13716132 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FEB4C3065B for ; Fri, 28 Jun 2024 13:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q1IWU75CxfVmHOsIY3S4yyorb+ZmELG29f4OzRjp5B0=; b=xyhJfWJVHpRJIv mq1PpukJQ5wUeuraUZTaG3GzkXNKq31+WQKmPzr7+2NBiDyaLCNzsNqJkUj4QB43p13noD1xwpgC2 d7vOuQAWzunIQ5gsHfjA11WpEOcI2ZGfudSYeeD96+Y60CfJl0oLK9fl/MAB/ebJdq/ac5Z+IoLWq D6WHT9Ld64e5Mc0DRFRG5eTlI+ZMOsiaeqHOBw6bvVF5apUqvxhgj21lU4YEmjQcr6PYcWwE2tAnF Tm63sITwacZqQN6kYmY3JOJJ816d8BwBHg8c2xZAd7Y2d9wMDt6Kjz8eMBlW4fteXWFmZ0SwxItau XW7bhqYkatCNIbMtP8PQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBTH-0000000DnSV-11Rm; Fri, 28 Jun 2024 13:16:59 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBTD-0000000DnPX-3EBT for linux-i3c@lists.infradead.org; Fri, 28 Jun 2024 13:16:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719580616; x=1751116616; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z21wmrskk3ZtoTZKSZUQzAUxQFElN0J78z98EF392QM=; b=M9XD3ub460s+Fvdczl+q6MJtjC1z/fyjO6Ccs/LXpa2AV53OMZpIZQb1 5yS3iC3GViKGvGx5yqH6muz1h1nGyJJeiArhE/B/d94cD2dnk0cC0+JFS VWG+jALvCN8RhjhL+p7M11NU0h8Yk+6MSiUbNMfxZ0PliL5G9+IndSmpe M74WfZpmbSssR/ERYAGsZa/kDUGtGNlPFUo6ydJTfOkkhyGP03Z+nTVy8 kEssWiMsnuUxxwXBD58C6RLIqh7KglO/IBZlm+vgmSoVNs7xFYUYFwnws LNmUTYi1DGn8jGfK1ukAlpst0Sq9/PRGyXXW1iTItux/0iEKRbQrKZzQu g==; X-CSE-ConnectionGUID: Ra3gplm1QvWz6gj+0AKfQw== X-CSE-MsgGUID: Gg2RhDs0S2+m9Oez8kTWCg== X-IronPort-AV: E=McAfee;i="6700,10204,11116"; a="34300195" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="34300195" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 06:16:53 -0700 X-CSE-ConnectionGUID: AnyF1SAYTUudS9NSVJHAWQ== X-CSE-MsgGUID: j7PtHIWmRq2lFjY5eYQ9tA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="49213807" Received: from ehlflashnuc2.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.57]) by fmviesa005.fm.intel.com with ESMTP; 28 Jun 2024 06:16:52 -0700 From: Jarkko Nikula To: linux-i3c@lists.infradead.org Cc: Alexandre Belloni , Jarkko Nikula Subject: [PATCH 4/4] i3c: mipi-i3c-hci: Round IBI data chunk size to HW supported value Date: Fri, 28 Jun 2024 16:15:59 +0300 Message-ID: <20240628131559.502822-4-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628131559.502822-1-jarkko.nikula@linux.intel.com> References: <20240628131559.502822-1-jarkko.nikula@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_061655_961060_975F2F30 X-CRM114-Status: UNSURE ( 8.68 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org The dma.c: hci_dma_init() sets the CHUNK_SIZE field in the IBI_SETUP register incorrectly if the calculated ibi_chunk_sz is not exactly 2^(n+2) bytes, where n is 0..6. Fix this by rounding the chunk size up to nearest 2^(n+2) bytes. Signed-off-by: Jarkko Nikula --- drivers/i3c/master/mipi-i3c-hci/dma.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c index 9bdfe40bc1e1..a918e96b21fd 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dma.c +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c @@ -279,6 +279,13 @@ static int hci_dma_init(struct i3c_hci *hci) rh->ibi_chunk_sz = dma_get_cache_alignment(); rh->ibi_chunk_sz *= IBI_CHUNK_CACHELINES; + /* + * Round IBI data chunk size to number of bytes supported by + * the HW. Chunk size can be 2^n number of DWORDs which is the + * same as 2^(n+2) bytes, where n is 0..6. + */ + rh->ibi_chunk_sz = umax(4, rh->ibi_chunk_sz); + rh->ibi_chunk_sz = roundup_pow_of_two(rh->ibi_chunk_sz); if (rh->ibi_chunk_sz > 256) { ret = -EINVAL; goto err_out;