Unverified Commit 07d45e80 authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

Merge tag 'aspeed-6.16-fixes-0' of...

Merge tag 'aspeed-6.16-fixes-0' of https://git.kernel.org/pub/scm/linux/kernel/git/bmc/linux into arm/fixes

ASPEED SoC driver fixes for 6.16

Address concerns in the ASPEED LPC snoop driver identified in the first two
patches of the cleanup series at [1].

[1]: https://lore.kernel.org/all/20250616-aspeed-lpc-snoop-fixes-v2-0-3cdd59c934d3@codeconstruct.com.au/

* tag 'aspeed-6.16-fixes-0' of https://git.kernel.org/pub/scm/linux/kernel/git/bmc/linux

:
  soc: aspeed: lpc-snoop: Don't disable channels that aren't enabled
  soc: aspeed: lpc-snoop: Cleanup resources in stack-order

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents fec3103b 56448e78
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ struct aspeed_lpc_snoop_model_data {
};

struct aspeed_lpc_snoop_channel {
	bool enabled;
	struct kfifo		fifo;
	wait_queue_head_t	wq;
	struct miscdevice	miscdev;
@@ -190,6 +191,9 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
	const struct aspeed_lpc_snoop_model_data *model_data =
		of_device_get_match_data(dev);

	if (WARN_ON(lpc_snoop->chan[channel].enabled))
		return -EBUSY;

	init_waitqueue_head(&lpc_snoop->chan[channel].wq);
	/* Create FIFO datastructure */
	rc = kfifo_alloc(&lpc_snoop->chan[channel].fifo,
@@ -236,6 +240,8 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
		regmap_update_bits(lpc_snoop->regmap, HICRB,
				hicrb_en, hicrb_en);

	lpc_snoop->chan[channel].enabled = true;

	return 0;

err_misc_deregister:
@@ -248,6 +254,9 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
static void aspeed_lpc_disable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
				     int channel)
{
	if (!lpc_snoop->chan[channel].enabled)
		return;

	switch (channel) {
	case 0:
		regmap_update_bits(lpc_snoop->regmap, HICR5,
@@ -263,8 +272,10 @@ static void aspeed_lpc_disable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
		return;
	}

	kfifo_free(&lpc_snoop->chan[channel].fifo);
	lpc_snoop->chan[channel].enabled = false;
	/* Consider improving safety wrt concurrent reader(s) */
	misc_deregister(&lpc_snoop->chan[channel].miscdev);
	kfifo_free(&lpc_snoop->chan[channel].fifo);
}

static int aspeed_lpc_snoop_probe(struct platform_device *pdev)