Skip to content

Commit e9b5bbb

Browse files
committed
Merge: Bluefield-3 assorted upstream fixes
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4614 JIRA: https://issues.redhat.com/browse/RHEL-45234 This MR contains assorted Bluefield-3 drivers fixes from upstream up to 6.10-rc5. Fixed drivers are: mlxbf-bootctl, mlxbf-pmc, mlxbf-tmfifo, sdhci-of-dwcmshc. Performed basic testing only: * Boot test * Copied files through tmfifo networking * Checked mlxbf-bootctl and mlxbf-pmc functionality * Load & reload of shci-of-dwcmshc and file copy to mmc partition Signed-off-by: Luiz Capitulino <luizcap@redhat.com> Approved-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: Mark Salter <msalter@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Approved-by: Lucas Zampieri <lzampier@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents c1384e4 + 80e2100 commit e9b5bbb

File tree

4 files changed

+98
-22
lines changed

4 files changed

+98
-22
lines changed

drivers/mmc/host/sdhci-of-dwcmshc.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -584,15 +584,32 @@ static int dwcmshc_probe(struct platform_device *pdev)
584584
return err;
585585
}
586586

587+
static void dwcmshc_disable_card_clk(struct sdhci_host *host)
588+
{
589+
u16 ctrl;
590+
591+
ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
592+
if (ctrl & SDHCI_CLOCK_CARD_EN) {
593+
ctrl &= ~SDHCI_CLOCK_CARD_EN;
594+
sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL);
595+
}
596+
}
597+
587598
static void dwcmshc_remove(struct platform_device *pdev)
588599
{
589600
struct sdhci_host *host = platform_get_drvdata(pdev);
590601
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
591602
struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
592603
struct rk35xx_priv *rk_priv = priv->priv;
593604

605+
pm_runtime_get_sync(&pdev->dev);
606+
pm_runtime_disable(&pdev->dev);
607+
pm_runtime_put_noidle(&pdev->dev);
608+
594609
sdhci_remove_host(host, 0);
595610

611+
dwcmshc_disable_card_clk(host);
612+
596613
clk_disable_unprepare(pltfm_host->clk);
597614
clk_disable_unprepare(priv->bus_clk);
598615
if (rk_priv)
@@ -684,17 +701,6 @@ static void dwcmshc_enable_card_clk(struct sdhci_host *host)
684701
}
685702
}
686703

687-
static void dwcmshc_disable_card_clk(struct sdhci_host *host)
688-
{
689-
u16 ctrl;
690-
691-
ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
692-
if (ctrl & SDHCI_CLOCK_CARD_EN) {
693-
ctrl &= ~SDHCI_CLOCK_CARD_EN;
694-
sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL);
695-
}
696-
}
697-
698704
static int dwcmshc_runtime_suspend(struct device *dev)
699705
{
700706
struct sdhci_host *host = dev_get_drvdata(dev);

drivers/platform/mellanox/mlxbf-bootctl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static ssize_t large_icm_show(struct device *dev,
463463
if (res.a0)
464464
return -EPERM;
465465

466-
return snprintf(buf, PAGE_SIZE, "0x%lx", res.a1);
466+
return sysfs_emit(buf, "0x%lx", res.a1);
467467
}
468468

469469
static ssize_t large_icm_store(struct device *dev,
@@ -581,7 +581,7 @@ static ssize_t opn_show(struct device *dev,
581581
}
582582
mutex_unlock(&mfg_ops_lock);
583583

584-
return snprintf(buf, PAGE_SIZE, "%s", (char *)opn_data);
584+
return sysfs_emit(buf, "%s", (char *)opn_data);
585585
}
586586

587587
static ssize_t opn_store(struct device *dev,
@@ -632,7 +632,7 @@ static ssize_t sku_show(struct device *dev,
632632
}
633633
mutex_unlock(&mfg_ops_lock);
634634

635-
return snprintf(buf, PAGE_SIZE, "%s", (char *)sku_data);
635+
return sysfs_emit(buf, "%s", (char *)sku_data);
636636
}
637637

638638
static ssize_t sku_store(struct device *dev,
@@ -683,7 +683,7 @@ static ssize_t modl_show(struct device *dev,
683683
}
684684
mutex_unlock(&mfg_ops_lock);
685685

686-
return snprintf(buf, PAGE_SIZE, "%s", (char *)modl_data);
686+
return sysfs_emit(buf, "%s", (char *)modl_data);
687687
}
688688

689689
static ssize_t modl_store(struct device *dev,
@@ -734,7 +734,7 @@ static ssize_t sn_show(struct device *dev,
734734
}
735735
mutex_unlock(&mfg_ops_lock);
736736

737-
return snprintf(buf, PAGE_SIZE, "%s", (char *)sn_data);
737+
return sysfs_emit(buf, "%s", (char *)sn_data);
738738
}
739739

740740
static ssize_t sn_store(struct device *dev,
@@ -785,7 +785,7 @@ static ssize_t uuid_show(struct device *dev,
785785
}
786786
mutex_unlock(&mfg_ops_lock);
787787

788-
return snprintf(buf, PAGE_SIZE, "%s", (char *)uuid_data);
788+
return sysfs_emit(buf, "%s", (char *)uuid_data);
789789
}
790790

791791
static ssize_t uuid_store(struct device *dev,
@@ -836,7 +836,7 @@ static ssize_t rev_show(struct device *dev,
836836
}
837837
mutex_unlock(&mfg_ops_lock);
838838

839-
return snprintf(buf, PAGE_SIZE, "%s", (char *)rev_data);
839+
return sysfs_emit(buf, "%s", (char *)rev_data);
840840
}
841841

842842
static ssize_t rev_store(struct device *dev,

drivers/platform/mellanox/mlxbf-pmc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,8 +1505,9 @@ static ssize_t mlxbf_pmc_counter_show(struct device *dev,
15051505
{
15061506
struct mlxbf_pmc_attribute *attr_counter = container_of(
15071507
attr, struct mlxbf_pmc_attribute, dev_attr);
1508-
unsigned int blk_num, cnt_num, offset;
1508+
unsigned int blk_num, cnt_num;
15091509
bool is_l3 = false;
1510+
int offset;
15101511
u64 value;
15111512

15121513
blk_num = attr_counter->nr;
@@ -1539,9 +1540,10 @@ static ssize_t mlxbf_pmc_counter_store(struct device *dev,
15391540
{
15401541
struct mlxbf_pmc_attribute *attr_counter = container_of(
15411542
attr, struct mlxbf_pmc_attribute, dev_attr);
1542-
unsigned int blk_num, cnt_num, offset, data;
1543+
unsigned int blk_num, cnt_num, data;
15431544
bool is_l3 = false;
15441545
u64 evt_num;
1546+
int offset;
15451547
int err;
15461548

15471549
blk_num = attr_counter->nr;
@@ -1621,8 +1623,9 @@ static ssize_t mlxbf_pmc_event_store(struct device *dev,
16211623
{
16221624
struct mlxbf_pmc_attribute *attr_event = container_of(
16231625
attr, struct mlxbf_pmc_attribute, dev_attr);
1624-
unsigned int blk_num, cnt_num, evt_num;
1626+
unsigned int blk_num, cnt_num;
16251627
bool is_l3 = false;
1628+
int evt_num;
16261629
int err;
16271630

16281631
blk_num = attr_event->nr;

drivers/platform/mellanox/mlxbf-tmfifo.c

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
/* Message with data needs at least two words (for header & data). */
4848
#define MLXBF_TMFIFO_DATA_MIN_WORDS 2
4949

50+
/* Tx timeout in milliseconds. */
51+
#define TMFIFO_TX_TIMEOUT 2000
52+
5053
/* ACPI UID for BlueField-3. */
5154
#define TMFIFO_BF3_UID 1
5255

@@ -62,12 +65,14 @@ struct mlxbf_tmfifo;
6265
* @drop_desc: dummy desc for packet dropping
6366
* @cur_len: processed length of the current descriptor
6467
* @rem_len: remaining length of the pending packet
68+
* @rem_padding: remaining bytes to send as paddings
6569
* @pkt_len: total length of the pending packet
6670
* @next_avail: next avail descriptor id
6771
* @num: vring size (number of descriptors)
6872
* @align: vring alignment size
6973
* @index: vring index
7074
* @vdev_id: vring virtio id (VIRTIO_ID_xxx)
75+
* @tx_timeout: expire time of last tx packet
7176
* @fifo: pointer to the tmfifo structure
7277
*/
7378
struct mlxbf_tmfifo_vring {
@@ -79,19 +84,21 @@ struct mlxbf_tmfifo_vring {
7984
struct vring_desc drop_desc;
8085
int cur_len;
8186
int rem_len;
87+
int rem_padding;
8288
u32 pkt_len;
8389
u16 next_avail;
8490
int num;
8591
int align;
8692
int index;
8793
int vdev_id;
94+
unsigned long tx_timeout;
8895
struct mlxbf_tmfifo *fifo;
8996
};
9097

9198
/* Check whether vring is in drop mode. */
9299
#define IS_VRING_DROP(_r) ({ \
93100
typeof(_r) (r) = (_r); \
94-
(r->desc_head == &r->drop_desc ? true : false); })
101+
r->desc_head == &r->drop_desc; })
95102

96103
/* A stub length to drop maximum length packet. */
97104
#define VRING_DROP_DESC_MAX_LEN GENMASK(15, 0)
@@ -819,6 +826,50 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring,
819826
return true;
820827
}
821828

829+
static void mlxbf_tmfifo_check_tx_timeout(struct mlxbf_tmfifo_vring *vring)
830+
{
831+
unsigned long flags;
832+
833+
/* Only handle Tx timeout for network vdev. */
834+
if (vring->vdev_id != VIRTIO_ID_NET)
835+
return;
836+
837+
/* Initialize the timeout or return if not expired. */
838+
if (!vring->tx_timeout) {
839+
/* Initialize the timeout. */
840+
vring->tx_timeout = jiffies +
841+
msecs_to_jiffies(TMFIFO_TX_TIMEOUT);
842+
return;
843+
} else if (time_before(jiffies, vring->tx_timeout)) {
844+
/* Return if not timeout yet. */
845+
return;
846+
}
847+
848+
/*
849+
* Drop the packet after timeout. The outstanding packet is
850+
* released and the remaining bytes will be sent with padding byte 0x00
851+
* as a recovery. On the peer(host) side, the padding bytes 0x00 will be
852+
* either dropped directly, or appended into existing outstanding packet
853+
* thus dropped as corrupted network packet.
854+
*/
855+
vring->rem_padding = round_up(vring->rem_len, sizeof(u64));
856+
mlxbf_tmfifo_release_pkt(vring);
857+
vring->cur_len = 0;
858+
vring->rem_len = 0;
859+
vring->fifo->vring[0] = NULL;
860+
861+
/*
862+
* Make sure the load/store are in order before
863+
* returning back to virtio.
864+
*/
865+
virtio_mb(false);
866+
867+
/* Notify upper layer. */
868+
spin_lock_irqsave(&vring->fifo->spin_lock[0], flags);
869+
vring_interrupt(0, vring->vq);
870+
spin_unlock_irqrestore(&vring->fifo->spin_lock[0], flags);
871+
}
872+
822873
/* Rx & Tx processing of a queue. */
823874
static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
824875
{
@@ -841,6 +892,7 @@ static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
841892
return;
842893

843894
do {
895+
retry:
844896
/* Get available FIFO space. */
845897
if (avail == 0) {
846898
if (is_rx)
@@ -851,6 +903,17 @@ static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
851903
break;
852904
}
853905

906+
/* Insert paddings for discarded Tx packet. */
907+
if (!is_rx) {
908+
vring->tx_timeout = 0;
909+
while (vring->rem_padding >= sizeof(u64)) {
910+
writeq(0, vring->fifo->tx.data);
911+
vring->rem_padding -= sizeof(u64);
912+
if (--avail == 0)
913+
goto retry;
914+
}
915+
}
916+
854917
/* Console output always comes from the Tx buffer. */
855918
if (!is_rx && devid == VIRTIO_ID_CONSOLE) {
856919
mlxbf_tmfifo_console_tx(fifo, avail);
@@ -860,6 +923,10 @@ static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
860923
/* Handle one descriptor. */
861924
more = mlxbf_tmfifo_rxtx_one_desc(vring, is_rx, &avail);
862925
} while (more);
926+
927+
/* Check Tx timeout. */
928+
if (avail <= 0 && !is_rx)
929+
mlxbf_tmfifo_check_tx_timeout(vring);
863930
}
864931

865932
/* Handle Rx or Tx queues. */

0 commit comments

Comments
 (0)